#piyushjain - card details
1 messages ยท Page 1 of 1 (latest)
HI ๐
What kind of card info are you trying to get?
want to retrieve last 4 digit and card type
And what API are you calling?
RequestOptions requestOptions = RequestOptions.builder().setApiKey(STRIPE_SECRET_KEY)
.setStripeAccount(accountId).build();
try {
PaymentIntent paymentIntent1 = PaymentIntent.retrieve(paymentIntent, requestOptions);
PaymentMethod paymentMethod = PaymentMethod.retrieve(paymentIntent1.getPaymentMethod(), requestOptions);
System.out.println(paymentMethod.getCardPresent().getRawJsonObject());
} catch (StripeException e) {
throw new CustomException(e.getMessage());
}
by payment intent i am getting payment method id
piyushjain - card details
then by payment method id i am trying to get card info
but card info always returning null object
PaymentIntent paymentIntent1 = PaymentIntent.retrieve(paymentIntent, requestOptions);
PaymentMethod paymentMethod = PaymentMethod.retrieve(paymentIntent1.getPaymentMethod(), requestOptions);
these 2 Apis
can you paste what's the response for paymentIntent1?
you already have the details you need in the response itself, is there a reason why you're making another call to retrieve the PaymentMethod?
i know but dont you think this is too nested. cant we get card details by paymentMethod Id?
you can get card details by paymentMethod Id if you want to. However, why make unnecessary requests when you don't need to? That's an additional round trip - it takes a little while for the server to make a request and get a response. As your load grows bigger also, you would need to be careful not to hit rate limits.
anyway, what does paymentIntent1.getPaymentMethod() return?
<com.stripe.model.PaymentMethod@743371005 id=pm_1MTfUGGbi6ZzBBnzif31kV24> JSON: {
"acss_debit": null,
"afterpay_clearpay": null,
"alipay": null,
"au_becs_debit": null,
"bacs_debit": null,
"bancontact": null,
"billing_details": {
"address": {
"city": null,
"country": null,
"line1": null,
"line2": null,
"postal_code": null,
"state": null
},
"email": null,
"name": null,
"phone": null
},
"card": null,
"card_present": {},
"created": 1674539764,
"customer": null,
"eps": null,
"fpx": null,
"giropay": null,
"grabpay": null,
"id": "pm_1MTfUGGbi6ZzBBnzif31kV24",
"ideal": null,
"interac_present": null,
"livemode": false,
"metadata": {},
"object": "payment_method",
"oxxo": null,
"p24": null,
"sepa_debit": null,
"sofort": null,
"type": "card_present"
}