#Sarvesh

1 messages · Page 1 of 1 (latest)

abstract kestrelBOT
modest obsidian
#

Hi there, how can I help?

gleaming mauve
#

In paymentIntent succeed webhook event for direct charges can we get more details about the user Card details for last 4 digits and which card type he used etc just to show on invoice?

#

or I need to register another webhook for charges.updated / succeed to receive that information?

#

can I add those events to paymentintent webhook itself?

gleaming mauve
#

?

modest obsidian
#

Sure, from the payment_intent.suceeded event, you can first retrieve the PaymentIntent's the PaymentMethod object, and from there you can get the last4 (https://stripe.com/docs/api/payment_methods/object#payment_method_object-card-last4) and brand (https://stripe.com/docs/api/payment_methods/object#payment_method_object-card-brand) of this card payment method.

gleaming mauve
#

ok so when I receive a paymentinterent webook response, then take the paymentintent id and do another GET call to GET
/v1/payment_methods/:id to receive payment method object?

modest obsidian
gleaming mauve
#

payment_menthod->card->brand

#

payment_menthod->card->last4 directly possible to get to need to do another GET request using payment_method ID?

modest obsidian
#

You need to do a GET request /v1/payment_methods/:id with the payment_method ID that you get form the payment_intent object to retrieve the payment_method object.

gleaming mauve
#

got it , thank you, I will try now

gleaming mauve
#

payment_intent ID : "pi_3MQ86FCYUydkTzYD0q9J3gCa",
payment_method ID: pm_1MQ87ECYUydkTzYDotYUEsRk

getting error with this code

$stripe = new StripeClient(config('services.stripe.stripeSecret'));
try{

                    $paymentMethodData = $stripe->paymentMethods->retrieve($paymentMethodId, []);
                    
                } catch(Exception $e) {

PM ERROR No such PaymentMethod: 'pm_1MQ87ECYUydkTzYDotYUEsRk'

#

while doing processing of paymentintent webhook response I am trying to retrive the payment_method details but it is not returning the payment_method object

modest obsidian
gleaming mauve
#

req_9StXJhVdZyWlb8

modest obsidian
#

You should specify a stripe_account in the request.

By specifying a stripe_account, you are telling Stripe that you want to make an API call on behalf of a connected account. You can refer to this doc to learn more about making API request for connected account (https://stripe.com/docs/connect/authentication)

Learn how to add the right information to your API calls so you can make calls for your connected accounts.

gleaming mauve
modest obsidian
#

This PaymentMethod was created in the connected account, so you need to specify stripe_account to make an API call on behalf of a connected account, like how you did when creating the PaymentIntent.

gleaming mauve
#

$paymentMethodData = $stripe->paymentMethods->retrieve($paymentMethodId, [], ['stripe_account' => 'acct_1MQ7WQCYUydkTzYD']);
with this request now it works and returned the payment_method object

#

if we store the payment_method object in our database then is it harmful/insecure anyway? We are not storing any user card details to our database but in this response last4 digits and card brand is mentioned

modest obsidian
#

I don't think the last4 digit and card brand are sensitive information if this is your concern.

gleaming mauve
#

ok