#piyushjain - card details

1 messages ยท Page 1 of 1 (latest)

quasi starBOT
robust orbit
#

HI ๐Ÿ‘‹

What kind of card info are you trying to get?

loud basin
#

want to retrieve last 4 digit and card type

robust orbit
#

And what API are you calling?

loud basin
#

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

robust orbit
#

piyushjain - card details

loud basin
#

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

fresh marten
#

can you paste what's the response for paymentIntent1?

loud basin
#

yeah sure

fresh marten
#

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?

loud basin
#

i know but dont you think this is too nested. cant we get card details by paymentMethod Id?

fresh marten
#

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?

loud basin
#

<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"
}

fresh marten
#

you should probably be passing in the id i.e. pm_1MTfUGGbi6ZzBBnzif31kV24

#

not the entire result of paymentIntent1.getPaymentMethod()

loud basin
#

oh

#

wait i am sending

#

pm_1MTfUGGbi6ZzBBnzif31kV24

#

this is just the response

#

of paymentIntent1.getPaymentMethod()

#

anyway for now i will get card details from payment intent only