#.sashank

1 messages · Page 1 of 1 (latest)

supple starBOT
hasty jacinth
#

hi there!

#

how can I help?

burnt talon
#

hi we are currently facing an issue
we are sending the metadata in json format to stripe.checkout.session.create
but when we configured a webhook to check for payment failures, in the payment_intent.payment_failed event, we are not getting the metadata which we passed while creating session

#

we want to get the failure reason and update it in the db with the metadata information that contains customer information

hasty jacinth
#

that's normal, you set the metadata on the Checkout Session itself, not on the PaymentIntent.

burnt talon
#

oh ok we will try to add in this and see if it works
thank you so much for the quick response

hasty jacinth
#

happy to help 🙂

burnt talon
#

hi we added payment_intent_data, but in response we didn't get this back

const session = await stripe.checkout.sessions.create({
payment_method_types: ['card'],
metadata:{"servicer_id":servicer_id,"job_id":job_id,"customer_id":customer_id,},
payment_intent_data:{metadata:{"servicer_id":servicer_id,"job_id":job_id,"customer_id":customer_id}},
line_items: [{
price_data: {
currency: 'usd',
product_data: {
name: job_name,
},
unit_amount: total_amount,
},
quantity: 1,
}],
mode: 'payment',
success_url: 'https://yourwebsite.com/success',
cancel_url: 'https://yourwebsite.com/cancel',
// shipping_address_collection: {
// allowed_countries: ['IN'], // Allow shipping addresses from any country
// },
});

hasty jacinth
#

but in response we didn't get this back
which response?

burnt talon
#

response from stripe

hasty jacinth
#

now the metadata is stored on the PaymentIntent, so it won't be visible on the Checkout Session. These are separate objects!

burnt talon
#

oh ok

hasty jacinth
#

wait you did this:

  metadata:{"servicer_id":servicer_id,"job_id":job_id,"customer_id":customer_id,},
  payment_intent_data:{metadata:{"servicer_id":servicer_id,"job_id":job_id,"customer_id":customer_id}},

so you should see the metadata on both the Checkout Session and the Payment Intent

#

where exactly don't you see the metadata?

burnt talon
#

payment_intent_data is not showing up in the checkout session

#

just metadata is shown

hasty jacinth
#

That's normal:

  • On the Checkout Session object you'll see the metadata you set.
  • On the PaymentIntent object you'll see the payment_intent_data.metadata you set
burnt talon
#

ok got it , we will check that in payment_intent.payment_failed

#

we got the metadata on PaymentIntent now, we made payment using a card which has insufficient funds, but we are not able to get the error message from webhook response, saying the card has insufficient funds, we got the insufficient funds message from the bank as sms on mobile, how can we get this using the webhooks?

hasty jacinth
#

which webhook endpoint are you listening to?

#

can you share the Event ID (evt_xxx)?

burnt talon
#

payment_intent.payment_failed

burnt talon
#

evt_3OfKjYJhm3jmN1nN1x7Sk119

hasty jacinth
#

there you can see the message retruned by the bank

#

also... are you doing tests in live mode!?

Don’t use real card details. The Stripe Services Agreement prohibits testing in live mode using real payment method details. Use your test API keys and the card numbers below.
https://stripe.com/docs/testing

burnt talon
#

yes to check failed transactions in real world scenario

hasty jacinth
#

you are not allowed to do this.

#

test cards should be enough for this.

burnt talon
#

but in test cards we can't check insufficient funds right, so we did with a real card

#

we got this but we didn't get the message like , failed due to insufficient funds anywhere
"last_payment_error": {
"charge": "ch_3Of2BxJhm3jmN1nN0Y28xmmz", "code": "card_declined",
"decline_code": "transaction_not_allowed", "doc_url": "https://stripe.com/docs/error-codes/card-declined",
"message": "Your card does not support this type of purchase.",

}

hasty jacinth
#

we got this but we didn't get the message like , failed due to insufficient funds anywhere
you get the message that the bank sent, which is not always consistent with the real reason.

burnt talon
#

oh ok got it thanks

#

Use test cards to validate your Stripe integration without moving real money. Test a variety of international scenarios, including successful and declined payments, card errors, disputes, and bank authentication. You can also test non-card payment methods and redirects.

#

so we are checking in test mode now

hasty jacinth
#

yes that's a good idea

burnt talon
#

also is there a way to get session id inside this webhook event payment_intent.payment_failed ?

hasty jacinth
supple starBOT