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
10 changes: 5 additions & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ repositories {
}

dependencies {
implementation 'com.braintreepayments.api:drop-in:4.+'
implementation 'com.braintreepayments.api:drop-in:5.+'
implementation 'com.facebook.react:react-native:+'
}

// https://developers.braintreepayments.com/guides/3d-secure/migration/android/v3
rootProject.allprojects {
repositories {
maven {
url "https://cardinalcommerce.bintray.com/android"
url "https://cardinalcommerceprod.jfrog.io/artifactory/android"
credentials {
username 'braintree-team-sdk@cardinalcommerce'
password '220cc9476025679c4e5c843666c27d97cfb0f951'
username 'braintree_team_sdk'
password 'AKCp8jQcoDy2hxSWhDAUQKXLDPDx6NYRkqrgFLRc3qDrayg6rrCbJpsKKyMwaykVL8FWusJpp'
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@
import com.braintreepayments.api.models.PaymentMethodNonce;
import com.braintreepayments.api.models.CardNonce;
import com.braintreepayments.api.models.ThreeDSecureInfo;
import com.braintreepayments.api.models.ThreeDSecureAdditionalInformation;
import com.braintreepayments.api.models.ThreeDSecurePostalAddress;
import com.braintreepayments.api.models.ThreeDSecureRequest;




public class RNBraintreeDropInModule extends ReactContextBaseJavaModule {

private Promise mPromise;
private static final int DROP_IN_REQUEST = 0x444;

private boolean isVerifyingThreeDSecure = false;

public RNBraintreeDropInModule(ReactApplicationContext reactContext) {
Expand All @@ -45,7 +51,10 @@ public void show(final ReadableMap options, final Promise promise) {
return;
}



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


if (options.hasKey("threeDSecure")) {
final ReadableMap threeDSecureOptions = options.getMap("threeDSecure");
Expand All @@ -56,9 +65,66 @@ public void show(final ReadableMap options, final Promise promise) {

isVerifyingThreeDSecure = true;

String amount = String.valueOf(threeDSecureOptions.getDouble("amount"));

ThreeDSecureRequest threeDSecureRequest = new ThreeDSecureRequest()
.amount(amount)
.versionRequested(ThreeDSecureRequest.VERSION_2);

if (threeDSecureOptions.hasKey("email")) {
threeDSecureRequest.email(threeDSecureOptions.getString("email"));
}

if (threeDSecureOptions.hasKey("billingAddress")) {
final ReadableMap threeDSecureBillingAddress = threeDSecureOptions.getMap("billingAddress");
ThreeDSecurePostalAddress billingAddress = new ThreeDSecurePostalAddress();

if (threeDSecureBillingAddress.hasKey("givenName")) {
billingAddress.givenName(threeDSecureBillingAddress.getString("givenName"));
}

if (threeDSecureBillingAddress.hasKey("surname")) {
billingAddress.surname(threeDSecureBillingAddress.getString("surname"));
}

if (threeDSecureBillingAddress.hasKey("streetAddress")) {
billingAddress.streetAddress(threeDSecureBillingAddress.getString("streetAddress"));
}

if (threeDSecureBillingAddress.hasKey("extendedAddress")) {
billingAddress.extendedAddress(threeDSecureBillingAddress.getString("extendedAddress"));
}

if (threeDSecureBillingAddress.hasKey("locality")) {
billingAddress.locality(threeDSecureBillingAddress.getString("locality"));
}

if (threeDSecureBillingAddress.hasKey("region")) {
billingAddress.region(threeDSecureBillingAddress.getString("region"));
}

if (threeDSecureBillingAddress.hasKey("postalCode")) {
billingAddress.postalCode(threeDSecureBillingAddress.getString("postalCode"));
}

if (threeDSecureBillingAddress.hasKey("phoneNumber")) {
billingAddress.phoneNumber(threeDSecureBillingAddress.getString("phoneNumber"));
}

billingAddress.countryCodeAlpha2(threeDSecureBillingAddress.getString("MY"));

threeDSecureRequest.billingAddress(billingAddress);
// For best results, provide as many additional elements as possible.
ThreeDSecureAdditionalInformation additionalInformation = new ThreeDSecureAdditionalInformation()
.shippingAddress(billingAddress);
}

dropInRequest
.amount(String.valueOf(threeDSecureOptions.getDouble("amount")))
.threeDSecureRequest(threeDSecureRequest)
.amount(amount)
.requestThreeDSecureVerification(true);


}

mPromise = promise;
Expand Down
54 changes: 51 additions & 3 deletions ios/RNBraintreeDropIn.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#import "RNBraintreeDropIn.h"
#import <React/RCTUtils.h>
#import "BTThreeDSecureRequest.h"
#import "BTThreeDSecurePostalAddress.h"
#import "BTThreeDSecureAdditionalInformation.h"

@implementation RNBraintreeDropIn

Expand Down Expand Up @@ -27,16 +31,60 @@ - (dispatch_queue_t)methodQueue
return;
}

request.threeDSecureVerification = YES;
request.amount = [threeDSecureAmount stringValue];
BTThreeDSecureRequest *threeDSecureRequest = [[BTThreeDSecureRequest alloc] init];
threeDSecureRequest.amount = [NSDecimalNumber decimalNumberWithString:threeDSecureAmount.stringValue];
threeDSecureRequest.versionRequested = BTThreeDSecureVersion2;

NSString *threeDSecureEmail = threeDSecureOptions[@"email"];
if(threeDSecureEmail){
threeDSecureRequest.email = threeDSecureEmail;
}

NSDictionary* threeDSecureBillingAddress = threeDSecureOptions[@"billingAddress"];
if(threeDSecureBillingAddress){
BTThreeDSecurePostalAddress *billingAddress = [BTThreeDSecurePostalAddress new];
// BTThreeDSecurePostalAddress *billingAddress = [[BTThreeDSecurePostalAddress alloc] init];

if(threeDSecureBillingAddress[@"givenName"]){
billingAddress.givenName = threeDSecureBillingAddress[@"givenName"];
}
if(threeDSecureBillingAddress[@"surname"]){
billingAddress.surname = threeDSecureBillingAddress[@"surname"];
}
if(threeDSecureBillingAddress[@"streetAddress"]){
billingAddress.streetAddress = threeDSecureBillingAddress[@"streetAddress"];
}
if(threeDSecureBillingAddress[@"extendedAddress"]){
billingAddress.extendedAddress = threeDSecureBillingAddress[@"extendedAddress"];
}
if(threeDSecureBillingAddress[@"locality"]){
billingAddress.locality = threeDSecureBillingAddress[@"locality"];
}
if(threeDSecureBillingAddress[@"region"]){
billingAddress.region = threeDSecureBillingAddress[@"region"];
}
if(threeDSecureBillingAddress[@"countryCodeAlpha2"]){
billingAddress.countryCodeAlpha2 = threeDSecureBillingAddress[@"countryCodeAlpha2"];
}
if(threeDSecureBillingAddress[@"postalCode"]){
billingAddress.postalCode = threeDSecureBillingAddress[@"postalCode"];
}
if(threeDSecureBillingAddress[@"phoneNumber"]){
billingAddress.phoneNumber = threeDSecureBillingAddress[@"phoneNumber"];
}
threeDSecureRequest.billingAddress = billingAddress;
}

request.threeDSecureRequest = threeDSecureRequest;

}

BTDropInController *dropIn = [[BTDropInController alloc] initWithAuthorization:clientToken request:request handler:^(BTDropInController * _Nonnull controller, BTDropInResult * _Nullable result, NSError * _Nullable error) {
[self.reactRoot dismissViewControllerAnimated:YES completion:nil];

if (error != nil) {
reject(error.localizedDescription, error.localizedDescription, error);
} else if (result.cancelled) {
} else if (result.canceled) {
reject(@"USER_CANCELLATION", @"The user cancelled", nil);
} else {
if (threeDSecureOptions && [result.paymentMethod isKindOfClass:[BTCardNonce class]]) {
Expand Down
4 changes: 2 additions & 2 deletions ios/RNBraintreeDropIn.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ Pod::Spec.new do |s|
s.license = "MIT"
# s.license = { :type => "MIT", :file => "../LICENSE" }
s.author = { "author" => "[email protected]" }
s.platform = :ios, "9.0"
s.platform = :ios, "12.0"
s.source = { :git => "https://github.com/bamlab/react-native-braintree-payments-drop-in.git", :tag => "master" }
s.source_files = "*.{h,m}"
s.requires_arc = true

s.dependency "React"
s.dependency "BraintreeDropIn", '~> 7.4'
s.dependency "BraintreeDropIn"
end
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "react-native-braintree-payments-drop-in",
"version": "1.2.0",
"version": "2.0.0",
"description": "React Native integration of Braintree Drop-in",
"main": "index.js",
"repository": {
"type": "git",
"url": "[email protected]:bamlab/react-native-braintree-payments-drop-in.git"
"url": "[email protected]:yoodomy/react-native-braintree-payments-drop-in.git"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down