naoufal / react-native-payments

Accept Payments with Apple Pay and Android Pay using the Payment Request API.
https://www.npmjs.com/package/react-native-payments
1.59k stars 413 forks source link

canMakePaymentsUsingNetworks for checking if cards are available #98

Open jimmystridh opened 6 years ago

jimmystridh commented 6 years ago

Problem: canMakePayments only checks if the system supports Apple Pay but does not check if the user has added a credit card. Sometimes you might want to behave differently if Apple Pay hasn't be set up yet.

Something like this works well in my tests (the added constant canMakeCcPayments):

- (NSDictionary *)constantsToExport
{
    return @{
             @"canMakePayments": @([PKPaymentAuthorizationViewController canMakePayments]),
             @"supportedGateways": [GatewayManager getSupportedGateways],
             @"canMakeCcPayments": @([PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:[NSArray arrayWithObjects: PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa, nil]])
             };
}

however I'm not sure where the best place to put it is. I'm also not sure if there is an Android equivalent.

This seems to be related to #77 , and might be a solution to implementing that call (there doesn't seem to be another native equivalent to canMakePaymentsWithActiveCard).

What are your thoughts on implementing this ?

Docs for method canMakePaymentsUsingNetworks:

ACOSW commented 6 years ago

@jimmystridh hi, i have faced same problem. So i created a small pull request to resolve this issue

jimmystridh commented 6 years ago

@ACOSW nice, that would work for my needs. @Andreyco what is your view on this ? Thanks

ACOSW commented 6 years ago

Looks like this project is dead and not maintained anymore =|