Skip to content

Commit

Permalink
Add applePayEnabled static method to PaymentRequest. [MITM-866]
Browse files Browse the repository at this point in the history
It's problematic for our use case to have to have to construct a payment request
in order to check if apple pay is enabled on the device via canMakePayments
instance method.

add a static method that lets us check if apple pay is enabled on the device.

<!-- ps-id: 36eab9f2-b5ed-4852-bcee-51262e81ab2f -->
  • Loading branch information
trcoffman committed Nov 14, 2023
1 parent fe91b8c commit 035a8e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions js/NativeBridge/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const IS_ANDROID = Platform.OS === 'android';

const NativePayments: {
canMakePayments: boolean,
applePayEnabled: () => boolean,
canMakePaymentsUsingNetworks: boolean,
openPaymentSetup: void,
supportedGateways: Array<string>,
Expand Down Expand Up @@ -40,6 +41,13 @@ const NativePayments: {
});
},

applePayEnabled() {
if (Platform.OS === 'ios') {
return ReactNativePayments.canMakePayments;
}
return false;
},

// TODO based on Naoufal's talk on YouTube the intention of canMakePayments is for it to work like this, so I'm thinking we can integrate Yegor's code into canMakePayments.
// NF 2020-11-18
canMakePaymentsUsingNetworks(usingNetworks: []) {
Expand Down
1 change: 1 addition & 0 deletions js/PaymentRequest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ export default class PaymentRequest {
);
}

static applePayEnabled = NativePayments.applePayEnabled;
static canMakePaymentsUsingNetworks = NativePayments.canMakePaymentsUsingNetworks;
static openPaymentSetup = NativePayments.openPaymentSetup;
}
Expand Down

0 comments on commit 035a8e4

Please sign in to comment.