Closed akki12345 closed 7 years ago
So what is the exact format that you need to provide to the payment provider? Say the price is 1200.99 dollars, what must the format be?
Here's how we called the method as a workaround to format the total for our Stripe payment gateway:
$total = Cart::total(null,null,'');
PHP datatype coercion took care of the rest.
Okay, so for the time being please use the workaround @jmarkese gave. This is even more reason for me to strip out this 'number_format' feature. It really seems to give me more troubles that it actually solves...
For the alternative https://github.com/bumbummen99/LaravelShoppingcart which is the forked project of https://github.com/Crinsane/LaravelShoppingcart and also support the latest Laravel versions.
There is a method called Cart::totalFloat()
which will return your float value for the cart total.
############### OR #################
For this package just convert the number format back to integer or float values. An example is shown below
$num = '1,200,998.255';
########## FOR FLOAT VALUES ###########################
echo filter_var($num, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
########## FOR INTEGER VALUES ###########################
echo filter_var($num, FILTER_SANITIZE_NUMBER_INT);
Hello all, I'm in big trouble, The issue I am running into is integrating this cart library with a payment service such as payumoney which expects the order total to be expressed in the string format( Amount is the total amount of the transaction (greater than 0) in INR, without a currency symbol or other non-numeric character. Only a decimal allowed). i'm updating the number format in cart config file(cart.php) and remove "," on thousand_separator. Now the cart::total() is converting to 1, 503.00 to 1503.00 so payumoney does not accept this but the magic think is this when the cart:total() is in three digit means 840.98 or 999.57 this amount is accepted by the payumoney. please help me, thank you in advance @Crinsane @jmarkese