#heisend3rp
1 messages Β· Page 1 of 1 (latest)
Hi π
You could create the PM directly using the API and a tok_ value that corresponds with an expired card. Then test making a payment using that Payment Method ID
okay. thank you
Happy to help π
-d type=card \
-d "card[number]"=4242424242424242 \
-d "card[exp_month]"=10 \
-d "card[exp_year]"=2022 \
-d "card[cvc]"=314
{
"error": {
"code": "invalid_expiry_month",
"doc_url": "https://stripe.com/docs/error-codes/invalid-expiry-month",
"message": "Your card's expiration month is invalid.",
"param": "exp_month",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_i5LPj2FaYXb3CU?t=1671470901",
"type": "card_error"
}
}
doesn't work
π€·ββοΈ
That's not what I said to do
You want to create a Payment Method using the token parameter. We call this out here: https://stripe.com/docs/api/payment_methods/create?lang=node#create_payment_method-card
Wait NVM
The point here is to return this error for your testing
I would also like to have an expired card saved to my testing customer so I can check the ui works.
E.g. Disabling the select for this payment method or not showing it at all
You can save a valid card and then update it with an expiration date in the past
I tried:
curl https://api.stripe.com/v1/payment_methods/pm_1MGjnyJ7hRt0Zipdk6T6cjSL \
-u {{sk_test}}: \
-H 'Stripe-Account: {{connected_acct}}' \
-d "card[exp_year]"=2021
Got the following error:
{
"error": {
"code": "invalid_expiry_year",
"doc_url": "https://stripe.com/docs/error-codes/invalid-expiry-year",
"message": "Your card's expiration year is invalid.",
"param": "exp_year",
"request_log_url": "https://dashboard.stripe.com/acct_1Iabp9J7hRt0Zipd/test/logs/req_gcoCt1K4aKPv0M?t=1671472065",
"type": "card_error"
}
}
Okay no what you need to do is create the payment method using card[token]=tok_chargeDeclinedExpiredCard
This should allow you to create a payment method that will fail due to an expired card
curl https://api.stripe.com/v1/payment_methods/pm_1MGnYCJ7hRt0Zipdf36iUN8N/attach \
-u ***: \
-H 'Stripe-Account: ***' \
-d customer=cus_KUI154HhNt3jaz
{
"error": {
"code": "expired_card",
"doc_url": "https://stripe.com/docs/error-codes/expired-card",
"message": "Your card has expired.",
"param": "exp_month",
"request_log_url": "https://dashboard.stripe.com/acct_1Iabp9J7hRt0Zipd/test/logs/req_rM1oi915y4c20D?t=1671472537",
"type": "card_error"
}
}
I can indeed create it but I cannot attach it to a customer now
@onyx cairn so itβs not possible?
Well the attaching will trigger validation so no I don't think that's a specific scenario you can test.