Shopify / mobile-buy-sdk-ios

Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app. With a few lines of code, you can connect your app with the Shopify platform and let your users buy your products using Apple Pay or their credit card.
MIT License
452 stars 199 forks source link

Using X-Shopify-Customer-Access-Token on a draft order url complains that url is deleted #1171

Open pradyotd opened 2 years ago

pradyotd commented 2 years ago

I am using a private app on Shopify to generate a draft order. I use the resulting url in my IOS app in a WKWebView along with a X-Shopify-Customer-Access-Token --> header and customerAccessToken from login. The resulting screen complains that "Checkout page you are looking for does not exist". If I take the same url and use a browser, I am taken to a login screen, which if I login, I can see the order checkout page. My code is as below.

`import SwiftUI import WebKit

struct WebView: UIViewRepresentable {

var url: URL
var customerAccessToken: String

func makeUIView(context: Context) -> WKWebView {
    return WKWebView()
}

func updateUIView(_ webView: WKWebView, context: Context) {
    var request = URLRequest(url: url)
    request.addValue(customerAccessToken, forHTTPHeaderField: "X-Shopify-Customer-Access-Token")
    webView.load(request)
}

} ` The moment I comment out the line adding the header, the WkWebView loads the login page. I have confirmed that the customerAccessToken isn't some cached value, and is the latest obtained on login(possibly a couple of mins old at most).

The version of Mobile Buy SDK I am using is: image

Hope to get some direction here. thanks! This is the screen shot of the error I see. image