#kacper-attach-pm-metadata

1 messages ยท Page 1 of 1 (latest)

regal bay
#

Hello ๐Ÿ‘‹
Don't think there's a way to pass the metadata to that event specifically.

full mist
#

ohh:/

regal bay
#

However that event delivers a PaymentMethod object

full mist
#

Hi:D

regal bay
full mist
#

data looks awesome:D

#

should be enough for me

#

๐Ÿ˜„

#

thank you!

regal bay
#

NP! ๐Ÿ™‚ Good luck

full mist
#

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

regal bay
#

can you share the guide you're using for this?

full mist
#

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)

regal bay
#

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

full mist
#

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*

regal bay
#

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?

full mist
#

yes

#

exactly

regal bay
full mist
#

ohhh this whould be much easier haha

#

thank you!!!

#

i think it will solve my problems;D

regal bay
#

NP! ๐Ÿ™‚ definitely would've saved you a lot of trouble if I had known that from the beginning LOL

#

all good though

full mist
#

probably haha but its fine ๐Ÿ˜„ have a nice day bye ๐Ÿ˜„

#

thanks one more time