2013-10-08 14 views
6

Non vedo questo particolare errore descritto nelle strisce API ovunque. Qualcuno sa cosa sta succedendo?Perché Stripe.com restituisce un errore (402) È richiesto il pagamento?

Ecco il mio codice VB.net per creare un cliente:

Function CreateStripeCustomer(ByVal Token As String) As String 
    '' The Stripe Account API Token - change this for testing 
    Dim STR_Stripe_API_Token As String = "sk_test_SECRET_TEST_KEY" '<-- test secret key. Change to live later. 
    ''The Stripe API URL 
    Dim STR_Stripe_API_URL As String = "https://api.stripe.com/v1/customers" 
    ''Creates a Web Client 
    Dim OBJ_Webclient As New System.Net.WebClient() 
    ''Creates Credentials 
    Dim OBJ_Credentials As New System.Net.NetworkCredential(STR_Stripe_API_Token, "MY_STRIPE.COM_PASSWORD") 
    ''Sets the Credentials on the Web Client 
    OBJ_Webclient.Credentials = OBJ_Credentials 
    ''Creates a Transaction with Data that Will be Sent to Stripe 
    Dim OBJ_Transaction As New System.Collections.Specialized.NameValueCollection() 
    OBJ_Transaction.Add("email", "PERFECTLY_VALID_EMAIL") 
    OBJ_Transaction.Add("card", "PERFECTLY VALID TOKEN RETURNED BY STRIPE.JS") 
    ''The Stripe Response String 
    Dim STR_Response As String = Encoding.ASCII.GetString(OBJ_Webclient.UploadValues(STR_Stripe_API_URL, OBJ_Transaction)) 
    Return STR_Response 
End Function 

La 402 "pagamento richiesto" l'errore sta accadendo sulla linea:

Dim STR_Response As String = Encoding.ASCII.GetString(OBJ_Webclient.UploadValues(STR_Stripe_API_URL, OBJ_Transaction)) 

risposta

5

Beh, sono passato al mio " LIVE "invece dei tasti" TEST ", e questo lo ha risolto. Ho appena perso 3 ore della mia vita cercando di risolvere questo problema. Spero che questo aiuti qualcun altro.

+1

È spiacevole che formattare le risposte in modo diverso in ambienti diversi ... Non è il punto di essere in grado di testare senza differenze? Oh bene – Jerad

5

La risposta più corretta è che è necessario utilizzare i numeri di scheda di prova appropriati. Vedere https://stripe.com/docs/testing

+0

Dopo ulteriori test, questa risposta avrà un messaggio di errore (come un numero di carta non valido) che è possibile visualizzare. –

+1

Il passaggio all'utilizzo di una carta di prova ha corretto questo errore per me. Non è possibile testare con numeri di carte reali. – user3344977

8

Se state vedendo questo in vivo, è anche possibile il numero della carta è semplicemente errata, ad esempio: se si ispezionare il corpo della risposta 402:

enter image description here

1

banda fornisce un ambiente di test in cui si usano le chiavi pubblicabili/segrete test, in opposizione all'aspettare fino alla produzione. Tuttavia, ciò che sembra il lato negativo, che è di fatto molto utile, è che è necessario conformarsi alle condizioni di prova di Stripe e utilizzare i numeri e gli ingressi delle schede dati per testare diversi aspetti della propria chiamata api.

Per esempio, al fine di ricevere alcuni errori che è possibile introdurre questi numeri:

card_declined: Use this special card number - 4000000000000002. 
incorrect_number: Use a number that fails the Luhn check, e.g. 4242424242424241. 
invalid_expiry_month: Use an invalid month e.g. 13. 
invalid_expiry_year: Use a year in the past e.g. 1970. 
invalid_cvc: Use a two digit number e.g. 99. 

Per ulteriori informazioni fare riferimento al link che Samir postato.

Problemi correlati