Replies: 1 comment
-
|
I would some how like to be able to update the payment session based on the query parameters returned from the gateway in the redirect. OR be able to pass arguments to authorizePayment when I do cart.complete |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am struggling with integration of 2 payment providers which are totally redirection based. Heres where I am at so far:
How both these gateways work is,
I initiate the payment which is implemented initiatePayment
This payment session is then handed over to the frontend, which creates a form and submits the form to the payment gateway with POST method.
Upon successful payment, the payment gateway redirects back to the success URL, which is a route implemented in the frontend, with details about the payment in the query parameter.
The next step in the payment flow is to validate the payment (validate the query parameters), which I cant figure out how.
I sort of figured there are 2 ways to do this (looking at other payment providers plugin in github)
What I see mollie payment and paystack plugins doing, is checking the payment status in authorizePayment method, (which I cannot do, as these gateways dont have payment status check functionality)
So, I turned to the second option I have. Call the webhook endpoint from the frontend with the payload in query string. This part worked for the successful payments, as I could pass along the querystring params, and the getWebhookActionAndData would do the validation (which is sha signature validation) and return action 'captured'
But the problem is, this does not work for cancelled payments, because action: 'canceled', from getWebhookActionAndData is totally ignored https://github.com/medusajs/medusa/blob/develop/packages/medusa/src/subscribers/payment-webhook.ts#L44
and the payment session remains in pending, which causes further error, as next attempt to payment will include the same id, and the gateway complains about duplicate transaction attempt.
The payment flow here is almost like the classic paypal flow, where you submit a form, and after successful payment or failed payment, you are redirected to the URL you specified with details in query string.
How else can I achieve this?
Beta Was this translation helpful? Give feedback.
All reactions