问题
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.
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
.
- 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