#kacper-attach-pm-metadata
1 messages ยท Page 1 of 1 (latest)
ohh:/
However that event delivers a PaymentMethod object
Hi:D
You can set the PaymentMethod metadata by setting payment_method_data.metadata while creating the PaymentIntent
https://stripe.com/docs/api/payment_intents/create#create_payment_intent-payment_method_data-metadata
NP! ๐ Good luck
hmm but its probably available on if I want to add PaymentMethod while creating PaymentIntent
my problem refers to saving card by customer using "save card for future payments" in payment sheet
this action invokes payment_method.created event
can you share the guide you're using for this?
Sure
this is app flow
-> customer click checkout button in my mobile app
-> app send request to server to create PaymentIntent with this parameter:
enabled: true,
},
-> server send PaymentIntent keys to app
-> app receivs keys and call presentPaymentSheet method
-> stripe payment sheet opens and customer can add credit card details, then clicks checkbox with text: "save this card for future payments"
-> server listens to stripe events via webhook
-> server receives event payment_method.attached - this is the moment when I want to save my card to database but I need info about my tenant id passed via metadata to check if tenant is in testmode
-> server receives event payment_intent.succeeded - i have all necessary info in this event like PaymentMethod id or metadata but I will get this event with every successfull transaction so i have to check if this PaymentMethod was saved oporevioslu (quite annoying solution but should work)
I don't think you need to pass in an existing payment method while creating the PaymentIntent in order to set payment_method_data.metadata
have you tried it and saw it behave differently or throw an error?
ah I see, you're using automatic_payment_methods but using payment_method_data would require you to pass in a type before hand
yeah it throws an error;/
amount,
currency: 'aud',
customer: stripeCustomer.id,
automatic_payment_methods: {
enabled: true,
},
metadata: {
secondaryId: transaction,
tenantId: tenant._id.toString(),
},
transfer_data: {
destination: accountId,
},
payment_method_data: {
metadata: {
tenantId: tenant._id.toString(),
},
},
});
if I do it this wat
this way*
I need info about my tenant id passed via metadata to check if tenant is in testmode
can you expand a little bit more on this? Are you only trying to figure out if the request was in test mode or live mode?
each webhook event has a boolean property called livemode that you can check to see if the object that was delivered was in livemode or test mode
https://stripe.com/docs/api/events/object#event_object-livemode
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ohhh this whould be much easier haha
thank you!!!
i think it will solve my problems;D