naoufal/react-native-payments

`canMakePayments` value is wrong on iOS?

peetzweg opened this issue · 0 comments

const canMakePayment = await PaymentRequest.canMakePayments();

if (canMakePayment) {
  throw new Error("Can not make payment.");
}

When I call this method in my code it returns falls. It even throughs an exception if I try to catch an exception
Error: Can not make payment..

It happens in the simulator as well as on my physical device. However this not true as I'am able to make payments. If I ignore it's outcome and just proceed with the checkout it works fine. They payment even goes through a proper payment gateway and charged.

What am I doing wrong here?

I checked and it's just an exported native value of the PKPaymentAuthorizationViewController.

https://developer.apple.com/documentation/passkit/pkpaymentauthorizationviewcontroller

ReactNativePayments.m

- (NSDictionary *)constantsToExport
{
    return @{
             @"canMakePayments": @([PKPaymentAuthorizationViewController canMakePayments]),
             @"supportedGateways": [GatewayManager getSupportedGateways]
             };
}

https://developer.apple.com/documentation/passkit/pkpaymentauthorizationviewcontroller/1616192-canmakepayments

class func canMakePayments() -> Bool
true if the device supports making payments; otherwise, false.

Is it maybe because it's function? Not a swift pro nor a rn bridge crack 🤷