Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancel presented Apple Pay #918

Closed
rob5408 opened this issue May 2, 2022 · 1 comment
Closed

Cancel presented Apple Pay #918

rob5408 opened this issue May 2, 2022 · 1 comment

Comments

@rob5408
Copy link

rob5408 commented May 2, 2022

Is your feature request related to a problem? Please describe.
In my app I followed the steps here to...

  1. Present an Apple Pay screen
  2. Fetch a Payment Intent from my server
  3. Confirm Apple Pay

...however in development I had an issue in my payment intent endpoint and while this was communicated back to the app immediately I had to wait for the Apple Pay screen to timeout (15s?) to inform the user.

Describe the solution you'd like
I've read a bunch of documentation and I don't think this has been considered yet. Happiest if the solution was just to use an existing method. Now, ideally all my endpoints work as they should all the time, but I'm a belt and suspenders kinda guy. If the server throws back an error it would be nice to manually cancel the Apple Pay screen. I was thinking about something like this...

    const { error, paymentMethod, cancelApplePay } = await presentApplePay({ ... });

Where cancelApplePay is just a method I could call to dismiss the Apple Pay screen immediately.

Describe alternatives you've considered
I have thought maybe I should just get the Payment Intent first which would allow me to skip the awkward situation caused by the above where Apple Pay presents and then dismisses with an error unrelated to Apple Pay. I think this is probably best as it requires no SDK change except for maybe different guidance in the example code or documentation. I generally try not to deviate from y'alls instructions though.

I've also thought about instead of my normal flow of immediately throwing from my Payment Intent endpoint instead providing a known invalid client secret to confirmApplePayPayment so it just fails quicker.

const pay = async () => {
    const { error, paymentMethod } = await presentApplePay({ ... });

    if (error) {
      Alert.alert(error.code, error.message);
    } else {
      let clientSecret = "INVALID"
      try {
         clientSecret = await fetchPaymentIntentClientSecret();
      } catch (error) {
      }

      const { error: confirmApplePayError } = await confirmApplePayPayment(
        clientSecret
      );

      if (confirmApplePayError) {
        Alert.alert(confirmApplePayError.code, confirmApplePayError.message);
      } else {
        Alert.alert('Success', 'The payment was confirmed successfully!');
      }
    }
  };

Additional context
None.

@charliecruzan-stripe
Copy link
Collaborator

hi! going to close this as a duplicate of #447, but I really appreciate the thorough explanation, and we'll take this into account when building this feature 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants