Beyond 2021
Beyond 2021

Reputation: 133

Stripe/Apple-pay Error

I keep getting this error when integrating stripe with apple-pay. Ive tried upload the CSR file according to Stripe but no luck.

{com.stripe.lib:ErrorMessageKey=We couldn't fully decrypt your request. Please make sure you've uploaded your Apple Pay certificate at https://dashboard.stripe.com/settings/apple_pay. For help doing this see https://stripe.com/docs/mobile/apple-pay., NSLocalizedDescription=We couldn't fully decrypt your request. Please make sure you've uploaded your Apple Pay certificate at https://dashboard.stripe.com/settings/apple_pay. For help doing this see https://stripe.com/docs/mobile/apple-pay.}

Upvotes: 3

Views: 4259

Answers (2)

Darkday-coder
Darkday-coder

Reputation: 63

I was also playing around with flutter-stripe for ios applepay and android g-pay: I perform following and it works:

Center(
                          child: Padding(
                            padding: const EdgeInsets.symmetric(
                                horizontal: 20.0),
                            child: PlatformPayButton(
                              onPressed: () {
                                _handleApplePayPress(
                                  context,
                                  widget.customerOrderItems!,
                                  StorageManager().totalAmount,
                                );
                              },
                            ),
                          ),
                        ),

this section gives the apple pay button on ios then for the method implementation

void _handleApplePayPress(
    BuildContext context,
    List<CartItem>? cartItem,
    double orderTotalPrice,
  ) async {
    try {
      print('trying');
      final SecretResponse response =
          await CustomerOrderRepository().submitOrder(
        cartItem: cartItem!,
        totalAmount: orderTotalPrice,
      );
      if (response.clientSecret != null) {
        try {
          final paymentIntentResult =
              await Stripe.instance.confirmPlatformPayPaymentIntent(
            clientSecret: response.clientSecret!,
            confirmParams: PlatformPayConfirmParams.applePay(
              applePay: ApplePayParams(
                merchantCountryCode: 'AU',
                currencyCode: 'AUD',
                cartItems: [
                  ApplePayCartSummaryItem.immediate(
                      label: "Total Amount",
                      amount: '${StorageManager().finalAmount}')
                ],
              ),
            ),
          );
          print('paymentIntentResult: $paymentIntentResult');
          print(
              'paymentIntentResult.status: ${response.customerOrderDTO?.toJson()}');
          if (paymentIntentResult.status == PaymentIntentsStatus.Succeeded) {
            _navigateToNextScreen(
                orderTotalPrice, response.customerOrderDTO?.orderNumber);
          } else {
            throw Exception(
                'Payment failed with status: ${paymentIntentResult.status}');
          }
        } catch (err) {
          print('Error: $err');
          String errorMessage = 'Error during payment';
          if (err is StripeException) {
            errorMessage = err.error.localizedMessage!;
          }
          CommonMethods.showFailreToast(errorMessage);
        }
      }
    } catch (error) {
      print('Error: $error');
      CommonMethods.showFailreToast('Something Went Wrong - $error');
    }
  }

this works for me..

Upvotes: 0

Beyond 2021
Beyond 2021

Reputation: 133

Thank you for the help. This reply from Thomas @ Stripe support solved my issue.

Hey there,

Thanks for writing in about this, I'm happy to help! Most often when we see this is it a result of Xcode caching something improperly, so I'd recommend going back to the guide at https://stripe.com/docs/mobile/apple-pay and starting completely from scratch (including creating a new Apple Merchant ID).

Make sure to create an Apple Pay Certificate using the certificate signing request you obtain from Stripe at https://dashboard.stripe.com/account/apple_pay, and using your new merchant ID (and that this process succeeds without any warnings).

Then download the certificate that Apple gives you and upload it on your Stripe dashboard.

Finally, after all that is done, enable the "Apple Pay" capability in your app, and select the new merchant ID on the Capabilities screen.

Also, don't forget to change the merchant identifier in your code as well (i.e. [Stripe paymentRequestWithMerchantIdentifier:myNewMerchantId]).

I hope this helps but please do not hesitate to get back to me if you need more details. All the best, Thomas

Upvotes: 5

Related Questions