Open temple300 opened 4 years ago
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.
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.
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.
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.
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.
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.
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