laravel-paystack icon indicating copy to clipboard operation
laravel-paystack copied to clipboard

Done. Upgrade to the latest version. version 1.0.4, Still getting same response, invalid amount.

Open temple300 opened this issue 5 years ago • 7 comments

Error is 401 Unauthorized,

Done. Upgrade to the latest version. version 1.0.4

Originally posted by @unicodeveloper in https://github.com/unicodeveloper/laravel-paystack/issues/78#issuecomment-633094730

temple300 avatar May 27 '20 23:05 temple300

error

temple300 avatar May 27 '20 23:05 temple300

Battled with this over 2 hours yesterday before i found a fix. From the Paystack::makePaymentRequest() method, you are expected to pass "quantity" because the value of quantity will be multiplied by the value of amount. If you don't set a value for quantity, the value of amount when calculated will be zero. You can solve this by passing an hidden input value of quantity to be set to 1 or just remove the variable quantity that was multiplied with amount. see the screenshot i attached. Screenshot 2020-05-28 at 08 27 26

seunsekoni avatar May 28 '20 07:05 seunsekoni

This is very interesting. The package expects that the user puts the value of quantity in the form via a hidden field. And it's stated in the README file.

unicodeveloper avatar May 28 '20 09:05 unicodeveloper

It wasn't stated as a required field in the README file. I for one don't need the quantity field for my payments but i realised it's required in the make Paystack::makePaymentRequest() to calculate the value of amount. Hence, why i removed it.

seunsekoni avatar May 28 '20 11:05 seunsekoni

In the sample form (in the README), I added it. I never really thought anyone would omit putting a quantity field (apparently I was wrong). Maybe in a new release, I can default the quantity to 1 if quantity is not added to the form field to prevent hair-pulling situations like this.

sample_form

unicodeveloper avatar May 28 '20 11:05 unicodeveloper

Serious? Are you supposed to have any business with dev's quantity? In my case, we're operating a store where multiple products can be purchased with different quantities. What if I want to include some other variable after multiplying by quantity? How do you calculate it then? The simple solution is to accept whatever amount you're given and leave multiplication arithmetic to the dev. If the underlying API requires a "quantity", it's safe to also pass it without our knowledge. I'm not sure they'll encourage such poor design, though.

temple300 avatar May 28 '20 14:05 temple300

I totally get your use case. You are right. For folks dealing with specific/just one product, it makes sense for them. In previous versions, I left out calculating the amount with quantities.

unicodeveloper avatar Jun 11 '20 06:06 unicodeveloper