Capture shopify payment response

99封情书 提交于 2019-12-11 05:56:33

问题


I recently started implementing shopify for one of my client. Since it's a website built in spring, I have only option to use their Javascript SDK. Everything is working fine I'm able to create a cart increase the number of product but once I redirected user to the shopify payment page I'm not able to track the payment status.

I tried to google this issue from last couple of days but I'm not able to figure out how to resolve this.

Can anyone help me with their experience what I'm doing wrong here. This is the link which I'm referencing to implement the sdk.

This is the code I have in my website for shopify

client = ShopifyBuy.buildClient({
    apiKey: 'APIKEY',
    myShopifyDomain: 'domain-name',
    appId: '6'
});

client.createCart().then(function (cart) {
   cart = cart;
   cart.addVariants({variant: product.selectedVariant, quantity: totalQuantity}).then(function (cart) {
   });
});

client.fetchProduct('productId').then(function(newProduct) {
    product = newProduct;
    variant = product.variants[0];
    checkoutURL = product.variants[0].checkoutUrl(totalQuantity);
    document.location.href = checkoutURL;
});

Thanking you in advance.


回答1:


It is possible making some changes in your client's website and in the checkout section of the admin shopify store.

  1. Add a custom javascript redirect in the store checkout page that redirects to the client's website and pass to it the ID of the order, you could do this by adding some js code in: Settings -> Checkout -> Additional scripts of store admin. Something like this:

    window.location =" http://YOURURLHERE.COM?orderid=xxx ";

Where xxx is the order ID.

  1. Once you are able to get the orderid in client side (javascript), you can call to the shopify API to get the order info (https://help.shopify.com/api/reference/order) by plain javascript.

Hope this help



来源:https://stackoverflow.com/questions/39888256/capture-shopify-payment-response

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!