Bug#pwa 3029::[bug]: Selecting payment method causing graphql error #4115
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Describe the bug
In 12.7 a fix was made to visually select the method of payment that is saved as selected on the quote. However it also added an onChange function that executes a mutation to save the payment method.
https://github.com/magento/pwa-studio/pull/3969/files#diff-b3bc0e73e1c57b4b69ad1d1cc59b3d3e60021bd9ec46a399b73305079e2ebb11R54
This causes a graphql error for custom payment methods that require additional information. This can be seen by the need to pass in braintree data, which wouldn't be needed for non-braintree payment methods. Other payment methods require their own "braintree equivalent" data in order to be set
Example for our custom payment method for Moneris (code: mht), we now get an error when selecting the payment method radio button:
message: "Required parameter "mht" for "payment_method" is missing."
Data sent to graphql endpoint:
``{{
variables: {
cartId: "ZSNL4bWFnEaYmrtCcinryj76gCvoDcho"
paymentMethod: {
code: "mht",
braintree :
{ is_active_payment_token_enabler: false payment_method_nonce: "mht" }
}
}
}}`{{
Expected behavior
No graphql error when changing radios for payment method
Possible solutions
Don't call setPaymentMethodOnCart at a higher level than the payment method. Leave saving the payment method to the payment method (usually when going to review step, not when selecting the radio)
Related Issue
Closes https://jira.corp.adobe.com/browse/PWA-3029
Acceptance
Verification Stakeholders
Specification
Verification Steps
Test scenario(s) for direct fix/feature
Test scenario(s) for any existing impacted features/areas
Test scenario(s) for any Magento Backend Supported Configurations
Is Browser/Device testing needed?
Any ad-hoc/edge case scenarios that need to be considered?
Screenshots / Screen Captures (if appropriate)
Breaking Changes (if any)
Checklist