1
votes

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
With Shopify being a hosted platform, there is no payment response for you to capture. If you want the details of the payment, you can get them from the order itself using the API, post checkout once the order exists. Keep in mind that checkout in Shopify is controlled by Shopify. So you don't get to code much in there. You can use any Analytics you want pre-checkout, post-checkout. - David Lazar
@DavidLazar Thanks for the comment can you please suggest me any link from where I can get some idea. I'm new to Shopify - Luffy
Shopify has an immense amount of relevant documentation for you. Check out their website. - David Lazar

1 Answers

2
votes

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