Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Stripe.com return error (402) Payment Required?

I'm not seeing this particular error described in stripes API anywhere. Anyone know what's going on?

Here is my VB.net code to create a customer:

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

The 402 "payment required" error is happening on the line:

Dim STR_Response As String = Encoding.ASCII.GetString(OBJ_Webclient.UploadValues(STR_Stripe_API_URL, OBJ_Transaction))
like image 271
Aaron Brown Avatar asked Oct 08 '13 04:10

Aaron Brown


1 Answers

Well, I switched to my "LIVE" keys instead of my "TEST" keys, and that fixed it. Just wasted 3 hours of my life trying to fix this. Hope this helps somebody else.

like image 58
Aaron Brown Avatar answered Sep 16 '22 13:09

Aaron Brown