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

Feature: add native getDeviceData method #37

Merged
merged 4 commits into from
Oct 6, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,15 @@ public void run3DSecureCheck(final ReadableMap parameters, final Promise promise
}
}

@ReactMethod
public void getDeviceData(final String clientToken, final Promise promise) {
setup(clientToken);
new DataCollector(mBraintreeClient).collectDeviceData(
mContext,
(result, e) -> promise.resolve(result));
}


private void handleThreeDSecureResult(ThreeDSecureResult threeDSecureResult, Exception error) {
if (error != null) {
handleError(error);
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ declare module '@ekreative/react-native-braintree' {
tokenizeCard(options: TokenizeCardOptions): Promise<BraintreeResponse>;
runApplePay(options: RunApplePayOptions): Promise<BraintreeResponse>;
requestPayPalBillingAgreement(options: PayPalBillingAgreementOptions): Promise<BraintreeResponse>;
getDeviceData(clientToken: string): Promise<string>;
}

const RNBraintree: RNBraintreeModule;
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export default {
tokenizeCard: RNBraintree.tokenizeCard,
runApplePay: RNBraintreeApplePay && RNBraintreeApplePay.runApplePay,
requestPayPalBillingAgreement: RNBraintree.requestPayPalBillingAgreement,
getDeviceData: RNBraintree.getDeviceData,
}
10 changes: 10 additions & 0 deletions ios/RNBraintree.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ @implementation RNBraintree
rejecter:reject];
}

RCT_EXPORT_METHOD(getDeviceData: (NSString *) clientToken
resolver: (RCTPromiseResolveBlock)resolve
rejecter: (RCTPromiseRejectBlock)reject) {
self.apiClient = [[BTAPIClient alloc] initWithAuthorization: clientToken];
self.dataCollector = [[BTDataCollector alloc] initWithAPIClient:self.apiClient];
[self.dataCollector collectDeviceData:^(NSString * _Nonnull deviceData) {
resolve(deviceData);
}];
}

#pragma mark - 3D Secure
- (void)startPaymentFlow: (NSDictionary *)parameters
resolver: (RCTPromiseResolveBlock)resolve
Expand Down