Why is Stripe.com return error (402) Payment required?

I do not see this specific error described in any API. Does anyone know what is going on?

Here is my VB.net client creation code:

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 

Error 402 "payment required" occurs on the line:

 Dim STR_Response As String = Encoding.ASCII.GetString(OBJ_Webclient.UploadValues(STR_Stripe_API_URL, OBJ_Transaction)) 
+6
source share
4 answers

If you see this live, it’s also possible the card number is simply incorrect , for example: if you check the body of 402 answer:

enter image description here

+8
source

Well, I switched to my β€œLIVE” keys instead of my β€œTEST” keys, and this fixed it. Just wasted 3 hours of my life trying to fix it. Hope this helps someone else.

+5
source

The more correct answer is that you need to use the appropriate test card numbers. See https://stripe.com/docs/testing

+5
source

Stripe provides a test environment in which you use publicly available / private keys as they counter production expectations. However, what looks like the downside, which is actually very useful, is that you need to adhere to the Stripe testing conditions and use their data and card numbers to verify various aspects of your api call.

For example, to get certain errors, you can enter these numbers:

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

For more information, refer to the link posted by Samir.

+1
source

Source: https://habr.com/ru/post/955467/


All Articles