Shopify / mobile-buy-sdk-android

Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app. With a few lines of code, you can connect your app with the Shopify platform and let your users buy your products using their credit card.
MIT License
216 stars 136 forks source link

Not able to checkout status - Ready() status #628

Open gowtham-me opened 4 years ago

gowtham-me commented 4 years ago

We are trying to get checkout callback for WebCheckout. For that, we need Checkout status.

I am using the below code to get checkout statue - Ready() `Polling for checkout completion ⤴ After a successful checkoutCompleteWith... mutation, the checkout process starts. This process is usually short, but it isn't immediate. Because of this, polling is required to obtain an updated checkout in a ready state - with a Storefront.Order.

GraphClient client = ...;
ID paymentId = ...;

Storefront.QueryRootQuery query = Storefront.query(rootQuery -> rootQuery
    .node(paymentId, nodeQuery -> nodeQuery
        .onPayment(paymentQuery -> paymentQuery
        .checkout(checkoutQuery -> checkoutQuery
                    .ready()
            .order(orderQuery -> orderQuery
            .processedAt()
            .orderNumber()
            .totalPrice()))
        .errorMessage()
        .ready()
        )
    )
);

client.queryGraph(query).enqueue(
  new GraphCall.Callback<Storefront.QueryRoot>() {
    @Override public void onResponse(@NonNull GraphResponse<Storefront.QueryRoot> response) {

         Storefront.Payment payment = (Storefront.Payment) response.data().getNode();

         if (payment.getErrorMessage() == null || payment.getErrorMessage().isEmpty()){
        Storefront.Checkout checkout = payment.getCheckout();
        String orderId = checkout.getOrder().getId().toString();
                Boolean status = checkout.getReady();
         }
         else{
        String errorMessage = payment.getErrorMessage();
         }

    }
    @Override public void onFailure(@NonNull GraphError error) {
    }
  },
  null,
  RetryHandler.exponentialBackoff(500, TimeUnit.MILLISECONDS, 1.2f)
    .whenResponse(
      response -> ((Storefront.Payment) ((GraphResponse<Storefront.QueryRoot>) response).data().getNode()).getReady() == false
    )
    .maxCount(12)
    .build()
);

I am getting NULL as a response for checkout.

rushabh13 commented 4 years ago

Same issue heppening with me. Is there any solution available there?