init
This commit is contained in:
@@ -71,10 +71,13 @@ dependencies {
|
|||||||
implementation "com.facebook.react:react-native:+"
|
implementation "com.facebook.react:react-native:+"
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.8.21"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.8.21"
|
||||||
|
|
||||||
// Braintree Dependencies - Latest versions
|
// Braintree
|
||||||
implementation 'com.braintreepayments.api:drop-in:6.16.0'
|
implementation 'com.braintreepayments.api:drop-in:6.16.0'
|
||||||
implementation 'com.braintreepayments.api:card:4.45.0'
|
implementation 'com.braintreepayments.api:card:4.45.0'
|
||||||
implementation 'com.braintreepayments.api:data-collector:4.45.0'
|
implementation 'com.braintreepayments.api:data-collector:4.45.0'
|
||||||
implementation 'com.braintreepayments.api:google-pay:4.45.0'
|
implementation 'com.braintreepayments.api:google-pay:4.45.0'
|
||||||
implementation 'com.braintreepayments.api:venmo:4.45.0'
|
implementation 'com.braintreepayments.api:venmo:4.45.0'
|
||||||
|
|
||||||
|
// Google Pay
|
||||||
|
implementation 'com.google.android.gms:play-services-wallet:19.2.1'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ import BraintreeDropIn, {
|
|||||||
const BRAINTREE_CLIENT_TOKEN = 'sandbox_g42y39zw_348pk9cgf3bgyw2b';
|
const BRAINTREE_CLIENT_TOKEN = 'sandbox_g42y39zw_348pk9cgf3bgyw2b';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [paymentResult, setPaymentResult] = useState<PaymentResult | null>(null);
|
const [paymentResult, setPaymentResult] = useState<PaymentResult | null>(
|
||||||
|
null
|
||||||
|
);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [deviceData, setDeviceData] = useState<string>('');
|
const [deviceData, setDeviceData] = useState<string>('');
|
||||||
|
|
||||||
@@ -42,7 +44,10 @@ const App = () => {
|
|||||||
|
|
||||||
const result = await BraintreeDropIn.show(options);
|
const result = await BraintreeDropIn.show(options);
|
||||||
setPaymentResult(result);
|
setPaymentResult(result);
|
||||||
showAlert('Success!', `Payment nonce received: ${result.nonce.substring(0, 20)}...`);
|
showAlert(
|
||||||
|
'Success!',
|
||||||
|
`Payment nonce received: ${result.nonce.substring(0, 20)}...`
|
||||||
|
);
|
||||||
console.log('Payment Result:', result);
|
console.log('Payment Result:', result);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
if (error.message === 'USER_CANCELLATION') {
|
if (error.message === 'USER_CANCELLATION') {
|
||||||
@@ -96,7 +101,10 @@ const App = () => {
|
|||||||
// Test 3: Google Pay (Android only)
|
// Test 3: Google Pay (Android only)
|
||||||
const handleGooglePay = async () => {
|
const handleGooglePay = async () => {
|
||||||
if (Platform.OS !== 'android') {
|
if (Platform.OS !== 'android') {
|
||||||
showAlert('Android Only', 'Google Pay is only available on Android devices');
|
showAlert(
|
||||||
|
'Android Only',
|
||||||
|
'Google Pay is only available on Android devices'
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,10 +142,10 @@ const App = () => {
|
|||||||
try {
|
try {
|
||||||
const options: DropInOptions = {
|
const options: DropInOptions = {
|
||||||
clientToken: BRAINTREE_CLIENT_TOKEN,
|
clientToken: BRAINTREE_CLIENT_TOKEN,
|
||||||
orderTotal: 100.00,
|
orderTotal: 100.0,
|
||||||
currencyCode: 'USD',
|
currencyCode: 'USD',
|
||||||
threeDSecure: {
|
threeDSecure: {
|
||||||
amount: 100.00,
|
amount: 100.0,
|
||||||
},
|
},
|
||||||
venmo: true,
|
venmo: true,
|
||||||
payPal: true,
|
payPal: true,
|
||||||
@@ -192,7 +200,9 @@ const App = () => {
|
|||||||
const handleCollectDeviceData = async () => {
|
const handleCollectDeviceData = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const data = await BraintreeDropIn.collectDeviceData(BRAINTREE_CLIENT_TOKEN);
|
const data = await BraintreeDropIn.collectDeviceData(
|
||||||
|
BRAINTREE_CLIENT_TOKEN
|
||||||
|
);
|
||||||
setDeviceData(data);
|
setDeviceData(data);
|
||||||
showAlert('Device Data Collected', `Length: ${data.length} characters`);
|
showAlert('Device Data Collected', `Length: ${data.length} characters`);
|
||||||
console.log('Device Data:', data.substring(0, 100) + '...');
|
console.log('Device Data:', data.substring(0, 100) + '...');
|
||||||
@@ -234,7 +244,7 @@ const App = () => {
|
|||||||
const options: DropInOptions = {
|
const options: DropInOptions = {
|
||||||
clientToken: BRAINTREE_CLIENT_TOKEN,
|
clientToken: BRAINTREE_CLIENT_TOKEN,
|
||||||
vaultManager: true,
|
vaultManager: true,
|
||||||
orderTotal: 25.00,
|
orderTotal: 25.0,
|
||||||
currencyCode: 'USD',
|
currencyCode: 'USD',
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -299,7 +309,6 @@ const App = () => {
|
|||||||
<ScrollView
|
<ScrollView
|
||||||
contentContainerStyle={styles.scrollContent}
|
contentContainerStyle={styles.scrollContent}
|
||||||
showsVerticalScrollIndicator={false}>
|
showsVerticalScrollIndicator={false}>
|
||||||
|
|
||||||
<View style={styles.header}>
|
<View style={styles.header}>
|
||||||
<Text style={styles.title}>Braintree Drop-In</Text>
|
<Text style={styles.title}>Braintree Drop-In</Text>
|
||||||
<Text style={styles.subtitle}>React Native Turbo Module Example</Text>
|
<Text style={styles.subtitle}>React Native Turbo Module Example</Text>
|
||||||
@@ -389,7 +398,9 @@ const App = () => {
|
|||||||
|
|
||||||
<View style={styles.resultRow}>
|
<View style={styles.resultRow}>
|
||||||
<Text style={styles.resultLabel}>Description:</Text>
|
<Text style={styles.resultLabel}>Description:</Text>
|
||||||
<Text style={styles.resultValue}>{paymentResult.description}</Text>
|
<Text style={styles.resultValue}>
|
||||||
|
{paymentResult.description}
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={styles.resultRow}>
|
<View style={styles.resultRow}>
|
||||||
@@ -432,7 +443,6 @@ const App = () => {
|
|||||||
⚠️ Remember to replace BRAINTREE_CLIENT_TOKEN with your actual token
|
⚠️ Remember to replace BRAINTREE_CLIENT_TOKEN with your actual token
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</SafeAreaView>
|
</SafeAreaView>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeRNBraintreeDropIn.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAgDpCC,gCAAmB,CAACC,YAAY,CAAO,mBAAmB,CAAC","ignoreList":[]}
|
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeRNBraintreeDropIn.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAkDpCC,gCAAmB,CAACC,YAAY,CAAO,mBAAmB,CAAC","ignoreList":[]}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"names":["_NativeRNBraintreeDropIn","_interopRequireDefault","require","e","__esModule","default","BraintreeDropIn","show","options","NativeRNBraintreeDropIn","fetchMostRecentPaymentMethod","clientToken","tokenizeCard","cardInfo","collectDeviceData","exports"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAgE,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAKjD,MAAMG,eAAe,CAAC;EACnC;AACF;AACA;AACA;AACA;EACE,OAAOC,IAAIA,CAACC,OAAsB,EAA0B;IAC1D,OAAOC,gCAAuB,CAACF,IAAI,CAACC,OAAO,CAAC;EAC9C;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAOE,4BAA4BA,CACjCC,WAAmB,EACY;IAC/B,OAAOF,gCAAuB,CAACC,4BAA4B,CAACC,WAAW,CAAC;EAC1E;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,OAAOC,YAAYA,CACjBD,WAAmB,EACnBE,QAAkB,EACM;IACxB,OAAOJ,gCAAuB,CAACG,YAAY,CAACD,WAAW,EAAEE,QAAQ,CAAC;EACpE;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAOC,iBAAiBA,CAACH,WAAmB,EAAmB;IAC7D,OAAOF,gCAAuB,CAACK,iBAAiB,CAACH,WAAW,CAAC;EAC/D;AACF;AAACI,OAAA,CAAAV,OAAA,GAAAC,eAAA","ignoreList":[]}
|
{"version":3,"names":["_NativeRNBraintreeDropIn","_interopRequireDefault","require","e","__esModule","default","BraintreeDropIn","show","options","NativeRNBraintreeDropIn","fetchMostRecentPaymentMethod","clientToken","tokenizeCard","cardInfo","collectDeviceData","exports"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAgE,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AASjD,MAAMG,eAAe,CAAC;EACnC;AACF;AACA;AACA;AACA;EACE,OAAOC,IAAIA,CAACC,OAAsB,EAA0B;IAC1D,OAAOC,gCAAuB,CAACF,IAAI,CAACC,OAAO,CAAC;EAC9C;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAOE,4BAA4BA,CACjCC,WAAmB,EACY;IAC/B,OAAOF,gCAAuB,CAACC,4BAA4B,CAACC,WAAW,CAAC;EAC1E;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,OAAOC,YAAYA,CACjBD,WAAmB,EACnBE,QAAkB,EACM;IACxB,OAAOJ,gCAAuB,CAACG,YAAY,CAACD,WAAW,EAAEE,QAAQ,CAAC;EACpE;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAOC,iBAAiBA,CAACH,WAAmB,EAAmB;IAC7D,OAAOF,gCAAuB,CAACK,iBAAiB,CAACH,WAAW,CAAC;EAC/D;AACF;AAACI,OAAA,CAAAV,OAAA,GAAAC,eAAA","ignoreList":[]}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeRNBraintreeDropIn.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,cAAc;AAgDlD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,mBAAmB,CAAC","ignoreList":[]}
|
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeRNBraintreeDropIn.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,cAAc;AAkDlD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,mBAAmB,CAAC","ignoreList":[]}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"names":["NativeRNBraintreeDropIn","BraintreeDropIn","show","options","fetchMostRecentPaymentMethod","clientToken","tokenizeCard","cardInfo","collectDeviceData"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,OAAOA,uBAAuB,MAAM,2BAA2B;AAK/D,eAAe,MAAMC,eAAe,CAAC;EACnC;AACF;AACA;AACA;AACA;EACE,OAAOC,IAAIA,CAACC,OAAsB,EAA0B;IAC1D,OAAOH,uBAAuB,CAACE,IAAI,CAACC,OAAO,CAAC;EAC9C;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAOC,4BAA4BA,CACjCC,WAAmB,EACY;IAC/B,OAAOL,uBAAuB,CAACI,4BAA4B,CAACC,WAAW,CAAC;EAC1E;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,OAAOC,YAAYA,CACjBD,WAAmB,EACnBE,QAAkB,EACM;IACxB,OAAOP,uBAAuB,CAACM,YAAY,CAACD,WAAW,EAAEE,QAAQ,CAAC;EACpE;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAOC,iBAAiBA,CAACH,WAAmB,EAAmB;IAC7D,OAAOL,uBAAuB,CAACQ,iBAAiB,CAACH,WAAW,CAAC;EAC/D;AACF","ignoreList":[]}
|
{"version":3,"names":["NativeRNBraintreeDropIn","BraintreeDropIn","show","options","fetchMostRecentPaymentMethod","clientToken","tokenizeCard","cardInfo","collectDeviceData"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,OAAOA,uBAAuB,MAAM,2BAA2B;AAS/D,eAAe,MAAMC,eAAe,CAAC;EACnC;AACF;AACA;AACA;AACA;EACE,OAAOC,IAAIA,CAACC,OAAsB,EAA0B;IAC1D,OAAOH,uBAAuB,CAACE,IAAI,CAACC,OAAO,CAAC;EAC9C;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAOC,4BAA4BA,CACjCC,WAAmB,EACY;IAC/B,OAAOL,uBAAuB,CAACI,4BAA4B,CAACC,WAAW,CAAC;EAC1E;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,OAAOC,YAAYA,CACjBD,WAAmB,EACnBE,QAAkB,EACM;IACxB,OAAOP,uBAAuB,CAACM,YAAY,CAACD,WAAW,EAAEE,QAAQ,CAAC;EACpE;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAOC,iBAAiBA,CAACH,WAAmB,EAAmB;IAC7D,OAAOL,uBAAuB,CAACQ,iBAAiB,CAACH,WAAW,CAAC;EAC/D;AACF","ignoreList":[]}
|
||||||
|
|||||||
@@ -39,11 +39,12 @@ Pod::Spec.new do |s|
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Braintree Dependencies
|
# Braintree Dependencies
|
||||||
# s.dependency 'Braintree', '~> 6.0'
|
s.dependency 'BraintreeDropIn', '9.12.2'
|
||||||
# s.dependency 'BraintreeDropIn', '~> 9.0'
|
s.dependency 'Braintree/Core', '5.26.0'
|
||||||
# s.dependency 'Braintree/DataCollector', '~> 6.0'
|
s.dependency 'Braintree/Card', '5.26.0'
|
||||||
# s.dependency 'Braintree/ApplePay', '~> 6.0'
|
s.dependency 'Braintree/DataCollector', '5.26.0'
|
||||||
# s.dependency 'Braintree/Venmo', '~> 6.0'
|
s.dependency 'Braintree/ApplePay', '5.26.0'
|
||||||
|
s.dependency 'Braintree/Venmo', '5.26.0'
|
||||||
|
|
||||||
s.swift_version = '5.0'
|
s.swift_version = '5.0'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -42,7 +42,9 @@ export interface PaymentResult {
|
|||||||
|
|
||||||
export interface Spec extends TurboModule {
|
export interface Spec extends TurboModule {
|
||||||
show(options: DropInOptions): Promise<PaymentResult>;
|
show(options: DropInOptions): Promise<PaymentResult>;
|
||||||
fetchMostRecentPaymentMethod(clientToken: string): Promise<PaymentResult | null>;
|
fetchMostRecentPaymentMethod(
|
||||||
|
clientToken: string
|
||||||
|
): Promise<PaymentResult | null>;
|
||||||
tokenizeCard(clientToken: string, cardInfo: CardInfo): Promise<PaymentResult>;
|
tokenizeCard(clientToken: string, cardInfo: CardInfo): Promise<PaymentResult>;
|
||||||
collectDeviceData(clientToken: string): Promise<string>;
|
collectDeviceData(clientToken: string): Promise<string>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
import NativeRNBraintreeDropIn from './NativeRNBraintreeDropIn';
|
import NativeRNBraintreeDropIn from './NativeRNBraintreeDropIn';
|
||||||
import type { DropInOptions, CardInfo, PaymentResult } from './NativeRNBraintreeDropIn';
|
import type {
|
||||||
|
DropInOptions,
|
||||||
|
CardInfo,
|
||||||
|
PaymentResult,
|
||||||
|
} from './NativeRNBraintreeDropIn';
|
||||||
|
|
||||||
export type { DropInOptions, CardInfo, PaymentResult };
|
export type { DropInOptions, CardInfo, PaymentResult };
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user