Italian integrare Stripe per pagamenti carta di credito

marcick

Well-Known Member
Licensed User
Longtime User
Ciao a tutti,
qualcuno si è cimentato con successo ? https://stripe.com/it
Vorrei integrarlo in una app B4I e B4A ma le mie conoscenze sono abbastanza limitate, già se si parla di librerie, api, vado in tilt.
Forse la soluzione facilmente adattabile a entrambe le piattaforme è quella tramite post HTTP ma non so come fare https://stripe.com/docs/quickstart
Qualche dritta ?
 

cirollo

Active Member
Licensed User
Longtime User
Ciao! io ho integrato Stripe in una webapp ed ora sto cercando di farlo in B4A e B4I ma non riesco a tradurre la chiamata CURL in B4A, tu poi sei riuscito?
 

marcick

Well-Known Member
Licensed User
Longtime User
Ciao, no, non ho più approfondito, anche se è una cosa che vorrei riuscire a fare
 

Star-Dust

Expert
Licensed User
Longtime User

sirjo66

Well-Known Member
Licensed User
Longtime User
avete un comando CURL con dati di esempio che possiamo provare ??
 

sirjo66

Well-Known Member
Licensed User
Longtime User
il "CURL -u" serve per l'autenticazione, e qui (purtroppo) non vi posso essere di aiuto, bisognerebbe chiedere ad Erel, però da quel che ho capito c'era anche la possibilità di farlo tramite POST su HTTP, esiste da qualche parte un esempio funzionante ??
 

LucaMs

Expert
Licensed User
Longtime User
Per me è arabo; al massimo arrivo a conoscere vagamente il CURLing:

ijfn01baoc718yyotfsf.jpg


:p
 

cirollo

Active Member
Licensed User
Longtime User
ragazzi, io sono quasi riuscito a farlo, ho adesso un problema nel leggere il json di ritorno da stripe....questo è quello che ricevo

B4X:
{
  "id": "tok_1DePTxENBiByw1eYkUZaGFpj",
  "object": "token",
  "card": {
    "id": "card_1DePTxENBiByw1eYstyEqGfG",
    "object": "card",
    "address_city": null,
    "address_country": null,
    "address_line1": null,
    "address_line1_check": null,
    "address_line2": null,
    "address_state": null,
    "address_zip": null,
    "address_zip_check": null,
    "brand": "Visa",
    "country": "US",
    "cvc_check": "unchecked",
    "dynamic_last4": null,
    "exp_month": 12,
    "exp_year": 2020,
    "fingerprint": "XauSvjvOfRW1kGeS",
    "funding": "credit",
    "last4": "4242",
    "metadata": {
    },
    "name": null,
    "tokenization_method": null
  },
  "client_ip": "151.84.255.212",
  "created": 1544112825,
  "livemode": false,
  "type": "card",
  "used": false
}

se lo copio/incollo in un JSON validator mi dice che è tutto ok, ma con queste istruzioni (con cui leggo gli altri JSON)

B4X:
' ------------------------------------------- STRIPE TOKEN   
       If Job.JobName="StripeToken" Then
           Log("StripeToken")
           Dim root As List = parser.NextArray
           
           For Each colroot As Map In root
               StripeToken = colroot.Get("id")
           Next
           Log(StripeToken)
       End If

ottengo questo errore:

B4X:
Error occurred on line: 281 (Studenti)
java.lang.RuntimeException: JSON Array expected.
   at anywheresoftware.b4a.objects.collections.JSONParser.NextArray(JSONParser.java:62)
   at ncs.fivestars_school_genitori.studenti._jobdone(studenti.java:1839)
   at java.lang.reflect.Method.invoke(Native Method)
   at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:733)
   at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:355)
   at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
   at java.lang.reflect.Method.invoke(Native Method)
   at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
   at anywheresoftware.b4a.BA$2.run(BA.java:365)
   at android.os.Handler.handleCallback(Handler.java:808)
   at android.os.Handler.dispatchMessage(Handler.java:101)
   at android.os.Looper.loop(Looper.java:166)
   at android.app.ActivityThread.main(ActivityThread.java:7425)
   at java.lang.reflect.Method.invoke(Native Method)
   at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
 

udg

Expert
Licensed User
Longtime User
Prova con questo codice (parsing del tuo JSON):
B4X:
Dim parser As JSONParser
parser.Initialize(<text>)
Dim root As Map = parser.NextObject
Dim livemode As String = root.Get("livemode")
Dim created As Int = root.Get("created")
Dim client_ip As String = root.Get("client_ip")
Dim id As String = root.Get("id")
Dim used As String = root.Get("used")
Dim type As String = root.Get("type")
Dim card As Map = root.Get("card")
Dim address_zip_check As String = card.Get("address_zip_check")
Dim country As String = card.Get("country")
Dim last4 As String = card.Get("last4")
Dim funding As String = card.Get("funding")
Dim metadata As Map = card.Get("metadata")
Dim address_country As String = card.Get("address_country")
Dim address_state As String = card.Get("address_state")
Dim exp_month As Int = card.Get("exp_month")
Dim exp_year As Int = card.Get("exp_year")
Dim address_city As String = card.Get("address_city")
Dim tokenization_method As String = card.Get("tokenization_method")
Dim cvc_check As String = card.Get("cvc_check")
Dim address_line2 As String = card.Get("address_line2")
Dim address_line1 As String = card.Get("address_line1")
Dim fingerprint As String = card.Get("fingerprint")
Dim name As String = card.Get("name")
Dim id As String = card.Get("id")
Dim address_line1_check As String = card.Get("address_line1_check")
Dim address_zip As String = card.Get("address_zip")
Dim dynamic_last4 As String = card.Get("dynamic_last4")
Dim brand As String = card.Get("brand")
Dim object As String = card.Get("object")
Dim object As String = root.Get("object")

Come caso generale, ti basta fare il copia&incolla di un JSON nel tool on-line predisposto da Erel per avere il codice corrispondente:
http://basic4ppc.com:51042/json/index.html
 

sirjo66

Well-Known Member
Licensed User
Longtime User
nel linguaggio json se c'è una parentesi graffa vuol dire che è un oggetto, se c'è una parentesi quadra è una lista

come vedi il tuo json inizia con una graffa, per cui il primo passo da fare era un nextObject e non un nextArray come hai fatto tu

il messaggio di errore infatti ti diceva che stava aspettando un array ed invece si è trovato un oggetto
 

cirollo

Active Member
Licensed User
Longtime User
alla fine ho risolto mettendo il json nel jsontree utility ed utilizzando il codice che mi proponeva
 

sirjo66

Well-Known Member
Licensed User
Longtime User
attento però che il codice ha un errore, non so se l'hai visto
 
Top