CheckoutWithWebView success return info

New Member
4 0 0

I am building out a mobile app entirely in Unity. I have shopify all set up and can create a cart, add an item from my store, and successfully make a purchase using CheckoutWithWebView. What I would like/need is some kind of info, and kind of unique identifier, for the transaction.

 

On success, the app notifies the backend that a purchase has been made and for how much. Our backend needs to be able to verify that purchase by checking with Shopify to make sure there was an actual transaction and that it's not being spoofed. However, since the success message relays no information, I can't give the backend anything to use to verify.

 

Is there any way to retrieve info from a successful purchase, or to somehow add an identifier at the build cart stage? Maybe add a custom field that I can add a random number to that can later be queried in our orders?

0 Likes
Shopify Staff
Shopify Staff
130 17 20

Hey @Moge,

 

Consider configuring an orders/create webhook to listen for new orders. As for the spoofing concern, here's how you can verify these requests are from Shopify.

0 Likes
New Member
4 0 0

Hi -

 

Thanks for the reply and the help. It may be I'm being dense, but I'm not sure this helps...

 

We could set up a webhook to notify our Shopify private app of a transaction. We could even have set it up to notify our backend of that transaction. But there's no way to map that transaction to the user in our Unity app. For example, our unique identifier is email. But the person could be logged in to our Unity app with one email, but checkout through Shopify with their PayPal account, and maybe for that they use a different email and maybe their name is Robert instead of Bob. We can already query Shopify for all orders, but there's still no way to link the purchase made in Shopify to the success message in Unity. 

 

We really some kind of unique identifier that is known to the Unity app, the backend, and the Shopify store. That could be the Shopify order number, but the Unity app has no access to it because the Shopify store sends back no information. If we could add a custom attribute to the cart with a unique identifier that we also send to the backend, the backend could look for in the Shopify orders for an order with that attribute. However, there's nothing in the SDK for adding a custom attribute to a Cart.

 

Any other ideas on how to triangulate? Or am I missing something fundamental with the webhooks?

 

Thanks!

0 Likes
Highlighted
Shopify Staff
Shopify Staff
130 17 20

Thanks for clarifying!

 

Perhaps custom checkout attributes would work? If you're using the Unity SDK it appears to be implemented.

 

Let me know how you go.

0 Likes
New Member
4 0 0

Hi - 

 

This seems like it could be the right direction, and I'm now definitely being dense, so I'm hoping you'll bear with me...

 

In trying to figure out how to create a checkout and add it to my cart so I can send along custom attributes (I failed - is there a sample anywhere? I could not find anything.), I stumbled across the fact that after a successful purchase, I seem to be able to access the cart's CurrentCheckout. From there, I've managed to retrieve that Checkout's id, but that does not seem to be something that is accessible otherwise through the API.

 

There is also a method for retrieving the order number, which would solve everything, I'm pretty sure, but when I try to access that I get the following error...

NoQueryException: It looks like you did not query the field `order`

 

If you can clue me in on how to solve that, I think all would be well in my world.

 

0 Likes
Shopify Staff
Shopify Staff
130 17 20

An order number wont be available until the order is actually placed. 

 

Here's an example of creating a checkout with custom attributes:

 

mutation {
  checkoutCreate(input: {
    lineItems: [
      {
        variantId: "...",
        quantity: 1
      }
    ],
    customAttributes: [
      {
        key: "example",
        value: "hello"
      }
    ]
  }) {
    checkout {
       id
    }
  }
}

and then you can pull them out of the note_attributes array:

22-43-q4m66-rjela

0 Likes