#SishirG-applepay-reactnative
1 messages · Page 1 of 1 (latest)
Are you seeing a specific crash? Are there any other details you can share?
Apple changed the entire UI for ios 15
and when I type apple pay btn there is no response
You're getting no errors at all? You mentioned it seems to be crashing - do you have the stack trace?
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;
}
}
thanks for sending that over - let me take a closer look
okay
What do you get if you print/log details that you get back from presentApplePay - I'm just curious what you're seeing there
literally nothing
i dont think the sdk is updated here's their new video:https://developer.apple.com/videos/play/wwdc2021/10092/
Let me try and pull in some other folks to see what's going on!
Yes please
and just to check - which version of our react native sdk are you using?'
"@stripe/stripe-react-native": "^0.2.3",
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?
I tested it on ios 14.7.1 and it works fine
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?
Will do
Thanks, hopefully you can get a bit more details about which part is crashing and then we can debug what's causing it
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
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
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?
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',
},
];
yay typing :p
But why doesnot const items = [ { label: purchaseInfo.storeTitle, amount: JSON.stringify(purchaseInfo.total), }, ]; work?
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
ooh so i should round it up?
{
label: purchaseInfo.storeTitle,
amount: purchaseInfo.total.toFixed(2),
},
];``` this works :))
sounds good thank you very much I really appreciate it