#aayush

1 messages · Page 1 of 1 (latest)

spiral eagleBOT
ionic sable
#

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

waxen basin
#

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

ionic sable
#

for example you can udpate the subscription to use this pm pm_card_visa_chargeDeclined after the first successfull attempt

waxen basin
ionic sable
waxen basin
#

just a min

ionic sable
waxen basin
#

as im getting a response null in create checkout session object

#

for default payment

ionic sable
#

Can you share the requestId ?

waxen basin
#

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

ionic sable
#

It seems that you API client is formatting the string, it is pm_card_visa_chargeDeclined without spaces.

waxen basin
#

can i know if i can set a default payment methd while creating checkout session

#

and then update it to check failed payment response

ionic sable
#

You can set the default payment method when creating the subscription

waxen basin
#

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"}}

ionic sable
#

you are missing quotes default_payment_method: "pm_card_visa"

waxen basin
#

i did try that

#

{"error":{"message":"No such PaymentMethod: 'pm_card_visa'"}}

ionic sable
waxen basin
#

req_QkjwzXe6L7U4Qu

merry zealot
#

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.

waxen basin
#

so first i have to create that customer and add the test card?

merry zealot
#

Add the test card to the Customer, yes. You can add it when creating the Customer.