-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to Authorize Payment #133
Comments
Can we configure the webhook to be the source of truth to somehow update everything that is needed in Medusa. It is only right as so many failures can happen on client anyway. Or what would be the implication of trying to complete a cart on client that Paystack's Webhook has already a second ago updated |
No that shouldn't be an issue, the webhook is designed to complete the cart without any interaction from the client, so you don't lose transactions if they don't click the complete button for example. Could you confirm your cart's payment session data has a the You could fetch the payment session data for the cart in image two for example by running this SQL query in your Medusa database SELECT * FROM "public"."payment_session" WHERE cart_id='cart_01HW5MMEG5HTAWQYEWEQSH1PDB' When
If it does not include this then the transaction wasn't initialized correctly, which would point to another error higher up that would help better diagnose this |
Now when running in a live environment. These are the logs
This is my setup, local:3000 connecting to local redis, live db ('staging-db'). Just to ensure events are not getting mixed up with. So I do first local transaction, the results in the screenshot, i.e 400 on local browser, everything good in live server in terms of hooks. And second transaction (All Live no local), here in this comment. Results...1. Success in browser i.e user is redirected to order complete, 2. but the error 400 happens in live server now |
There's a ton of information here (thank you for that), but not enough to tell what is the issue definitively from here - missing importantly the debug logs printed when the webhook event is first received. I'm going to go out on a limb and say this is most likely happening because you have different Paystack secret keys across your local and staging envs but are using the same database. This also does not look to be a webhook specific issue - you get the same "Transaction reference not found" error when you complete the cart with the "/complete" endpoint from the frontend as you do when the plugin tries to complete the cart on a webhook event. I'm going to walk through what happens when a payment is made and the plugin tries to authorize the payment so you can either figure it out or help us understand which part of the plugin is being problematic. When a user clicks "Pay with Paystack" on the frontend, a payment session is initialized by Medusa. Medusa asks this pluign to initialize a payment session as well so it initializes a payment with Paystack and adds the reference for that transaction to the payment session's data (which is part of the cart). After a user completes the payment you call the To authorize the payment, the plugin retrieves the cart being completed by id (this id is part of the webhook event received or received as part of the What is happening in your case here is when the obtained reference is sent to Paystack, Paystack says it has no knowledge of a transaction with that reference on your account. You should confirm the reference received in the webhook or added to your cart's payment session data is a valid transaction on your Paystack dashboard and then confirm the secret key for that account is actually what is in your Medusa backend. Note the reference received in the webhook event (4f65cfd2rw): |
I keep getting error
An error occurred while processing paystack.webhook_event: Error: Paystack Payment error: Failed to authorize payment:
when a payment is made. On v1.3.0At times the payment is captured and at times it's not.
The text was updated successfully, but these errors were encountered: