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

Unable to checkout with Apple Pay if gift card is applied (follow up from #927) #959

Closed jenchuah closed 5 years ago

jenchuah commented 5 years ago

This is a follow up from #927

The paymentDue is reduced by gift card applications, see Mobile Buy SDK's Checkout class:

/// The amount left to be paid. This is equal to the cost of the line items, 
        /// taxes and shipping minus discounts and gift cards. 
        open var paymentDue: Decimal { get }

So when you add paymentDue to [PKPaymentSummaryItem] you will get the following error because as you said the API is expecting the total since the gift card isn't charged until checkout completion.

Optional(<Mutation: ["checkoutCompleteWithTokenizedPayment": {
    payment = "<null>";
    userErrors =     (
                {
            field =             (
                payment,
                amount
            );
            message = "Amount The amount of the payment must match the total of 52.00.";
        }
    );
}]>)
dbart01 commented 5 years ago

@rebeccajfriedman Is this the intended behaviour for paymentDue?

rebeccajfriedman commented 5 years ago

This is the expected behaviour right now. We are working to make the flow more intuitive, and we'll update here when we do.

jamiemtdwyer commented 5 years ago

Since paymentDue is reduced by gift card applications, and the API is expecting the full balance of the checkout, I think the solution then is to pass the totalPrice to the payment mutation.

chirilavasiletiberiu commented 5 years ago

I don't really understand the process of a transaction. Why we should pass the totalPrice to the payment mutation if the paymentDue reflects the total value that customer should pay? After all, how gift cards are working? :)

rebeccajfriedman commented 5 years ago

The gift card is not charged until the checkoutCompleteWithTokenizedPayment mutation is called, which is why it needs to accept the full amount. It will deplete the gift card before charging the remaining (paymentDue) balance.

mihai-moldovan commented 4 years ago

Hey, we've recently hit the same problem. I've checked the latest sample app and the latest sdk version and the problem still presist. How did you fix it?

ashishsuranaace commented 2 years ago

I am also having same issues here. Please any can guide to solve this problem or any hint. ▿ Optional