

A react native interface for integrating payments using Braintree's v.zero SDK
source link: https://reactnativeexample.com/a-react-native-interface-for-integrating-payments-using-braintrees-v-zero-sdk/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

A react native interface for integrating payments using Braintree's v.zero SDK
react-native-braintree
A react native interface for integrating payments using Braintree's v.zero SDK.
Sample
Full Client + Server sample can be found here: https://github.com/alawong/BTRNSample
Usage
Setup
var BTClient = require('react-native-braintree');
BTClient.setup(<token>);
You can find a demo client token here.
Show Payment Screen
v.zero
BTClient.showPaymentViewController().then(function(nonce) {
//payment succeeded, pass nonce to server
})
.catch(function(err) {
//error handling
});
PayPal only
BTClient.showPayPalViewController().then(function(nonce) {
//payment succeeded, pass nonce to server
})
.catch(function(err) {
//error handling
});
Custom Integration
If you only want to tokenize credit card information, you can use the following:
BTClient.getCardNonce("4111111111111111", "10", "20").then(function(nonce) {
//payment succeeded, pass nonce to server
})
.catch(function(err) {
//error handling
});
One Touch
To take advantage of One Touch, there are additional setup required:
-
Register a URL scheme in Xcode (should always start with your Bundle ID)
-
Use setupWithURLScheme instead, passing the url scheme you have registered in previous step
var BTClient = require('react-native-braintree');
BTClient.setupWithURLScheme(<token>
,<url scheme>
); -
Add this delegate method (callback) to your AppDelegate.m
import
<RNBraintree.h>
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [[RNBraintree sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
-
Optionally, install the fake PayPal wallet app in your simulator to simulate and test responses
Installation
-
react-native init BTRNSample
(skip for existing projects) -
Run
npm install react-native-braintree --save
to add the package -
Inside the
ios/
directory, create a Podfile:Podfile for cocoapods 1.0
source 'https://github.com/CocoaPods/Specs.git'
target 'yourAppTarget' do
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'RCTImage',
'RCTNetwork',
'RCTText',
'RCTWebSocket'
]
pod 'react-native-braintree', :path => '../node_modules/react-native-braintree'
end
Or if you use an older CocoaPods version:
source 'https://github.com/CocoaPods/Specs.git'
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'RCTImage',
'RCTNetwork',
'RCTText',
'RCTWebSocket'
]
pod 'react-native-braintree', :path => '../node_modules/react-native-braintree'
- Run
pod install
. This installs the Braintree iOS SDK and a new workspace is created. - Open
BTRNSample.xcworkspace
- Under your app target -> build settings, look for
Other Linker Flags
and add$(inherited)
- Build and run project! If it fails the first time, clean and rebuild.
Because React Native's iOS code is now pulled in via CocoaPods, you also need to remove the React
, RCTImage
, etc. subprojects from your app's Xcode project.
Requirements
Tested with:
- Node 4.1.0
- npm 2.14.3
- react-native 0.8.0
GitHub
Recommend
-
11
Live Coding: Braintree Payment APISchedule time with mepowered by Calendly
-
13
Updating Braintree to the Latest Version in Xamarin Forms
-
9
Adding Swift Package Manager Support to the Braintree iOS SDKBy Susan Stevens and Sammy Cannil...
-
6
UI React Native Unofficial SDK for integrating MercadoPago PX Native UIs Jun 16, 2021...
-
10
react-native-braintree-android A react native interface for integrating Braintree's native Drop-in Payment UI for Android using Braintree's v.zero SDK.
-
4
How to Build a Robust Payment Processing Flow with Braintree (feat. BT Playground)By Sreeram Vasudevan and
-
6
V2EX › 程序员 有人做过 Braintree 对接 paypal 支付吗?遇到了点问题 loonie · 12 小时...
-
9
Integrating Firebase with React NativeFirebase is a Backend as a Service (BaaS) that provides an advantage to mobile developers who use React Native for developing mobile applications. As a React Native developer, by using Firebase y...
-
6
React Native — Integrating third-party librariesDesign by Kumkum Jain
-
6
@ekreative/react-native-braintree Getting started Android Specific Add this to your build.gradle allprojects {...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK