Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #93 from ShortboxedInc/fix-ios
Browse files Browse the repository at this point in the history
fix: Fix build issue with both iOS and Android
  • Loading branch information
vasylnahuliak authored Aug 16, 2024
2 parents d6170dd + b2669f9 commit e52aeaa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,16 @@ public void showPayPalModule(final ReadableMap parameters, final Promise promise
if (parameters.hasKey("currencyCode")) {
currency = parameters.getString("currencyCode");
}
if (parameters.hasKey("userAction") && PayPalCheckoutRequest.USER_ACTION_COMMIT.equals(parameters.getString("userAction"))) {
request.setUserAction(PayPalCheckoutRequest.USER_ACTION_COMMIT);
}
if (mCurrentActivity != null) {
mPayPalClient = new PayPalClient(mBraintreeClient);
PayPalCheckoutRequest request = new PayPalCheckoutRequest(
parameters.getString("amount")
);
request.setCurrencyCode(currency);
request.setIntent(PayPalPaymentIntent.AUTHORIZE);
if (parameters.hasKey("userAction") && PayPalCheckoutRequest.USER_ACTION_COMMIT.equals(parameters.getString("userAction"))) {
request.setUserAction(PayPalCheckoutRequest.USER_ACTION_COMMIT);
}
mPayPalClient.tokenizePayPalAccount(
mCurrentActivity,
request,
Expand Down
8 changes: 4 additions & 4 deletions ios/RNBraintree.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ @implementation RNBraintree
NSString *clientToken = options[@"clientToken"];
NSString *amount = options[@"amount"];
NSString *currencyCode = options[@"currencyCode"];
NSString *userAction = options[@"userAction"];

self.apiClient = [[BTAPIClient alloc] initWithAuthorization: clientToken];
self.dataCollector = [[BTDataCollector alloc] initWithAPIClient:self.apiClient];
BTPayPalDriver *payPalDriver = [[BTPayPalDriver alloc] initWithAPIClient: self.apiClient];

BTPayPalCheckoutRequest *request= [[BTPayPalCheckoutRequest alloc] initWithAmount:amount];
request.currencyCode = currencyCode;
if (userAction && [@"commit" isEqualToString:userAction]) {
request.userAction = BTPayPalRequestUserActionCommit;
}
[payPalDriver tokenizePayPalAccountWithPayPalRequest:request completion:^(BTPayPalAccountNonce * _Nullable tokenizedPayPalAccount, NSError * _Nullable error) {
if (error) {
reject(@"ONE_TIME_PAYMENT_FAILED", error.localizedDescription, nil);
Expand All @@ -50,7 +54,6 @@ @implementation RNBraintree
rejecter: (RCTPromiseRejectBlock)reject) {
NSString *clientToken = options[@"clientToken"];
NSString *description = options[@"description"];
NSString *userAction = options[@"userAction"];

self.apiClient = [[BTAPIClient alloc] initWithAuthorization: clientToken];
self.dataCollector = [[BTDataCollector alloc] initWithAPIClient:self.apiClient];
Expand All @@ -60,9 +63,6 @@ @implementation RNBraintree
if (description) {
request.billingAgreementDescription = description;
}
if (userAction && [@"commit" isEqualToString:userAction]) {
request.userAction = BTPayPalRequestUserActionCommit;
}
[payPalDriver tokenizePayPalAccountWithPayPalRequest:request completion:^(BTPayPalAccountNonce * _Nullable tokenizedPayPalAccount, NSError * _Nullable error) {
if (error) {
reject(@"REQUEST_BILLING_AGREEMENT_FAILED", error.localizedDescription, nil);
Expand Down

0 comments on commit e52aeaa

Please sign in to comment.