Add product from external catalog and Spartacus cart - spartacus-storefront

I have a scenario where we have an external web product catalog and user wants to Add the product from this external catalog to Spartacus cart.
The biggest constraint is the ext catalog (another software which cannot be customized) can only do a HTTP POST the payload containing multiple product ids, quantities, and other attributes through a callback URL. Since we are using Spartacus store-front, I don't think we can do a POST to a frontend endpoint like in accelerator. So that only gives us the option to POST to OCC API, which also brings troublesome for authentication, identify cart, etc. Is there any better solution/pattern?
If we can only update records via OCC, is there also a way to stream event to Spartacus to do cart refresh in UI?
Thanks for any suggestion!

Related

Building a shopify private or public app

I am trying to make a plan to update my client's shopify stores by building Shopify app or using external library. Basically, I want to provide my clients with some convenience by automating the inventory update, order process and extra stuff.
For now, I have only two scenarios.
Whenever my wholesale inventory changes, i want to update my client's shopify product list to be updated (quantity, price and product description) accordingly.
Whenever my client(shopify store owner) receives an order from his/her customer, i want the order information to be automatically transferred to my server.
If possible, I want my clients to be able to integrate with my application without any tech knowledge. I have looked into the Shopify app (public/private) and some external API(java), because I am a java developer.
I checked Shopify Java library which requires api key and password to be able to access shopify owner's store for product/order access, but I am not sure how user-friendly this approach is in terms of Shopify owner's side.
For Shopify public app, I am not familiar with it, so I am not sure how much I can do with it.
Could somebody provide some details about pros/cons about these approaches?
Thanks.
All you need to know is that with Shopify, you can connect to their shop using standard HTTPS. Even better, it's all GraphQL now. As for credentials, Shopify is fully modern and offers you two methods of getting credentials.
Your merchant client can create credentials with permissions right inside their Shopify Admin -> Apps. They give you the keys, you're in business
You get them (or you) to simply click install your App running at some HTTPS address, and you use oAuth to get the credentials.
Either way, makes no difference to the actual code you write to interact with their shop and deal with inventory, sales etc. You do not need to make your App public in the sense of App store, so you can use your partner dashboard to create an App and oAuth install, or like I said, use the private App way.

how to access shopify Products via API without api-key and password?

i want to develop a chrome extension to see stats for any store which develop in shopify, can i access any store products without API-Key and Password in shopify?
No, you cant access products json without using api-key or permanent token of the store.
But still you want to access the product details you atleast needs the handler of the product.
Lets say your store is "abc.myshopify.com" and handler of your product is "xyz", then you can product json of xyz by HTTP GET call in following url
https://www.abc.myshopify.com/products/xyz.json
in general
https://www.[storename]/products/[product-handle].json
You could try using the Shopify StoreFront API.
It allows to get information of your shop from from your own website or custom app. Although it doesn't need a API Password, it needs a Api Key that doesn't need to be a secret.
The documentation says this (the first point is the important):
Using the Storefront API, you can:
Fetch data about a single product or a collection of products to
display on any website or device.
Create unique checkout experiences
with full control over the shopping cart.
Create new customers or
modify existing ones, including address information.
Allow customers
to select unique product options.
There is no way shopify will provide store details (product list) without api authentication.
For your requirement, I would suggest to create a shopify app which will sync all product details to your storage and you can access data from there.

how to proceed to checkout page after making order in bigcommerce?

I have created orders using Bigcommerce API for a web based app.
Now after creating the order, how do I make the user to proceed to Bigcommerce checkout page to make the payment?
thanks
If you are capturing an order via the API, you won't be able to direct the user to a checkout page to just capture payments. The order creation is more for POS kind of flow, where you can capture the payment externally and create an order associated with that product in your bigcommerce store, thereby managing inventory details, syncing orders, etc.

How can orders be changed using the Shopify API?

Shopify Gurus! I'd like to know if any one of these is possible:
Step in at the checkout process and submit some user input for validation using a 3rd-party API
Submit certain details of an order to that same 3rd-party API for validation from the management panel (for instance, as the store takes the order to begin processing it)
The validation results in either case will need to replace the user's original input.
Short answer: No to both.
Long answer:
Steps 1 and 2 of the checkout are a black box, no external content is allowed. Therefore you can't add extra stuff to either of those pages.
Post-checkout you can send details off to a third party for validation, but in general orders are immutable on Shopify. There are a couple of exceptions to this:
Status: You can update the status of the order through the API
Order Notes: You can add notes to the order through the API
Neither of these options allow for the updating of customer info (shipping/billing addresses, payment information, etc.). You can however notify the merchant that the order is invalid for whatever reason and cancel it. This is most useful for fraud detection services.

how to link purchases to user records in another system?

sorry I posted this in the google group before I realized you had moved this type of question to stackoverflow
I'm developing a web app with an e-commerce component based on shopify as a white-labelled product for our clients. Our app allows our clients' customers to purchase a subscription to a product for use within the app. Each of our clients will have a separate shopify store. We have a web interface that allows our clients to create products and we use the shopify api to create the products in their store via an app. We have installed web hooks to receive notification of payments so that we can create the appropriate records in our system to allow the customer access to the product they purchased.
So far, the plan has been to provide a product list on our site with a 'Buy Now' button that adds the product to the store's cart and then direct the user to checkout using Shopify's checkout system. In the fulfillment web hook, we get the cart token so all we need to do to link the two systems is record the cart token temporarily in our customer database and then we can credit the right user with the purchase.
The problem that we are running in to is that there seems to be no way to link the cart / order / payment to the user that is actually logged in to our system. We are still under development so we are using test stores and the domain of the app is different from the domain of the store (and that may be the case in the production system too) and it is seemingly impossible to figure out how to link the two systems.
I have tried a couple of different approaches ...
1) use a form and post to the store's cart/add.js with a return_to=back
This seems successful in that the items are added to the cart and opening the cart in a new window takes them to the cart they added the item to, but there is no way to associate that cart with the user on our system since we can't access the cart token in a separate domain
2) use a proxy (our system is written in nodes) to post to the store's cart and intercept the cart token.
This also works in that an item is added to a cart and we can access the _session_id and cart cookies from the response, but I don't seem to be able to set those cookies in the browser. Going to the store's cart doesn't show the item just added and the store gets a different cart token.
Is there a different approach or should one of those work?
Should we be doing this entirely differently?
Cheers
Paul
Your best bet is to put something in cart attributes when the order is created and use that when you get the webhook to link the order to the other system. You could have a simple json endpoint on the other server to get back the currently logged in user, or have them enter some user is on the cart page and store them in the cart atributes. More on cart attributes http://wiki.shopify.com/Ask_customer_for_additional_information
To implement John's suggestion, I put the following into my cart.liquid file:
<script type="text/javascript">
(function($){
$(document).ready(function(){
$.ajax({
url: 'http://<server>/token',
dataType: 'jsonp',
success: function(data, status, xhr) {
$('#cartform').append('<input type="hidden" name="attributes[token]" value="'+data.token+'" />');
},
error: function(xhr, status, error) {
alert('Error');
}
});
});
})(jQuery);
</script>
My server runs on a different domain than the shop, so I'm using jsonp. The token is something I can use to uniquely identify a customer record in my database. I am using an attribute so that it doesn't conflict with our client's use of shopify's note feature if they want to use it themselves for something. I have not yet tested this with my web hook but I assume that I can make this work from here on.
I'm not completely satisfied with this as it requires that our clients put this into their templates in order for shopify to work with our system. I still think that there should be a way through the JSON /cart API to set the value of the note for a cart.