openfoodfoundation / openfoodnetwork

Connect suppliers, distributors and consumers to trade local produce.
https://www.openfoodnetwork.org
GNU Affero General Public License v3.0
1.1k stars 712 forks source link

[Stripe] Add system spec to save card during checkout #3952

Open mkllnk opened 5 years ago

mkllnk commented 5 years ago

What we should change and why (this is tech debt)

Follow up from #1723. A user can enter credit card details during checkout. They can also decide to store those details for later checkouts by ticking a box. This is not covered in our feature specs.

The difficulty is that the Stripe card form is loaded in an iframe and some Stripe Javascript is sending an API request from the browser to the Stripe API. We don't have any way to intercept that request at the moment. We need to add Puffing Billy to intercept and mock these requests. That would also enable us to deal with Google Maps offline. https://github.com/oesmith/puffing-billy

The first failing web request:

POST https://api.stripe.com/v1/tokens

Described in https://stripe.com/docs/api/tokens/create_card.

Context

I'm investigating how a card is stored for #3727. I thought it's best done in a spec because that's easy to repeat. When trying to implement this spec I came across this difficulty.

Impact and timeline

This should be done before we refactor Stripe a lot. That's probably soon due to #3927.

filipefurtad0 commented 5 months ago

We need to add Puffing Billy to intercept and mock these requests.

Noting that we've given up on this approach, since we could not deal with concurrent ports (puma vs. puffing-billy). Signalling this here in case we come up with a different approach to setup a proxy to intercept browser requests - I guess this is still a nice to have, so leaving the issue open.