Is there any way to prefill payment information in stripe elements?
Asked Answered
R

3

6

I am using Stripe elements payment form in my code. While doing testing in Galen, we have to switch to the iframe to fill the payment information and test the entire flow. But, iOS doesn't allow us to switch iframes due to its CORS policy.

Is there any way to prefill the information in the payments form so that we can test our code in iOS?

Rademacher answered 25/6, 2019 at 7:8 Comment(0)
R
5

I asked the same to the Stripe Support team. They suggested the following:

"In general, we do not support or recommend automated testing of Elements by pre-filling details. The internal structure of the iframe(class names, DOM structure) is subject to change at any time so it's not generally safe to write code that accesses this.

The recommendation instead is to test by using Stripe's test tokens[0] — so essentially, in testing, you would stub out the payment form itself, and call your function that proceeds with the rest of payment using a string value like "tok_visa" directly. These test strings can be passed to the API to complete charges, so they can be used to mock the result of interacting with the Elements form.

[0] - https://stripe.com/docs/testing#cards "

Rademacher answered 11/7, 2019 at 10:24 Comment(0)
L
3

No, by design you cannot prefill payment information in Stripe Elements. If you could then that'd be a security risk.

Leighannleighland answered 26/6, 2019 at 1:5 Comment(1)
whats the point of on-session card saving then?Pleadings
G
1

Yep, Bookmarklets are a great way to fill out forms without you doing so. Bookmarklets are js (use can even use jQuery) stored as a bookmark, you click/tap it and it runs the js. In your case, you could create a bookmarklet to fill out the test stripe card info. Heres some links to help:

Gina answered 29/6, 2019 at 8:38 Comment(1)
Thanks. But if i am not able to switch to the iframe using JS code in galen, I wouldn't be able to do the same by executing the same JS code using bookmarklet.Rademacher

© 2022 - 2024 — McMap. All rights reserved.