wp-graphql / wp-graphql-woocommerce

Add WooCommerce support and functionality to your WPGraphQL server
https://woographql.com
GNU General Public License v3.0
645 stars 131 forks source link

Checkout mutation working only every second time #614

Open kedvardas1 opened 2 years ago

kedvardas1 commented 2 years ago

Help needed! We are using two Checkout mutations. One is for successful order with isPaid: true. Second one with isPaid: false if stripe payment intent fails (we are using 3DS here in Europe). And the problem is with isPaid: false.

Steps to reproduce the behavior:

  1. Order created in Woocommerce with status "Failed" after user fails a payment intent. He gets message from stripe elements that payment failed due something.
  2. User clicks same button and same flow goes again. Anyway if payment is succesful in Stripe or not Woocommerce returns Payment processing error failed (error comes from Stripe plugin as I debugged but that's try catch from WP)

Expected behavior I am sure it should not show "Payment processing failed." error. We should see thank you page if payment intent successful or error from stripe react elements if payment intent fails.

Here is the mutation if payment fails from first time mutation Checkout( $metaData: [MetaDataInput] $billing: CustomerAddressInput ) { checkout( input: { paymentMethod: "stripe" metaData: $metaData billing: $billing isPaid: false } ) { order { cartHash databaseId needsPayment } } }

Here is the mutation for success payment mutation Checkout( $metaData: [MetaDataInput] $billing: CustomerAddressInput $transactionId: String! ) { checkout( input: { paymentMethod: "stripe" metaData: $metaData billing: $billing isPaid: true transactionId: $transactionId } ) { order { cartHash databaseId needsPayment } } }

Plugin Versions**

Any suggestions, documentation or problems already solved somewhere?

kidunot89 commented 2 years ago

@kedvardas1 If you want to process a payment through a WooCommerce's payment gateway don't set isPaid.

isPaid: true tells WooGraphQL to skip the payment processing step and that this order was paid for outside of WooCommerce.

kedvardas1 commented 2 years ago

@kidunot89 yes I know. we are using isPaid: true only when payment is succesful from React Stripe elements.

the problem I wrote about is with isPaid: false

kidunot89 commented 2 years ago

@kedvardas1 passing false to isPaid has no purpose. If you aren't setting it to true leave it out.

kidunot89 commented 2 years ago

@kedvardas1 are you passing the stripe intent as metaData?

kedvardas1 commented 2 years ago

@kidunot89 okay, thanks.

yes, as metaData. stripe intent id and customer id

ADDED: seems check_source / prepared_source is failing every second time