Determine Shop To Which Fulfilled Order From Webhook Belongs - shopify

I have a Shopify app that creates a webhook for orders/fulfilled when a shop signs up, I also save some details about the shop as well as it's products.
When Shopify sends me fulfilled orders via the webhook, i want to associate this order with the appropriate shop to which it belongs.
I have looked in the data sent, but there's no shop name or shop url.
Is there a way for me to determine which shop the orders belong to?
Thanks.

If you have setup a Webhook then you know two things for sure.
The domain of the shop calling you is in the header
There is authentication information in the header you have to use
If you are not authenticating your webhook you're doing it wrong. So the short answer to determining which shop is calling you is to look inside the header for the domain.

Related

How does one associate a website user with a Paypal subscription?

I am implementing subscriptions to a premium service on a website using Paypal as the payment service. I have successfully created a Catalog Product and Billing Plan through the API, and I am able to get to the payment page on Paypal, but it's not clear how I'm supposed to persist a user identifier through the purchase process.
I assumed it would be something along the lines of passing a user id somewhere, but there's nothing in the Paypal documentation about this. I need to be able to let the user make a purchase and have the Paypal webhook send the confirmation to an endpoint on my site, and that's where I'd expect to get their user id to toggle the subscription on their account on my end.
Is there something I'm missing? There has to be a way to do this cause I'd imagine it's a pretty common use case. If anyone has information or has done this before, I'd love to hear. Thanks.
The only truly secure way I've found when using javascript SDK, is to securely generate a unique custom_id on your server side associated with the user.
Then when you create the buttons, the 'createSubscription' function takes custom_id as a parameter.
Then use a webhook to receive events from your subscription and the custom_id will be present in the body of all BILLING.SUBSCRIPTION events under resource.custom_id.
I am able to get to the payment page on PayPal,
You are vague about what you are doing here. There are multiple ways (and some ways have multiple versions) of accepting subscriptions via PayPal, so it is important that you provide full details about the method you are using.
The time to associate a created subscription ID with a user ID is when it is approved, in the onApprove function if you are using a Smart Payment Button: https://developer.paypal.com/docs/subscriptions/integrate/#4-create-a-subscription

How to redirect user back to the Sales Channel once the Shopify Payment is completed?

I have build a Sales Channel for my e-commerce website. The Sales Channel loads shopify products from Shopify stores to my e-commerce website.
Now I want to implement the Buy functionality: the user selects a product in my e-commerce website. I would create a DraftOrder and send the draft order to Shopify, shopify would respond with am invoice-url.
Now I can redirect the user to this invoice-url to make the payment directly through Shopify... but I want to redirect the user back to my e-commerce website, once the payment is completed.
Is it possible to implement this redirect functionality?
Note: I had asked a similar question trying to achieve the same goal using Checkout API.
You cannot do too much on the order status page - the page customer gets in once an order is placed and paid. You can add custom scripts on the shop's checkout settings page: Add Additional Scripts. For example, you can show a message with a link back to your sales channel.
If you're on Shopify Plus you can customize checkout.liquid directly.

shopify webhook - identify a different client

I would like to integrate my backend API with several shopify clients by using webhook created by shopify.
I read that webhook is a push notification triggered by shopify. If I give my server endpoint (receiving order/creating a new customer) to my several shopify clients, how will I identify a different notification?
Will there be a unique identifier(per client) in the notification sent by shopify? It's because if I receive an order notification, I need to identify this order notification with one of my clients in my db.
Please advise me about this use case.
Thanks.
Per the Shopify Webhook Documentation, each webhook from Shopify contains a JSON payload and HTTP headers that provide context.
The X-Shopify-Shop-Domain HTTP header includes the domain of the shop, e.g., johns-apparel.myshopify.com. You can use this to identify the shop.
Every Webhook comes to you from Shopify with security information that allows you to determine if the incoming Webhook is even valid and every Webhook also tells you the shop the Webhook is coming from.
So you can use the shop information to figure things out. Straightforward!

Paypal rest api express checkout with no shipping field (WebProfile handling)

I'm using Paypal rest api to make payment
the workflow is:
Create payment
Redirect to approval Url
User approved (return back to my site)
Execute payment
But there's one thing that I don't want users re-filling shipping address again because it was filled in my website.
So I change the workflow to:
Create web profile (set no shipping field)
Get web profile ID
Create payment with experienceProfileId given
Redirect to approval Url
User approved (return back to my site)
Execute payment
But I found this will create a lots WebProfile every time user request payment.
I think it is crazy to do:
create and delete it later again and again
attempt listing WebProfiles and check which is the one I want to use every time while creating payment
store experienceProfileId as a constant
What is the best practice for handling WebProfile or does there any solution just hiding shipping address while user approving payments?
Maybe this is not the answer regarding this "WebProfile". As a fact, I dont know what exactly "WebProfile" does or is.
I worked on the same Workflow these days. As you wrote I needed to predefine some address. For me it was obvious, that I have to do the database-stuff on my Website. Then I exactly define the order, shipping_address, etc. and send the users to Paypal.
If you predefine the new ShippingAddress() to your ´new ItemList()´ by
$itemlist->setShippingAddress($shippingaddress) the user cannot change it within the Process.
http://i.imgur.com/nAg8jxU.png
Maybe this helps you a little.

When will Shopify include customer webhooks?

Does anyone have any idea when/if Shopify will offer 'customers/created', 'customers/updated', and 'customers/delete' webhook events?
It would be great to be able to have our app notified when merchants are making changes to their customer records via their Store admin, or when someone creates a customer account without having completed an order.
They now exist! Check them out at http://api.shopify.com/webhook.html