Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ project.xcworkspace
# Android/IntelliJ
#
build/
.settings
.idea
.gradle
local.properties
Expand Down
6 changes: 6 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ repositories {
dependencies {
implementation 'com.braintreepayments.api:drop-in:4.+'
implementation 'com.facebook.react:react-native:+'
// Braintree dependencies
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better for users to make this a configuration step for using the library
Not everybody wants to have this in their code
See example of 3D Secure https://github.com/bamlab/react-native-braintree-payments-drop-in#3d-secure

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These library must be in library's gradle. If not, there will be an error like below
Screenshot at Nov 11 09-19-50

implementation 'com.braintreepayments.api:braintree:3.7.0'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After testing, you don't need to add this dependancy (it might be a sub deps of the drop-in)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you show me your testing without these dependencies? I still haven't figured out the way to do it

implementation 'com.braintreepayments.api:google-payment:3.2.0'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After testing, you don't need to add this dependancy (it might be a sub deps of the drop-in)


// Google dependencies
implementation 'com.google.android.gms:play-services-wallet:16.0.1'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't force the version

See example

}

// https://developers.braintreepayments.com/guides/3d-secure/migration/android/v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import android.app.Activity;
import android.content.Intent;

import com.braintreepayments.api.models.GooglePaymentRequest;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
Expand All @@ -17,6 +19,8 @@
import com.braintreepayments.api.models.PaymentMethodNonce;
import com.braintreepayments.api.models.CardNonce;
import com.braintreepayments.api.models.ThreeDSecureInfo;
import com.google.android.gms.wallet.TransactionInfo;
import com.google.android.gms.wallet.WalletConstants;

public class RNBraintreeDropInModule extends ReactContextBaseJavaModule {

Expand Down Expand Up @@ -47,6 +51,34 @@ public void show(final ReadableMap options, final Promise promise) {

DropInRequest dropInRequest = new DropInRequest().clientToken(options.getString("clientToken"));

if (options.hasKey("googlePay")) {
final ReadableMap googlePayOptions = options.getMap("googlePay");
if (!googlePayOptions.hasKey("amount")) {
promise.reject("NO_GOOGLE_PAY_AMOUNT", "You must provide an amount for Google Pay");
return;
}
if (!googlePayOptions.hasKey("currencyCode")) {
promise.reject("NO_GOOGLE_PAY_CURRENCY_CODE", "You must provide a currency code for Google Pay");
return;
}

GooglePaymentRequest googlePaymentRequest = new GooglePaymentRequest()
.transactionInfo(TransactionInfo.newBuilder()
.setTotalPrice(String.valueOf(googlePayOptions.getDouble("amount")))
.setTotalPriceStatus(WalletConstants.TOTAL_PRICE_STATUS_FINAL)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't that be configurable ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain more detail please?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be made in a follow-up PR, but apparently total price status can be changed to estimated or not known. This should be ideally an option in this bridge.

https://developers.google.com/android/reference/com/google/android/gms/wallet/WalletConstants.TotalPriceStatus.html

.setCurrencyCode(googlePayOptions.getString("currencyCode"))
.build());
if (googlePayOptions.hasKey("merchantID")) {
googlePaymentRequest.googleMerchantId(googlePayOptions.getString("merchantID"));
}
if (googlePayOptions.hasKey("merchantName")) {
googlePaymentRequest.googleMerchantName(googlePayOptions.getString("merchantName"));
}
dropInRequest.googlePaymentRequest(googlePaymentRequest);
} else {
dropInRequest.disableGooglePayment();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line really necessary, and if yes does it work when you remove the gradle deps that you added earlier?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is required to disable Google pay when developer doesn't pass "googlePay" parameter

}

if (options.hasKey("threeDSecure")) {
final ReadableMap threeDSecureOptions = options.getMap("threeDSecure");
if (!threeDSecureOptions.hasKey("amount")) {
Expand Down