Closed aShaforostov closed 6 years ago
Make Pull Request for update docs for this issue
@Hafros I get "java.lang.ClassCastException: com.shopify.buy3.Storefront$Checkout cannot be cast to com.shopify.buy3.Storefront$Payment" with the changes on your Pull Request
@amanzan Attach please your code
It's my working void
public void pollingForCheckoutCompletion(String checkout_id, String payment_id, final CheckoutRequestComplete completeHandler, final CheckoutRequestFail failHandler){
//ID checkoutId = new ID(checkout_id);
ID paymentId = new ID(payment_id);
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()
)
)
);
this.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()){
completeHandler.callback(payment.getCheckout());
}
else{
failHandler.callback(payment.getErrorMessage());
}
}
@Override public void onFailure(@NonNull GraphError error) {
failHandler.callback(error.getLocalizedMessage());
}
},
null,
RetryHandler.exponentialBackoff(500, TimeUnit.MILLISECONDS, 1.2f)
.whenResponse(
response -> ((Storefront.Payment) ((GraphResponse<Storefront.QueryRoot>) response).data().getNode()).getReady() == false
)
.maxCount(12)
.build()
);
}
I might had made a mistake before, now my code is like yours. But now I get "com.shopify.buy3.GraphError: Failed to reschedule GraphQL query execution". How do you create your GraphClient?
@amanzan
private GraphClient client(){
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(logging)
.build();
return GraphClient.builder(context)
.shopDomain(BuildConfig.SHOP_DOMAIN)
.accessToken(BuildConfig.API_KEY)
.httpClient(client)
//.httpCache(new File(context.getApplicationContext().getCacheDir(), "/http"), 10 * 1024 * 1024) // 10mb for http cache
// .defaultHttpCachePolicy(HttpCachePolicy.NETWORK_ONLY), //.expireAfter(5, TimeUnit.MINUTES)) // cached response valid by default for 5 minutes
.build();
}
Still same error, "com.shopify.buy3.GraphError: Failed to reschedule GraphQL query execution" I couldn't get RetryHandler to work for some reason, so I gave up and created my own. Thanks anyway, I still can use your code for checking payment errors :)
I'm using your polling code right after checkoutCompleteWithCreditCard and the payment object never get ready even though i can see in the admin web console the confirmed order. any suggestions?
@dudadayan Have you tried to increase the maxCount?
@aShaforostov Yes, with no success
@dudadayan Check your "Payment authorization" in shop settings
Settings -> Payment providers
In my case there is an "Automatically capture payment for orders."
@aShaforostov Thanks, I changed it to capture payments, but still, it didn't work
@dudadayan What is payment gateway your using? In my case is Stripe
@aShaforostov I'm using "Network Merchants (NMI)" as my gateway (in test mode). I don't think the problem is with them because I can see all the orders i made as confirmed in my shopify admin panel.
@dudadayan Most likely this is because of the test mode, try to disconnect it and try to make a real transaction
@aShaforostov is this issue still exist?
@sav007 I'm with @Hafros found a solution. Problem in you docs. Pull request was made
Thx will merge it!!
addressed in docs: https://github.com/Shopify/mobile-buy-sdk-android/pull/516
Still same error, "com.shopify.buy3.GraphError: Failed to reschedule GraphQL query execution" I couldn't get RetryHandler to work for some reason, so I gave up and created my own. Thanks anyway, I still can use your code for checking payment errors :)
@amanzan can u please share your code
@Hafros how i can resolve this issue ""com.shopify.buy3.GraphError: Failed to reschedule GraphQL query execution"
I am also facing this issue "com.shopify.buy3.GraphError: Failed to reschedule GraphQL query execution"
If I remove rescheduling code I get "java.lang.ClassCastException: com.shopify.buy3.Storefront$Checkout cannot be cast to com.shopify.buy3.Storefront$Payment"
When i make "Polling for checkout completion" after "checkoutCompleteWithCreditCard", with not valid credit card, I'm not get any errors. While polling in progress, I go to Abandoned checkouts in my store, in browser, and see that payment with error "Your card was declined.", but this error not exist in polling response