magento / pwa-studio

🛠Development tools to build, optimize and deploy Progressive Web Applications for Magento 2.
https://developer.adobe.com/commerce/pwa-studio/
Open Software License 3.0
1.07k stars 683 forks source link

PWA-3029::[bug]: Selecting payment method causing graphql error #4096

Closed glo82145 closed 1 year ago

glo82145 commented 1 year ago

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

pwa-studio-bot commented 1 year ago
Fails
:no_entry_sign: `node` failed.
:no_entry_sign: Unable to build scaffolded project. ``` yarn build ``` within a scaffolded project directory failed. Learn more about Scaffolding at https://magento.github.io/pwa-studio/pwa-buildpack/scaffolding/.
:no_entry_sign: GraphQL queries did not pass. Make sure to execute `yarn run validate-queries` locally prior to committing.
:no_entry_sign: The following file(s) did not pass **ESLint**. Execute `yarn run lint` locally for more details ``` packages/extensions/venia-sample-payments-checkmo/src/talons/checkmo.gql.js packages/pagebuilder/lib/ContentTypes/Products/Carousel/carousel.gql.ce.js packages/pagebuilder/lib/ContentTypes/Products/Carousel/carousel.gql.ee.js packages/peregrine/lib/hooks/useCustomerWishlistSkus/customerWishlist.gql.ce.js packages/peregrine/lib/hooks/useGoogleReCaptcha/googleReCaptchaConfig.gql.js packages/peregrine/lib/talons/AddToCartDialog/addToCartDialog.gql.js packages/peregrine/lib/talons/AddressBookPage/addressBookFragments.gql.js packages/peregrine/lib/talons/AddressBookPage/addressBookPage.gql.js packages/peregrine/lib/talons/AuthModal/authModal.gql.js packages/peregrine/lib/talons/Breadcrumbs/breadcrumbs.gql.js packages/peregrine/lib/talons/CartPage/GiftCards/giftCardFragments.gql.ee.js packages/peregrine/lib/talons/CartPage/GiftCards/giftCardFragments.gql.js packages/peregrine/lib/talons/CartPage/GiftCards/giftCardQueries.gql.ee.js packages/peregrine/lib/talons/CartPage/PriceAdjustments/CouponCode/couponCode.gql.js packages/peregrine/lib/talons/CartPage/PriceAdjustments/CouponCode/couponCodeFragments.gql.js packages/peregrine/lib/talons/CartPage/PriceAdjustments/GiftOptions/giftOptions.gql.js packages/peregrine/lib/talons/CartPage/PriceAdjustments/GiftOptions/giftOptionsFragments.gql.js packages/peregrine/lib/talons/CartPage/PriceAdjustments/ShippingMethods/shippingMethods.gql.js packages/peregrine/lib/talons/CartPage/PriceAdjustments/ShippingMethods/shippingMethodsFragments.gql.js packages/peregrine/lib/talons/CartPage/PriceAdjustments/giftOptionsSection.gql.js packages/peregrine/lib/talons/CartPage/PriceSummary/discountSummary.gql.js packages/peregrine/lib/talons/CartPage/PriceSummary/priceSummary.gql.js packages/peregrine/lib/talons/CartPage/PriceSummary/priceSummaryFragments.gql.js packages/peregrine/lib/talons/CartPage/PriceSummary/shippingSummary.gql.js packages/peregrine/lib/talons/CartPage/PriceSummary/taxSummary.gql.js packages/peregrine/lib/talons/CartPage/ProductListing/EditModal/productForm.gql.js packages/peregrine/lib/talons/CartPage/ProductListing/EditModal/productFormFragment.gql.js packages/peregrine/lib/talons/CartPage/ProductListing/product.gql.js packages/peregrine/lib/talons/CartPage/ProductListing/productListing.gql.ce.js packages/peregrine/lib/talons/CartPage/ProductListing/productListing.gql.ee.js packages/peregrine/lib/talons/CartPage/ProductListing/productListingFragments.gql.js packages/peregrine/lib/talons/CartPage/cartPage.gql.js packages/peregrine/lib/talons/CartPage/cartPageFragments.gql.js packages/peregrine/lib/talons/CategoryList/categoryList.gql.js packages/peregrine/lib/talons/CategoryTree/categoryTree.gql.js packages/peregrine/lib/talons/CheckoutPage/AddressBook/addressBook.gql.js packages/peregrine/lib/talons/CheckoutPage/AddressBook/addressBookFragments.gql.js packages/peregrine/lib/talons/CheckoutPage/BillingAddress/billingAddress.gql.js packages/peregrine/lib/talons/CheckoutPage/ItemsReview/itemsReview.gql.js packages/peregrine/lib/talons/CheckoutPage/ItemsReview/itemsReviewFragments.gql.js packages/peregrine/lib/talons/CheckoutPage/OrderConfirmationPage/createAccount.gql.js packages/peregrine/lib/talons/CheckoutPage/OrderConfirmationPage/orderConfirmationPageFragments.gql.js packages/peregrine/lib/talons/CheckoutPage/PaymentInformation/braintreeSummary.gql.js packages/peregrine/lib/talons/CheckoutPage/PaymentInformation/creditCard.gql.js packages/peregrine/lib/talons/CheckoutPage/PaymentInformation/editModal.gql.js packages/peregrine/lib/talons/CheckoutPage/PaymentInformation/paymentInformation.gql.js packages/peregrine/lib/talons/CheckoutPage/PaymentInformation/paymentMethods.gql.js packages/peregrine/lib/talons/CheckoutPage/PaymentInformation/summary.gql.js packages/peregrine/lib/talons/CheckoutPage/ShippingInformation/AddressForm/customerForm.gql.js packages/peregrine/lib/talons/CheckoutPage/ShippingInformation/AddressForm/guestForm.gql.js packages/peregrine/lib/talons/CheckoutPage/ShippingInformation/shippingInformation.gql.js packages/peregrine/lib/talons/CheckoutPage/ShippingInformation/shippingInformationFragments.gql.js packages/peregrine/lib/talons/CheckoutPage/ShippingMethod/shippingMethod.gql.js packages/peregrine/lib/talons/CheckoutPage/ShippingMethod/shippingMethodFragments.gql.js packages/peregrine/lib/talons/CheckoutPage/checkoutPage.gql.js packages/peregrine/lib/talons/CheckoutPage/checkoutPageFragments.gql.js packages/peregrine/lib/talons/Cms/cmsPage.gql.js packages/peregrine/lib/talons/CmsDynamicBlock/cmsDynamicBlock.gql.js packages/peregrine/lib/talons/CommunicationsPage/communicationsPage.gql.js packages/peregrine/lib/talons/ContactPage/contactUs.gql.js packages/peregrine/lib/talons/CreateAccount/createAccount.gql.js packages/peregrine/lib/talons/FilterModal/filterModal.gql.js packages/peregrine/lib/talons/Footer/footer.gql.js packages/peregrine/lib/talons/Gallery/addToCart.gql.js packages/peregrine/lib/talons/Gallery/gallery.gql.ce.js packages/peregrine/lib/talons/Gallery/gallery.gql.ee.js packages/peregrine/lib/talons/Header/accountMenu.gql.js packages/peregrine/lib/talons/Header/cartTriggerFragments.gql.js packages/peregrine/lib/talons/Header/currencySwitcher.gql.js packages/peregrine/lib/talons/Header/storeSwitcher.gql.js packages/peregrine/lib/talons/MagentoRoute/magentoRoute.gql.js packages/peregrine/lib/talons/MegaMenu/megaMenu.gql.js packages/peregrine/lib/talons/MiniCart/ProductList/productListFragments.gql.js packages/peregrine/lib/talons/MiniCart/miniCart.gql.js packages/peregrine/lib/talons/MiniCart/miniCartFragments.gql.js packages/peregrine/lib/talons/Navigation/navigation.gql.js packages/peregrine/lib/talons/Newsletter/newsletter.gql.js packages/peregrine/lib/talons/OrderHistoryPage/orderHistoryContext.gql.js packages/peregrine/lib/talons/OrderHistoryPage/orderHistoryPage.gql.js packages/peregrine/lib/talons/OrderHistoryPage/orderRow.gql.js packages/peregrine/lib/talons/ProductFullDetail/productFullDetail.gql.ce.js packages/peregrine/lib/talons/ProductFullDetail/productFullDetail.gql.ee.js packages/peregrine/lib/talons/RootComponents/Category/category.gql.js packages/peregrine/lib/talons/RootComponents/Category/categoryContent.gql.js packages/peregrine/lib/talons/RootComponents/Category/categoryFragments.gql.js packages/peregrine/lib/talons/RootComponents/Product/product.gql.js packages/peregrine/lib/talons/RootComponents/Product/productDetailFragment.gql.js packages/peregrine/lib/talons/SavedPaymentsPage/creditCard.gql.js packages/peregrine/lib/talons/SavedPaymentsPage/savedPaymentsPage.gql.js packages/peregrine/lib/talons/SearchPage/searchPage.gql.js packages/peregrine/lib/talons/SignIn/signIn.gql.js packages/peregrine/lib/talons/Wishlist/AddToListButton/addToListButton.gql.js packages/peregrine/lib/talons/Wishlist/WishlistDialog/CreateWishlistForm/createWishlistForm.gql.js packages/peregrine/lib/talons/Wishlist/WishlistDialog/wishlistDialog.gql.js packages/peregrine/lib/talons/WishlistPage/createWishlist.gql.js packages/peregrine/lib/talons/WishlistPage/wishlist.gql.js packages/peregrine/lib/talons/WishlistPage/wishlistConfig.gql.ce.js packages/peregrine/lib/talons/WishlistPage/wishlistConfig.gql.ee.js packages/peregrine/lib/talons/WishlistPage/wishlistFragment.gql.ee.js packages/peregrine/lib/talons/WishlistPage/wishlistFragment.gql.js packages/peregrine/lib/talons/WishlistPage/wishlistItem.gql.js packages/peregrine/lib/talons/WishlistPage/wishlistItemFragments.gql.js packages/peregrine/lib/talons/WishlistPage/wishlistPage.gql.js packages/venia-ui/lib/RootComponents/Category/category.gql.js packages/venia-ui/lib/components/AccountChip/accountChip.gql.js packages/venia-ui/lib/components/AccountInformationPage/accountInformationPage.gql.js packages/venia-ui/lib/components/AccountInformationPage/accountInformationPageFragment.gql.js packages/venia-ui/lib/components/Country/country.gql.js packages/venia-ui/lib/components/ForgotPassword/forgotPassword.gql.js packages/venia-ui/lib/components/Header/cartTrigger.gql.js packages/venia-ui/lib/components/Header/currencySwitcher.gql.js packages/venia-ui/lib/components/LegacyMiniCart/cartOptions.gql.js packages/venia-ui/lib/components/LegacyMiniCart/editFormFragment.gql.js packages/venia-ui/lib/components/MiniCart/miniCart.gql.js packages/venia-ui/lib/components/MyAccount/ResetPassword/resetPassword.gql.js packages/venia-ui/lib/components/Region/region.gql.js packages/venia-ui/lib/components/SignIn/signIn.gql.js ```
:no_entry_sign: The following file(s) were not formatted with **prettier**. Make sure to execute `yarn run prettier` locally prior to committing. ``` packages/peregrine/lib/talons/CheckoutPage/PaymentInformation/usePaymentMethods.js ```
Messages
:book: Associated JIRA tickets: [PWA-3029](https://jira.corp.magento.com/browse/PWA-3029).
:book: DangerCI Failures related to missing labels/description/linked issues/etc will persist until the next push or next pr-test build run (assuming they are fixed).
:book: Access a deployed version of this PR [here](https://pr-4096.pwa-venia.com/). Make sure to wait for the "pwa-pull-request-deploy" job to complete.

Log

ERROR ON TASK: prettierCheck

ERROR ON TASK: eslintCheck

ERROR ON TASK: validateQueries

ERROR ON TASK: scaffoldingSucceeds


Error:  Danger had errors running. See message(s) above for more details.
danger-results://tmp/danger-results.json

Generated by :no_entry_sign: dangerJS against c80fe0663f50f4ef526007e1b006f91908f618a1