-
Notifications
You must be signed in to change notification settings - Fork 29
Update Google Pay #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
646f2c7
4560f3f
7ee5784
56a9e6a
52fbd13
1c0d3c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,7 @@ project.xcworkspace | |
| # Android/IntelliJ | ||
| # | ||
| build/ | ||
| .settings | ||
| .idea | ||
| .gradle | ||
| local.properties | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,12 @@ repositories { | |
| dependencies { | ||
| implementation 'com.braintreepayments.api:drop-in:4.+' | ||
| implementation 'com.facebook.react:react-native:+' | ||
| // Braintree dependencies | ||
| implementation 'com.braintreepayments.api:braintree:3.7.0' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -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 { | ||
|
|
||
|
|
@@ -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) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't that be configurable ?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you explain more detail please?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| .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(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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")) { | ||
|
|
||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
