#sathishandroid_12146

1 messages · Page 1 of 1 (latest)

silk sailBOT
grand oyster
#

What do you mean by 'it takes time'?

calm breach
#

Response Time to get the Paynow QRcode URL

grand oyster
#

Can you share an example API request that you're making that returns/displays the QR code?

calm breach
#

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();
}
grand oyster
#

Can you share the req_xxx ID of one of those requests? Or the pi_xxx?

calm breach
#

you mean Stripe live API key ?

grand oyster
calm breach
#

req_AoT2CJPY0FJN7N

grand oyster
#

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?

calm breach
#

Qrcode is Rendering in POS customer screen with WebView after getting the QRCode URL.

grand oyster
#

Right, but that's sounds like an issue specific to your integration as opposed to an API request

#

End-to-end response time for that was also reasonable, ~0.8 seconds

calm breach
#

It may be problem to show the QRCode in second Screen

grand oyster
#

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?

calm breach
#

It takes 5 to 10 seconds..

grand oyster
#

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

calm breach
#

Another API call is Getting the Status of the payment, every one-second calling to get the Status of payment.

grand oyster
#

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

#

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

grand oyster
calm breach
#

Will check my integration to get the status API calling .. every one second..

grand oyster
#

Yeah, but why? Why do you need to check the status of the payment? That's not recommended and generally redundant in most inbtegrations

calm breach
#

Need "completed" status to save the Cart items to our server..

grand oyster
calm breach
#

How to Use this One?, after payment intent calling, can you send the example?

grand oyster
#

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

calm breach
#

String payload = request.body(); in here payload is payment Intent to get QRCode URL?

grand oyster
#

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

calm breach
#

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();
}
calm breach
#

if paymentStatus "completed" means will save our cart items

grand oyster
#

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

calm breach
#

Yes, Understand this, How to implement or call webhook method?

grand oyster
#

You'd need to configure a webhook on your account as explained at the URL I shared

silk sailBOT
calm breach
balmy moss
#

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.

calm breach
#

Handle the events means, what ? any example

calm breach
balmy moss
calm breach
#

Okay will check and Thanks for your guidance.