From c540e4f820e5370ba9e96bc15d967a7a04f94561 Mon Sep 17 00:00:00 2001 From: DS Boyce Date: Mon, 22 Aug 2022 14:39:17 -0700 Subject: [PATCH 1/2] Add offerPayLater option --- android/src/main/java/com/smarkets/paypal/RNPaypalModule.java | 2 ++ index.d.ts | 2 ++ ios/RNPaypal.m | 2 ++ 3 files changed, 6 insertions(+) diff --git a/android/src/main/java/com/smarkets/paypal/RNPaypalModule.java b/android/src/main/java/com/smarkets/paypal/RNPaypalModule.java index b697b42..1b89750 100644 --- a/android/src/main/java/com/smarkets/paypal/RNPaypalModule.java +++ b/android/src/main/java/com/smarkets/paypal/RNPaypalModule.java @@ -58,6 +58,8 @@ public void requestOneTimePayment( PayPalRequest request = new PayPalRequest(options.getString("amount")) .intent(PayPalRequest.INTENT_AUTHORIZE); + if (options.hasKey("offerPayLater")) + request.offerPayLater(options.getBoolean("offerPayLater")); if (options.hasKey("currency")) request.currencyCode(options.getString("currency")); if (options.hasKey("displayName")) diff --git a/index.d.ts b/index.d.ts index 0634afb..bdd655b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -92,6 +92,7 @@ declare function requestOneTimePayment(token: string, { shippingAddressRequired, userAction, intent, + offerPayLater, }: { amount: string, currency ? : paypalSupportedCurrencies, @@ -99,6 +100,7 @@ declare function requestOneTimePayment(token: string, { shippingAddressRequired ? : boolean, userAction ? : 'commit' | 'continue', intent ? : 'sale' | 'authorize' | 'order', + offerPayLater ? : boolean, }): Promise ; declare function requestBillingAgreement(token: string, { diff --git a/ios/RNPaypal.m b/ios/RNPaypal.m index 7dc8dad..98433a3 100644 --- a/ios/RNPaypal.m +++ b/ios/RNPaypal.m @@ -42,6 +42,8 @@ + (BOOL)requiresMainQueueSetup payPalDriver.appSwitchDelegate = self; BTPayPalRequest *request= [[BTPayPalRequest alloc] initWithAmount:options[@"amount"]]; + BOOL offerPayLater = [options[@"offerPayLater"] boolValue]; + if (offerPayLater) request.offerPayLater = offerPayLater; NSString* currency = options[@"currency"]; if (currency) request.currencyCode = currency; NSString* displayName = options[@"displayName"]; From 9fcb9e190db5f80f6d3a618fc8afa00d14e74820 Mon Sep 17 00:00:00 2001 From: DS Boyce Date: Mon, 22 Aug 2022 14:43:55 -0700 Subject: [PATCH 2/2] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index aca2f7c..0c2222a 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,9 @@ const { shippingAddressRequired: false, userAction: 'commit', // display 'Pay Now' on the PayPal review page // one of 'authorize', 'sale', 'order'. defaults to 'authorize'. see details here: https://developer.paypal.com/docs/api/payments/v1/#payment-create-request-body - intent: 'authorize', + intent: 'authorize', + // support pay later offers. see details here: https://developer.paypal.com/braintree/docs/guides/paypal/pay-later-offers/android/v3 + offerPayLater: false, } );