paypalOneTimePayment paypalBillingAgreement
isWalletAppInstalled authorizeAccountAndVault authorizeAccountWithProfileID collectDeviceData
Braintree 成立于 2007 年,在过去的几年里曾获得6900 万美元融资。成立后,Braintree发展速度迅猛,目前已有 4000 家商户在使用 Braintree 的支付系统,每年处理的交易额超过 100 亿美元之巨。Braintree通过向商户收取 2.9% 的佣金和 30 美分手续费获得盈利。Braintree能够为需要使用移动支付服务的公司提供一站式服务 Braintree
PayPal已经以8亿美元的现金收购了 Braintree。且 PayPal 已经将其移动端支付服务器全部转移到 Braintree 平台。
此原生插件封装了 Braintree 移动支付功能。
集成 Braintree 支付需要先在 PayPal 后台控制面板创建 App,详情参考 [Get Started] (https://developer.paypal.com/docs/accept-payments/express-checkout/ec-braintree-sdk/get-started/)
附:PayPal 服务器接入文档
创建 App 之后,需要获取授权 token。如下: A client token is a signed data blob that includes configuration and authorization information required by the Braintree client SDK. These should not be reused; a new client token should be generated for each request that's sent to Braintree. For security, we will revoke client tokens if they are reused excessively within a short time period.
Your server is responsible for generating the client token, which contains all of the necessary configuration information to set up the client SDKs. When your server provides a client token to your client, it authenticates the application to communicate directly to Braintree.
Your client is responsible for obtaining the client token from your server and initializing the client SDK.
支付流程简介
1.Your app or web front-end requests a client token from your server in order to initialize the client SDK
2.Your server generates and sends a client token back to your client with the server SDK
3.Once the client SDK is initialized and the customer has submitted payment information, the SDK communicates that information to Braintree, which returns a payment method nonce
4.You then send the payment method nonce to your server
5.Your server code receives the payment method nonce from your client and then uses the server SDK to create a transaction or perform other functions.
1.配置 config.xml 文件,配置完毕,需通过云端编译生效,配置方法如下:**
<feature name="braintreePay">
<param name="urlScheme" value="com.builder.zhushou.payments"/>
</feature>
字段描述:
urlScheme:(必须配置)用于实现应用间跳转及数据交换,This scheme must start with your app's Bundle ID and be dedicated to Braintree app switch returns. For example, if the app bundle ID is com.your-company.Your-App, then your URL scheme could be com.your-company.Your-App.payments(e.g. com.your-company.Your-App.payments://test).详见 官方文档。
2.必须添加白名单,如下:
<preference name="querySchemes" value="com.venmo.touch.v2" />
关于白名单解释详情参考 Yonbuilder 移动开发平台官方文档之-----白名单配置
关于 Venmo 参见Overview
开通 Venmo 详情参考Venmo Setup
关于 Venmo profiles ,以及 Multiple profiles
Server-Side Implementation
启动PayPal的单一支付
paypalOneTimePayment({params},callback(ret))
token:
amount:
currencyCode:
displayName:
endPage:
intent:
commitAction:
offerCredit:
address:
{
recipientName:'', //字符串类型;地址名称
streetAddress:'', //字符串类型;街道地址
extendedAddress:'', //字符串类型;扩展信息
locality:'', //字符串类型;地点
region:'', //字符串类型;区
countryCodeAlpha2:'', //字符串类型;国家代码
phoneNumber:'', //字符串类型;手机号码,仅支持Android端
postalCode:'' //字符串类型;,仅支持iOS端。Zip code or equivalent is usually required for countries that have them. For a list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code.
}
ret:
{
eventType:'success', //字符串类型;交互事件类型
//success:成功
//cancel:取消
//err:发生错误
PayPalAccountNonce: { //JSON对象;eventType 为 success 时有值
nonce: //字符串类型;
localizedDescription: //字符串类型;
type: //字符串类型;
isDefault: //布尔类型;
email: //字符串类型;
firstName: //字符串类型;
lastName: //字符串类型;
phone: //字符串类型;
clientMetadataId: //字符串类型;
payerId: //字符串类型;
}
}
err:
{
code:, //数字类型;错误码
msg:, //字符串类型;错误信息
}
var braintreePay = api.require('braintreePay');
braintreePay.paypalOneTimePayment({
token:'',
amount:'2.2',
intent:'sale',
}, function(ret, err) {
if (ret.eventType == 'success'){
api.alert({
msg: JSON.stringify(ret)
})
} else if (ret.eventType == 'cancel') {
alert('取消');
} else {
api.alert({
msg: JSON.stringify(err)
})
}
});
iOS 系统,Android系统
可提供的 1.0.0 及更高版本
启动PayPal的账单协议支付
paypalBillingAgreement({params},callback(ret))
token:
amount:
currencyCode:
displayName:
endPage:
intent:
commitAction:
offerCredit:
address:
{
recipientName:'', //字符串类型;地址名称
streetAddress:'', //字符串类型;街道地址
extendedAddress:'', //字符串类型;扩展信息
locality:'', //字符串类型;地点
region:'', //字符串类型;区
countryCodeAlpha2:'', //字符串类型;国家代码
phoneNumber:'', //字符串类型;手机号码,仅支持Android端
postalCode:'' //字符串类型;,仅支持iOS端。Zip code or equivalent is usually required for countries that have them. For a list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code.
}
ret:
{
eventType:'success', //字符串类型;交互事件类型
//success:成功
//cancel:取消
//err:发生错误
PayPalAccountNonce: { //JSON对象;eventType 为 success 时有值
nonce: //字符串类型;
localizedDescription: //字符串类型;
type: //字符串类型;
isDefault: //布尔类型;
email: //字符串类型;
firstName: //字符串类型;
lastName: //字符串类型;
phone: //字符串类型;
clientMetadataId: //字符串类型;
payerId: //字符串类型;
}
}
err:
{
code:, //数字类型;错误码
msg:, //字符串类型;错误信息
}
var braintreePay = api.require('braintreePay');
braintreePay.paypalBillingAgreement({
token:'',
amount:'2.2',
}, function(ret, err) {
if (ret.eventType == 'success'){
api.alert({
msg: JSON.stringify(ret)
})
} else if (ret.eventType == 'cancel') {
alert('取消');
} else {
api.alert({
msg: JSON.stringify(err)
})
}
});
iOS 系统,Android系统
可提供的 1.0.0 及更高版本
当前设备是否安装 了钱包应用
isWalletAppInstalled(callback(ret))
ret:
{
status: //布尔类型;是否安装
}
var braintreePay = api.require('braintreePay');
braintreePay.isWalletAppInstalled(function(ret, err) {
api.alert({
msg: JSON.stringify(ret)
})
});
iOS 系统,Android系统
可提供的 1.0.0 及更高版本
Initiates Venmo login via app switch, which returns a VenmoAccountNonce when successful.
authorizeAccountAndVault({params},callback(ret))
token:
vault:
ret:
{
eventType:'success', //字符串类型;交互事件类型
//success:成功
//cancel:取消
//err:发生错误
VenmoAccountNonce: { //JSON对象;eventType 为 success 时有值
nonce: //字符串类型;
localizedDescription: //字符串类型;
type: //字符串类型;
isDefault: //布尔类型;
}
}
err:
{
code:, //数字类型;错误码
msg:, //字符串类型;错误信息
}
var braintreePay = api.require('braintreePay');
braintreePay.authorizeAccountAndVault({
token:'',
vault:true
}, function(ret, err) {
api.alert({
msg: JSON.stringify(ret)
})
});
iOS 系统
可提供的 1.0.0 及更高版本
Initiates Venmo login via app switch, which returns a VenmoAccountNonce when successful.
authorizeAccountWithProfileID({params},callback(ret))
token:
vault:
profileID:
ret:
{
eventType:'success', //字符串类型;交互事件类型
//success:成功
//cancel:取消
//err:发生错误
VenmoAccountNonce: { //JSON对象;eventType 为 success 时有值
nonce: //字符串类型;
localizedDescription: //字符串类型;
type: //字符串类型;
isDefault: //布尔类型;
}
}
err:
{
code:, //数字类型;错误码
msg:, //字符串类型;错误信息
}
var braintreePay = api.require('braintreePay');
braintreePay.authorizeAccountWithProfileID({
token:'',
profileID:'',
}, function(ret, err) {
api.alert({
msg: JSON.stringify(ret)
})
});
iOS 系统
可提供的 1.0.0 及更高版本
获取设备信息,在服务器端进行 Venmo 扣款时需要
collectDeviceData({params},callback(ret))
ret:
{
status:, //布尔类型;正常回调
deviceData:'' //字符串类型;设备信息
}
var braintreePay = api.require('braintreePay');
braintreePay.collectDeviceData(function(ret) {
api.alert({
msg: JSON.stringify(ret)
})
});
iOS 系统
可提供的 1.0.0 及更高版本