I am doing WebCheckout. After that, I am getting a callback of that Checkout callback.
I have followed the way which has been written here.
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()
)
)
);
======================================================================
I am facing the following issues:
ID paymentId = ...;
It shouldn't be paymentId, It is checkoutId while will be received in response of this request.
Storefront.QueryRootQuery query = Storefront.query(rootQuery -> rootQuery
.node(paymentId, nodeQuery -> nodeQuery
.onPayment(paymentQuery -> paymentQuery
.checkout(checkoutQuery -> checkoutQuery
.order(orderQuery -> orderQuery
.processedAt()
.orderNumber()
.totalPrice()))
.errorMessage()
.ready()
)
)
);
.onPayment(paymentQuery -> paymentQuery
So, code will be look like this :
.node(paymentId) { nodeQuery: NodeQuery ->
nodeQuery.onCheckout { checkoutQuery: CheckoutQuery ->
checkoutQuery
.createdAt()
.updatedAt()
.completedAt()
.email()
.ready()
.order {
it.orderNumber()
}
}
}
In above code, I am always getting ready=true (Whether I have purchased the product or not). The ready field is using inside the retryHandler function.
RetryHandler.exponentialBackoff(500, TimeUnit.MILLISECONDS, 1.2f)
.whenResponse(
response -> ((Storefront.Payment) ((GraphResponse<Storefront.QueryRoot>) response).data().getNode()).getReady() == false
)
.maxCount(12)
.build()
==================================================================
paymentId
, it must display checkoutId
. As it is confusing to the developer.ready
field must be changed when the order is successfully placed.order
field must not be null.Found the solution,
Point 1,
Point 2,
NOTE: Please make a note that, for getting updated result, you have to remove the defaultCachePolicy from the GraphClient object where we are setting up our shop to Shopify.
Now, while Polling for checkout completion, pass HTTPCachePolicy as
HttpCachePolicy.Default.NETWORK_ONLY
And the query will be as follows,
rootQuery.node(paymentId) { nodeQuery: NodeQuery ->
nodeQuery.onCheckout { checkoutQuery: CheckoutQuery ->
checkoutQuery
.createdAt()
.updatedAt()
.completedAt()
.email()
.ready()
.order {
it.orderNumber()
}
}
}