stripe-react-native icon indicating copy to clipboard operation
stripe-react-native copied to clipboard

Error: Apple Pay request type `nil` is not supported. Can't use apple merchant tokens

Open SohelIslamImran opened this issue 1 year ago • 11 comments

Describe the bug Can't use merchant tokens by setting the request with its type set to PaymentRequestType.Recurring as describe here : https://docs.stripe.com/payments/accept-a-payment?platform=react-native&mobile-ui=payment-element#add-apple-pay

It is throwing the error:

Error: {
message = "Apple Pay request type `nil` is not supported.";
}

I have provided the PaymentRequestType.Recurring type.

image

Also it is not showing the details like this:

image

To Reproduce Steps to reproduce the behavior:

const initializePaymentSheet = async () => {
  const recurringSummaryItem = {
    label: 'My Subscription',
    amount: '59.99',
    paymentType: 'Recurring',
    intervalCount: 1,
    intervalUnit: 'month',
    // Payment starts today
    startDate: new Date().getTime() / 1000,

    // Payment ends in one year
    endDate: new Date().getTime() / 1000 + 60 * 60 * 24 * 365,
  };

  const {error} = await initPaymentSheet({
    // ...
    applePay: {
      merchantCountryCode: 'US',
      cartItems: [recurringSummaryItem],
      request: {
        type: PaymentRequestType.Recurring,
        description: 'Recurring',
        managementUrl: 'https://my-backend.example.com/customer-portal',
        billing: recurringSummaryItem,
        billingAgreement:
          "You'll be billed $59.99 every month for the next 12 months. To cancel at any time, go to Account and click 'Cancel Membership.'",
      },
    },
  });
};

Expected behavior It shouldn't throw the error and it should show proper details on the Apple Payment Sheet.

Screenshots image image

Desktop (please complete the following information):

  • OS: iOS/Mac
  • Browser [e.g. chrome, safari]
  • Version 0.28.0 and 0.37.3

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context Add any other context about the problem here.

SohelIslamImran avatar May 14 '24 22:05 SohelIslamImran

i have the same issue

mk1020 avatar Jun 04 '24 22:06 mk1020

Same issue too.

stripe/stripe-react-native: v. 0.37.2 Device: iPhone 15 with iOS 17.4

Error: { message = "Apple Pay request type "nil' is not supported."; }

3molee avatar Jun 05 '24 13:06 3molee

I cannot find i way to show all infos on iOS 16+. Plus i cannot find a way to customize the currency (setup intent with secret created server-side).

But at least I found a way to fix the error. There is a problem on the try request.configureRequestType(requestParams: applePayParams) inside /ios/StripeSdk+PaymentSheet.swift.

I think it should pass the applePayParams["request"] property instead. I'll attach a patch-package patch to this comment.

Version 0.37.2

@stripe+stripe-react-native+0.37.2.patch

projectnatz avatar Jun 06 '24 12:06 projectnatz

For now, you can use confirmPlatformPaySetupIntent and confirmPlatformPayPayment.. It works!

https://docs.stripe.com/apple-pay?platform=react-native#present-payment-sheet

const { confirmPlatformPayPayment, confirmPlatformPaySetupIntent } = useStripe();
  
const payWithApple = (recurringItem, billingAgreement)=> {
 if (recurringItem && billingAgreement) {
      const { error } = await confirmPlatformPayPayment(
        data?.paymentIntentClientSecret,
        {
          applePay: {
            currencyCode: "EUR",
            merchantCountryCode: "FR",
            cartItems: [recurringItem],
            request: {
              billingAgreement,
              billing: recurringItem,
              description: "Recurring",
              managementUrl: "https://www.domain.com",
              type: PlatformPay.PaymentRequestType.Recurring,
              trialBilling: existingUser ? undefined : getTrialBilling(),
            },
          },
        }
      );
    }
  }

@projectnatz @mk1020 @3molee @cpytel

SohelIslamImran avatar Jun 06 '24 13:06 SohelIslamImran

+1 This is currently blocking us from allowing Apple Pay

zacherygentry avatar Jun 26 '24 15:06 zacherygentry

For now, you can try my above solution @zacherygentry

SohelIslamImran avatar Jun 26 '24 15:06 SohelIslamImran

Currenlty Blocking me as well. Is this fixed yet

NooryA avatar Jul 30 '24 12:07 NooryA

Any updates? Blocked as well.

delandchen avatar Oct 10 '24 07:10 delandchen


 const applePayRequest = {
        type: PaymentRequestType.Recurring,
        description: 'Recurring',
        managementUrl: 'https://my-backend.example.com/customer-portal',
        billing: recurringSummaryItem,
        billingAgreement:
          "You'll be billed $59.99 every month for the next 12 months. To cancel at any time, go to Account and click 'Cancel Membership.'",
      }

  const {error} = await initPaymentSheet({
    // ...
    applePay: {
      merchantCountryCode: 'US',
      cartItems: [recurringSummaryItem],
      ...applePayRequest
      request: applePayRequest,
    },
  });

Quick solution: This will help resolve the error. @delandchen @NooryA @zacherygentry

tarunsinghal92 avatar Oct 30 '24 21:10 tarunsinghal92