#aayush
1 messages · Page 1 of 1 (latest)
No you can't specify payment when creating a Checkout Session.
Could you explain a bit what you are trying to achieve? so that I may suggest you another alternative
i want to basically update the payment method for a user and set as failed card so that i can test recurring payment and basically get reponse for recurring failed payment
user set to recurring payment -> 1st time succesfully paid then update his payment methods to failed card then when 2nd recurring date is coming i want to catch response for failed payment
I think one option could be using one of these decline token:
https://stripe.com/docs/testing?testing-method=payment-methods#declined-payments
for example you can udpate the subscription to use this pm pm_card_visa_chargeDeclined after the first successfull attempt
yes but how do i do that? when i try doing it it gives a error
Can you share the ID (req_xxx) of the failing API request?
https://support.stripe.com/questions/finding-the-id-for-an-api-request
just a min
You can make this API update:
https://stripe.com/docs/api/subscriptions/update#update_subscription-default_payment_method
ive tried this but it says no previous default payment is found
as im getting a response null in create checkout session object
for default payment
Can you share the requestId ?
yes
i cant find the exact req id but it was this error message:
stripeinvalidrequesterror: no such payment method: 'pm_card_visa charge declined'
when i try to update subscription
It seems that you API client is formatting the string, it is pm_card_visa_chargeDeclined without spaces.
can i know if i can set a default payment methd while creating checkout session
and then update it to check failed payment response
I told you no, you can't.
You can set the default payment method when creating the subscription
so i do this
const session = await stripe.subscriptions.create({
customer: customer.id,
items: [{ price: "price_1NXgO" }],
default_payment_method: pm_card_visa,
});
created a subscription api
but it gives this error {"error":{"message":"pm_card_visa is not defined"}}
you are missing quotes default_payment_method: "pm_card_visa"
Can you share the ID (req_xxx) of the failing API request?
https://support.stripe.com/questions/finding-the-id-for-an-api-request
req_QkjwzXe6L7U4Qu
Hi! I'm taking over from my colleague. Please, give me a moment to catch up.
You can't use these test cards on the Subscription. You have to add them to the Customer first.
so first i have to create that customer and add the test card?
Add the test card to the Customer, yes. You can add it when creating the Customer.