Open justinelut opened 1 month ago
Medusa 2 support
Hi @justinelut 👋 This plugin has not yet been updated to support Medusa 2 hence the error you're facing. If you or anyone has adapted the service to work with Medusa 2 already, contributions are very welcome. Otherwise, I have this on the roadmap for the plugin and support will be added soon.
Unfortunately i am a frontend developer and i dont know how to develop npm packages, i was developing a nextjs application for an ecommerce application based in kenya, i was using your paystack module and medusa, i have completed the frontend and deployed the backend but am unable to add payment,
Started working on V2 support in #v2-support
Hey, I am also in a similar position as @justinelut
Just wanted to ask, how long do you think updating the plugin to V2 will take? Sorry if its a bother, just unsure on the process
A beta version of this plugin with support for Medusa V2 has been published under the next
tag.
You are welcome to try it out and report early issues here
npm install medusa-payment-paystack@next
You can find a tentative list of breaking changes here.
I expect to be done with the rest of the migration - tests, updating starters and writing a migration guide soon.
Awesome thank you so much
From your screenshots, the Paystack session hasn't been initialised. Enable debug mode in the backend if it isn't already, you should see an error after choosing Paystack.
If the error says you're missing an email address make sure your call to initiatePaymentSession
in the storefront contains the user's email as part of the context:
everything is working fine but i get an error, when paystack pops up, duplicate transaction reference
I imagine this is because you're retrying the failed transaction above and should go away with a new cart. To confirm, you are getting the reference in the storefront now yes?
You can force a new cart to be created by removing the _medusa_cart_id
cookie in your devtools then try again
just cleared the card id but still getting the same error, duplicate transaction reference
@justinelut You will have to provide more information for me to be able to help you.
paystackTxAuthData
(will be at the same place you find the transaction reference) and then seeing the amount shown therebackend paystack data is there as you can see in the above screenshot, the errors below arrises from paystack but as you can see am using the same ref from the backend in the request , and after i still get the below error
here is my implementation of the paystack button
@justinelut the issue is you're passing a different amount on the frontend than is sent to Paystack on the backend.
You're looking to pay 87089KES on your store. Paystack requires you send the value in the smallest subunit of the currency, i.e. amount * 100. The plugin sends Paystack the amount therefore as 8708900. Since the transaction has been initiated with that amount, when you send 87089 to Paystack on the frontend they return that 400 error.
To fix this, multiply the cart total in the frontend by 100 so the amount sent to Paystack is in the smallest currency sub-unit. i.e. in the amount
prop passed to PaystackButton
, multiple cart.total
by 100.
finally that worked, thnak you so much, let me continue testing it
This among other reasons is why for V2 of this plugin, we'll likely no longer be recommending the react-paystack library. Paystack has a "Resume transaction" flow designed especially for this usecase which the library doesn't support. The storefront should not have to deal with the details of the transaction, it should just "resume" the transaction initiated on the backend.
I have an open issue filed in the react-paystack library - https://github.com/iamraphson/react-paystack/issues/113 and there's an open PR https://github.com/iamraphson/react-paystack/pull/110 adding partial support for it which both haven't received any activity so it isn't likely it will be added there anytime soon.
In V2, the recommended flow will be taking only the accessCode
returned by the plugin and passing it to the Paystack popup to resume the transaction. No more fiddling with amounts and currency codes on the storefront. The one source of truth will be the transaction initialised on the backend.
Thank you this works for me and am able to capture payments in the paystack dashboard, i think paystack should fix that multiplying by 100, its so frustrating to debug, if you dont follow the documentation properly
This among other reasons is why for V2 of this plugin, we'll likely no longer be recommending the react-paystack library. Paystack has a "Resume transaction" flow designed especially for this usecase which the library doesn't support. The storefront should not have to deal with the details of the transaction, it should just "resume" the transaction initiated on the backend.
I have an open issue filed in the react-paystack library - iamraphson/react-paystack#113 and there's an open PR iamraphson/react-paystack#110 adding partial support for it which both haven't received any activity so it isn't likely it will be added there anytime soon.
In V2, the recommended flow will be taking only the
accessCode
returned by the plugin and passing it to the Paystack popup to resume the transaction. No more fiddling with amounts and currency codes on the storefront. The one source of truth will be the transaction initialised on the backend.
Thanks for the latest update.
Looks like resumetransaction
only accepts one parameter(accessCode
) as seen here. Where to place await placeOrder()
now if i'm using that method?
UPDATE: i was using @types/paystack__inline-js
to get the types hence the confusion. i got the correct type definitions by borrowing code from https://github.com/adefemi/paystack-inline-ts
Error: Loaders for module Payment failed: medusa-payment-paystack doesn't seem to have a main service exported -- make sure your module has a default export of a service, is there a way to fix this because am using medusa v2 for my store.