#SishirG-applepay-reactnative

1 messages · Page 1 of 1 (latest)

warped ether
short galleon
#

hi @warped ether

#

i think stripe-react-native is broken in ios 15

warped ether
#

Are you seeing a specific crash? Are there any other details you can share?

short galleon
#

Apple changed the entire UI for ios 15

#

and when I type apple pay btn there is no response

warped ether
#

You're getting no errors at all? You mentioned it seems to be crashing - do you have the stack trace?

short galleon
#

there is no stack trace, like there is no response

#

I'll send u recording

#
function PayBtnStripe({nav, clientSecret, purchaseInfo, userInfo, enabled}) {
  const [, setCartItems] = useAtom(CARTITEMS);
  const {presentApplePay, confirmApplePayPayment, isApplePaySupported} =
    useApplePay();

  useEffect(() => {
    initStripe({
      publishableKey: STRIPE_PUBLISHABLE_KEY_LIVE,
      merchantIdentifier: STRIPE_MERCHANT_IDENTIFIER,
      stripeAccountId: purchaseInfo.vendorId,
    });
  });

  const items = [
    {
      label: purchaseInfo.storeTitle,
      amount: JSON.stringify(purchaseInfo.total),
    },
  ];

  const checkPay = async () => {
    if (isApplePaySupported) {
      pay();
    } else {
      Alert.alert('Please setup ApplePay to make payments.');
    }
  };

  const pay = async () => {
    try {
      const details = await presentApplePay({
        cartItems: items,
        country: 'US',
        currency: 'USD',
        shippingMethods: [],
        requiredBillingContactFields: [],
        requiredBillingAddressFields: [],
      });

      if (details.error) {
        // handle error
        if (details.error.code !== 'Canceled') {
          Alert.alert('Error occoured while using Apple Pay. Please try again');
          return;
        }
      } else {
        const {error: confirmError} = await confirmApplePayPayment(
          clientSecret,
        );

        if (confirmError) {
          // handle error
          Alert.alert(error);
          return;
        }
      }
warped ether
#

thanks for sending that over - let me take a closer look

short galleon
#

okay

warped ether
#

What do you get if you print/log details that you get back from presentApplePay - I'm just curious what you're seeing there

short galleon
#

literally nothing

warped ether
#

Let me try and pull in some other folks to see what's going on!

short galleon
#

Yes please

warped ether
#

and just to check - which version of our react native sdk are you using?'

short galleon
#

"@stripe/stripe-react-native": "^0.2.3",

kind isle
#

SishirG-applepay-reactnative

#

Also you said it's broken on iOS 15. Does that mean your app perfectly works on iOS 14? Or is it the first time you test?

short galleon
#

I tested it on ios 14.7.1 and it works fine

kind isle
#

Can you also fix if (confirmError) { // handle error Alert.alert(error); return; } to alert the correct error?

#

same for the if before that if (details.error) { // handle error if (details.error.code !== 'Canceled') { Alert.alert('Error occoured while using Apple Pay. Please try again'); return; } } you only log for a specific type, not all of them. Can you clearly log a message for each step?

short galleon
#

Will do

kind isle
#

Thanks, hopefully you can get a bit more details about which part is crashing and then we can debug what's causing it

short galleon
#

Have you been able to test it on your end in ios 15?

#

I'm running the app rn btw

kind isle
#

We're trying to test, upgrading to iOS 15 is not an instant task, but we're confident it should work as is at least. While we try, the best option is for you to add the logs I mentioned to narrow it down too

short galleon
#

So i added the logs like so const details = await presentApplePay({ cartItems: items, country: 'US', currency: 'USD', shippingMethods: [], requiredBillingContactFields: [], requiredBillingAddressFields: [], }); console.log(details); console.log('Hello'); but it's not printing anything after presentApplePay function

#

I think the promise is not being resolved

#

The I tried to resolve promise without async/await like this

        cartItems: items,
        country: 'US',
        currency: 'USD',
        shippingMethods: [],
        requiredBillingContactFields: [],
        requiredBillingAddressFields: [],
      }).then((res) => {
        console.log('RESULT LOG', res);
        return res;
      });
      console.log('DETAILS LOG', details);```
#

DETAILS LOG {"_U": 0, "_V": 0, "_W": null, "_X": null} here's the log

kind isle
#

I don't fully grasp what you're trying to prove. It's expected the DETAILS LOG yields nothing since your call isn't blocking right?

short galleon
#

Oh yea i was just trying another way to get payment method

        cartItems: items,
        country: 'US',
        currency: 'USD',
        shippingMethods: [],
        requiredBillingContactFields: [],
        requiredBillingAddressFields: [],
      }).then((res) => {
        return res.paymentMethod;
      });
      console.log('DETAILS LOG', details);```
#

and the result is the same

#

yesterday I had a chat with @stable relic and he's in the process of updating his computer to be ios 15 compatible i think

#

I think i get some logs in xcode

#

ooh i see i think my payment amount wasn't a string

#

When i do thi it works

#

const items = [
{
label: purchaseInfo.storeTitle,
amount: '12.33',
},
];

kind isle
#

yay typing :p

short galleon
#

But why doesnot const items = [ { label: purchaseInfo.storeTitle, amount: JSON.stringify(purchaseInfo.total), }, ]; work?

kind isle
#

hard to say, can you print the output? maybe that's null or an empty string?

#

Looks like you pass 6.2469 which wouldn't work right? Amounts are up to cents

#

The SDK should definitely catch this and error better, I don't think we've seen anyone hit that before

short galleon
#

ooh so i should round it up?

#
    {
      label: purchaseInfo.storeTitle,
      amount: purchaseInfo.total.toFixed(2),
    },
  ];``` this works :))
kind isle
#

yay!

#

and yes all amounts have to be up to cents

short galleon
#

sounds good thank you very much I really appreciate it

kind isle
#

Sure, thanks for the patience, that's a weird one because all of us thought it'd error clearly and we wouldn't have thought to ask you about the amount 😅

#

but we'll flag to make sure the SDK handles this gracefully in the future