Making Stripe Payment Gateway Calculate Total and Item based on Form

Ooops, this commit should fix the coupon stuff:

https://github.com/Fabrik/fabrik/commit/2d4cbf80fb3d582aa9bb3b098a848064b2663ece

... so it no longer shows if no coupon element selected.

The main problem with changing the price/item on the form is that, unlike (say) when using the PayPal plugin, the Stripe workflow requires the price and item to be known on the browser side. When the Stripe dialog pops up to collect the CC information, the price has to be passed to their JavaScript code, and is shown in the Stripe dialog. With things like PayPal, that data is only needed on the server side after submission.

And, as you probably know, doing anything in JavaScript is not entirely trivial, especially in something like Fabrik, where we have to provide a generic mechanism for doing it. For example, if you were using (say) join and CDD elements to display the item and cost, the value of those elements is going to be table keys, not the actual cost and name. And even if the cost is shown in the join's label, it would probably be formatted ... and could be formatted in a zillion different way, making "unformatting" it back to the raw "pennies" format (so $29.99 is 2999, or DM 67,89 is 6789) needed by Stripe very difficult.

I'll take a look at finding a simple way to do it, and let you know how long I think it would take. I think the only really viable way is to add some AJAX handling, which passes the current state of the the form data, so the same price/item code can be run that currently gets run for calculating the "static" values.

-- hugh
 
Thanks. Being able to get the currency from the form would also be very useful. I will be using stripe for payment at the end of an order, where the total depends in the item and sales taxes so we dont know the amount to charge until the form is complete.
 
Last edited:
I am clutching at straws...As a workaround, is it practical to install the stripe PHP library and just use the Stripe PHP https://stripe.com/docs/checkout/php and execute on form save?

I have been also trying to use a second payment form that autofills with the 3 payment elements from the first form, for payment, and can't get it working either!

Happy to put up a bounty if it is possible to get the stripe plugin to work with ajax data.
 
As an update, I do have stripe payment kind of working the way I want, but moving to a payment form with hidden fields after the main part of the order. This then has the item and amount loaded from the previous form that stripe can use. It isn't really elegant and has some holes that a smart customer can use to adjust the hidden fields, but it does work. (getting it to work as a single form would be even better with AJAX)

However, I am now up against a new obstacle. The currency always ends up as USD no matter what I have in the currency field. I have tried CAD but still goes through as USD. (Trying to use a placeholder for some reason didn't send the token to stripe and the payment failed). The currency is shown correctly in the charge section where it says "Purchase item for CA$45.90" for Canadian or "Purchase item for ?45.90" when GBP but the transaction is posted to stripe as "usd"
 
Sorry for the many posts on the Stripe plugin. Is anyone successfully using this? I am pulling my hair out with it!

- The currency charged is always USD no matter what we enter and what shows in the text before the charge
- We tried the update for the no coupon situation linked above. This results in error "0 Call to undefined method PlgFabrik_FormStripe::doLog() ". We went back to the older version
- We get a frequent error when charging that we cant isolate exactly when. "Validation failed. There was an internal error reported by the Stripe payment processing servers, please try again later." From the Stripe console, this happens because it seems to be sending the POST /v1/charges without having first got a token with POST /v1/tokens. Seems to skip a step. This happens at random around 20% of the time, but seems to happen more when we clear the cookies. We can't identify what exactly makes this happen. Clicking again usually fixes the problem.

When it works, it certainly does the job. I am sure will be a great solution once the kinks are out of it
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top