Hi All
I have Stripe Payments for a Customer working with the code listed below.
This is all good, I created the Payment method for this customer in the Stripe dashboard.
However I need to associate and create a payment method with the customer via my own UI in B4A. From reading the documentation https://stripe.com/docs/api/cards/create you can simply create a card with a request like so [using cUrl format]
The problem is how to obtain the token, the documentation states "A token, like the ones returned by Stripe.js. Stripe will automatically validate the card. "
So in B4A what is the best way to use Stripe.js and have it return a card token? I am thinking a webview but unsure if its just a matter of creating some local HTML file adding reference to stripe.js and hooking into events from webview in B4A to capture when the token is created?
Any advice on this please?
Thanks
I have Stripe Payments for a Customer working with the code listed below.
This is all good, I created the Payment method for this customer in the Stripe dashboard.
However I need to associate and create a payment method with the customer via my own UI in B4A. From reading the documentation https://stripe.com/docs/api/cards/create you can simply create a card with a request like so [using cUrl format]
B4X:
job1.PostString("https://api.stripe.com/v1/customers/cus_HsGfXvel9JmnxK/sources","source=tok_visa")
job1.GetRequest.SetHeader("Authorization","Bearer sk_test_...")
The problem is how to obtain the token, the documentation states "A token, like the ones returned by Stripe.js. Stripe will automatically validate the card. "
So in B4A what is the best way to use Stripe.js and have it return a card token? I am thinking a webview but unsure if its just a matter of creating some local HTML file adding reference to stripe.js and hooking into events from webview in B4A to capture when the token is created?
Any advice on this please?
Thanks
B4X:
Dim job1 As HttpJob
job1.Initialize("JobStripe",Me)
job1.PostString("https://api.stripe.com/v1/payment_intents","amount=600¤cy=eur&customer=cus_Hs2dmIB3Ytxqjz&confirm=true")
job1.GetRequest.SetHeader("Authorization","Bearer sk_test_...")
Wait For (job1) JobDone(j As HttpJob)
If j.Success Then
Log(j.GetString.Length)
Dim parser As JSONParser
parser.Initialize(j.GetString)
Dim RootObject As Map = parser.NextObject
Dim charges As Map = RootObject.Get("charges")
Dim data As List = charges.Get("data")
For Each coldata As Map In data
Dim receipt_url As String = coldata.Get("receipt_url")
WebView1.LoadUrl(receipt_url)
WebView1.Visible = True
WebView1.BringToFront
Button1.Visible = False
Exit
Next
End If
j.Release