#Jayy

1 messages · Page 1 of 1 (latest)

hallow groveBOT
fathom falcon
green halo
#

that didn't actually work because of the flow i am using.
here's what i do:

const checkout = await stripe.checkout.sessions.create({
        mode: 'setup',
        success_url: `${process.env.NEXTAUTH_URL}/payment/processing?sessionId={CHECKOUT_SESSION_ID}`,
        cancel_url: `${process.env.NEXTAUTH_URL}/payment?canceled=true`,
        customer: session.stripeId,
        payment_method_types: ['card'],
      })

This would still work if the user added a card with not enough funds as the SETUP mode doesn't check for balance.

once the user is redirected to the success_url i create the subscriptions as follows:

const monthlySub = await stripe.subscriptions.create({
        customer: paymentMethod.user.stripeCustomerId!,
        items: monthly.map((m) => ({
          price: m.price,
          quantity: m.quantity,
        })),
        expand: ['latest_invoice.payment_intent'],
        collection_method: 'charge_automatically',
        default_payment_method: paymentMethodId,
      })

This will automatically charge the saved method the customer has.. i want to simulate a failed payment on that

fathom falcon
#

You need to create a PaymentMethod from the decline card (for example : 4000000000000002 using Stripe Elements) and then pass it when creating the subscription default_payment_method

green halo
#

isn't there a way from inside stripe dashboard to save the payment methods!?

#

cz i get this when i try

fathom falcon
green halo
#

alright i'll give it a try. also i'm getting this on my dashboard:

Some Dashboard features aren’t available right now due to unusually high activity from your account. Check with your team and try again later.
what could cause it ?

#

checking the logs there are barely any activities

fathom falcon
green halo
#

will do, thanks for the help!

quick void
green halo
#

i'm sorry but this is not working. here is what i'm trying:

const x = await stripe.paymentMethods.create({
        type: 'card',
        card: {
          exp_month: 12,
          exp_year: 2024,
          number: '4000000000000002',
          cvc: '314',
        },
      })
 const y = await stripe.paymentMethods.attach(x.id, {
        customer: session.stripeId!,
      })

which is just erroring that card is declined and i cannot attach it to customer.

i tried creating the subscription without attaching which also caused an error (paymentMethod not attached to customer)

quick void
#

could you please share the request id?

green halo
#

req_Igd3DyjIg6SYb0

quick void
#

where did you get that card number from?

green halo
#

i used this one: 4000 0000 0000 0002

#

which is the first one in the table

quick void
#

oh yes sorry I missed it

#

then this explains the decline

#

when we try to attach a PM to a customer we try to authenticate it

green halo
#

so how am i able to create a subscription and check if it errors ?

quick void
#

if you want to test a decline after attaching you should use the 4000000000000341 card insteaed

#

the message directly after that table states

The cards in the previous table can’t be attached to a Customer object. To simulate a declined payment with a successfully attached card, use the next one.

green halo
#

oh

#

and it's just a charge fail decline yes ?

#

which should be the one i need with my flow

quick void
#

yes

green halo
#

Alright thanks !

quick void
#

let me know if you need any more help