#sankalpchari-payment-methods

1 messages · Page 1 of 1 (latest)

lusty lindenBOT
thorn plume
#

HI 👋

You can inspect the Payment Method associated with the Invoice payment

#

Where are you getting the data?

#

Webhooks, API responses, etc

west sierra
#

i have a site and i need to show which card was used for paymnet , im using php

im getting the card details if its set for subscription in default paymnet method or if its set default for customer

thorn plume
#

Okay so you can inspect the latest invoice on a subscription

west sierra
#

this is the code i have implemnetd

thorn plume
#
  1. That's a screenshot
  2. You should be able to describe this without sharing your code.
west sierra
#
  1. im checking default_paymnet_method on subscription and getting card from there
  2. if not set then im getting the default card set for customer

issues is if the default payment method is not set and default card is not set on customer

how to fetch the card details

thorn plume
#

If you retrieve the latest paid invoice for the Subscription, that will include the payment intent and payment method information

west sierra
#

ok im checking

#

which property will be set

thorn plume
#

I'm not sure I know what you are talking about

west sierra
#

on which property in invoice object will i get the paymnet information

thorn plume
#

For the subscription you can retreive the latest invoice using the latest_invoice property on the Subscription. The invoice will include the ID of a payment intent in the payment_intent property. That Payment Intent, if it has been paid, will include a latest_charge. That Charge object will have the payment_method_details that include the data on the payment method used to pay that Charge

west sierra
#

ok thanks

thorn plume
#
$stripe->invoices->retrieve(
  'in_xxxxxx',
  ['expand' => ['payment_intent.latest_charge']]
);

for example

#

sankalpchari-payment-methods

west sierra
#

its working

#

thanks