The answer will depend on the type of Checkout Session you are working with.
If you are working with Checkout Sessions where mode:payment
, then you should expand payment_intent.payment_method
when you retrieve the Session. Then, you can check payment_intent.payment_method.card.last4
to get the last 4 digits.
If you are working with Checkout Sessions where mode:subscription
, then you should expand subscription.default_payment_method
when you retrieve the Session. Then, you can check subscription.default_payment_method.card.last4
.
If you're not already familiar with expansion, you can read more about it here (https://stripe.com/docs/expand).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…