#sathishandroid_12146
1 messages · Page 1 of 1 (latest)
What do you mean by 'it takes time'?
Response Time to get the Paynow QRcode URL
Can you share an example API request that you're making that returns/displays the QR code?
public void createPaymentIntent(int amount) throws StripeException {
Thread thread = new Thread(() -> {
try {
Stripe.apiKey = Constants.Companion.getSTRIPE_API_KEY();
Map<String, Object> automaticPaymentMethods = new HashMap<>();
automaticPaymentMethods.put("enabled", true);
String[] payments=new String[] {"paynow"};
Map<String, Object> paymentData = new HashMap<>();
paymentData.put("type", "paynow");
Log.w("PaymentAmount:",amount+"");
Map<String, Object> params = new HashMap<>();
params.put("amount", amount);
params.put("currency", "SGD");
params.put("payment_method_types", payments);
params.put("payment_method_data",paymentData);
PaymentIntent paymentIntent = PaymentIntent.create(params);
Log.w("PaymentIntent:Print-->",paymentIntent.toJson());
confirmPaymentIntent(new JSONObject(paymentIntent.toJson()));
} catch (Exception e) {
e.printStackTrace();
}
});
thread.start();
}
Can you share the req_xxx ID of one of those requests? Or the pi_xxx?
you mean Stripe live API key ?
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
req_AoT2CJPY0FJN7N
End-to-end response time for that specific API request was ~0.3 seconds which seems perfectly reasonable for this kind of request
At what point in your integration do you confirm the PI to render the QR code?
Qrcode is Rendering in POS customer screen with WebView after getting the QRCode URL.
Right, but that's sounds like an issue specific to your integration as opposed to an API request
For example, this is the confirmation request that returns the QR code: https://dashboard.stripe.com/logs/req_iQybuszrcXe6LK
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
End-to-end response time for that was also reasonable, ~0.8 seconds
It may be problem to show the QRCode in second Screen
Without knowing the specific details of your integration it's hard to make any recommendations. What are the exact concerns you have with rendering the QR code? You say its 'slow' – how long does it take exactly?
It takes 5 to 10 seconds..
Do you make other API calls/have logic that is potentially blocking the rendering of the QR code?
Going to quickly try a PayNow integration to see what kind of rendering delay I see
Another API call is Getting the Status of the payment, every one-second calling to get the Status of payment.
Looks like you're confirming server-side. What do you do with that response that includes the QR code?
The recommendation is to confirm client-side with Stripe.js which automatically renders the QR code. I jsut tried that and it was ~instant
I would guess that whatever method you're using to render the QR code returned in your confirmation call (https://dashboard.stripe.com/logs/req_iQybuszrcXe6LK), is the actual issue here
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
As I noted that request responded within ~0.8 seconds. As you're not using confirmPayment, you're handling displaying the QR code manually so your logic in your integration is likely responsible for that additional delay
Out of interest, why are you polling the API like this?
Will check my integration to get the status API calling .. every one second..
Yeah, but why? Why do you need to check the status of the payment? That's not recommended and generally redundant in most inbtegrations
Need "completed" status to save the Cart items to our server..
You should do that asynchronously with a webhook: https://stripe.com/docs/payments/handling-payment-events
How to Use this One?, after payment intent calling, can you send the example?
The doc above explains the general idea. You'd setup a POST endpoint in your server that can accept events that are sent from your account for payments, in there you can handle cusotm logic like saving cart items, etc
String payload = request.body(); in here payload is payment Intent to get QRCode URL?
Not exactly. You'd use this webhook to receive async updates about payments occuring on your account. For example, a payment_intent.succeeded event will fire when a customer completes a payment. In that payload will be the Payment Intent object, and status: 'succeeded'
That's a replacement for your polling implementation
Replace of this one public void retrievePaymentIntent(String intent){
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
PaymentIntent paymentIntent = PaymentIntent.retrieve(intent);
System.out.println(paymentIntent.getLastResponse().requestId());
Log.w("StatusPrint:Print-->",paymentIntent.toJson());
JSONObject jsonObject=new JSONObject(paymentIntent.toJson());
paymentStatus=jsonObject.optString("status");
} catch (Exception e) {
e.printStackTrace();
}
}
});
thread.start();
}
This API i am using to get status every one second
if paymentStatus "completed" means will save our cart items
Yes, the webhook would replace your polling mechanism that checks the status of the payment. You can then move your cart/database logic into the webhhook logic to handle payment_intent.succeeded events
Yes, Understand this, How to implement or call webhook method?
You'd need to configure a webhook on your account as explained at the URL I shared
Okay after configuring the Webhook, i just need implement handle method in require activity to get the status.? is it okay?
Hi! I'm taking over this thread.
You configure a webhook endpoint, write some code to handle the events, and then trigger some test events to make sure eveything is working.
Handle the events means, what ? any example
After configuration, is it working like override method?
We have this guide showing how to handle webhook events: https://stripe.com/docs/webhooks/quickstart
Okay will check and Thanks for your guidance.