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
453 stars 199 forks source link

Nil Payment Returned From checkoutCompleteWithTokenizedPayment #705

Closed cocoahero closed 7 years ago

cocoahero commented 7 years ago

When attempting to complete an Pay checkout, we are seeing payment objects being returned as nil from checkoutCompleteWithTokenizedPayment. The checkout then appears to be marked as abandoned and listed in our Abandoned Checkouts list in Shopify.

Here is the returned response from the mutation query:

(lldb) po response
<Mutation: ["checkoutCompleteWithTokenizedPayment": {
    checkout =     {
        completedAt = "<null>";
        email = "jonathan@jonathanbaker.me";
        id = "a-redacted-checkout-id";
        orderStatusUrl = "<null>";
    };
    payment = "<null>";
    userErrors =     (
    );
}]>
cocoahero commented 7 years ago

Should note that the sample app (Storefront) appears to have the same issue.

davidmuzi commented 7 years ago

The bug is in the sample app, there needs to be a call to mutationForUpdateCheckout:updatingShippingAddress to add a shipping address before completing the checkout

cocoahero commented 7 years ago

@davidmuzi wouldn't that have already been done via the paySession(_ paySession: PaySession, didUpdateShippingAddress: callback on the PaySessionDelegate?

https://github.com/Shopify/mobile-buy-sdk-ios/blob/master/Sample%20Apps/Storefront/Storefront/CartViewController.swift#L218

davidmuzi commented 7 years ago

Unfortunately, Apple only provides a partial address suitable only to fetch shipping rates on that call. Only once the user authorizes the payment does Apple provide the full shipping address in didAuthorizePayment

calebd commented 7 years ago

The API should return an error in that case. If it knows the checkout isn't really complete, why do we get a successful response?

davidmuzi commented 7 years ago

Agree 💯 %. We are going to fix that.

calebd commented 7 years ago

Thanks! We were beating our heads against this for a while haha.