Closed kevinrobert3 closed 8 months ago
Yes you are right on the plugin taking the cart amount and sending that to Paystack. In Medusa and the plugin by extension, prices are represented in the lowest denomination of the currency. To charge KES 3650 in your case, you need to provide the prices in the admin as 3650 * 100.
The default Medusa starter localizes the amounts and so it should show up as KES 3650 on your frontend pages with 365000 given to the plugin and subsequently sent to Paystack.
Please do create a separate issue for the transaction failing issue. The error logs you added are indicative of an issue after the original failure which probably happened in the plugin. You could enable debug mode in the plugin to see extra logs which could guide you to what is failing. Add debug: true
to the plugin's config to enable debug mode
Isn't that a bit off that I need to add my prices in backend as KES 365000, that means changing so much across the board, e.g. for other currencies, showing it back in storefront etc. When we could get an option to change the value before the plugin consumes it. Adding the prices as n * 100 in backend is changing a lot of inner workings, even for reporting, only to accommodate Paystack. Also check the other issue similar to this, that would mean the person has to change the prices in their backend in the live environment to accommodate paystack
It would also mean that someone who has used a different payment processor and chooses Paystack later with the plugin would have to change all their product prices to n * 100 to use the plugin.
I propose push a breaking change in plugin doing the n * 100 internally. Everybody is sorted that way in the most least effort way
I am confused. To clarify, are you using the default Medusa admin dashboard?
If you are, this is what adding KES prices should look like:
When being saved to the backend, the admin dashboard automatically localizes the prices to the lowest denomination before sending to the backend, i.e. the n*100 conversion you want done.
Prices will be stored in the database with this value and all the other parts of Medusa (fulfillment, storefront, this plugin etc) expect the prices in the lowest denomination. Paystack also expects amounts in the lowest denomination (i.e. to pay KES 3650, the amount value sent to Paystack needs to be 365000). You can confirm this from the Checkout demo.
This is the default behaviour and I suggested performing the n*100 conversion yourself because I imagined you were on a custom admin. You shouldn't need to do that otherwise.
You'd have to provide more information on your setup and changes you have added that may affect how amounts are set in your store for us to be able to help.
Oh wow. I actually really noticed the prices in the other issue' screenshots. I had not noticed this price amounts. Yes I am on a custom admin. This is all fine then. The most weird thing to do and see, however, but I'll change the prices on my end. I'll close this one and open the other issue
We are using KES and are guessing the plugin takes the cart amount as the actual cart amount, e.g KES 3650 is translated as KES 3650 to Paystack by plugin.
The issue comes in the popup, when one passes 3650 * 100 you get a 'duplicate transaction reference'. Passing it as original amount "3650" makes the payment KES 36.5 which is wrong but payment succeeds.
Also I don't know whether to raise a new issue for this too. But when the erroneous "KES 36.5" transaction completes the plugin fails to complete the cart with error
and
I am guessing the plugin is somehow looking to check if amounts are same. Which would always be false since cart has KES 3650 (in db/medusa) and paid amount is KES 36.5 (paystack)