开发文档:https://developers.braintreepayments.com
1.Start
https://developers.braintreepayments.com/start/overview
准备工作:
注册沙盒账户:https://www.braintreepayments.com/sandbox
Create a Braintree Sandbox account to manage payments: fecmall fec~-1-3
沙盒信息:
Merchant ID: jjcy2pxvfgx4j5h6
Public Key: xmps59v4q6g5pwpy
Private Key: 757b5be1c91647fd1af83964b53b0025
2.工作原理
https://developers.braintreepayments.com/start/overview

Step 1:
Your front-end requests a client token from your server and initializes the client SDK.
客户端(譬如浏览器等客户端)请求服务端,发送一个获取client toke
的请求,并且初始化客户端sdk
Step 2:
Your server generates and sends a client token back to your client using the server SDK.
服务端通过sdk生成client toke
,发给客户端,
Step 3:
The customer submits payment information, the client SDK communicates that information to Braintree and returns a payment method nonce.
客户端提交支付信息,客户端SDK将该信息传达给Braintree,Braintree接收请求后,将 支付方式随机数
发送给客户端。
Step 4:
Your front-end sends the payment method nonce to your server.
客户端将第3步返回的 支付方式随机数
发送给服务端
Step 5:
Your server code receives the payment method nonce and then uses the server SDK to create a transaction
服务端接收客户端发送的 支付方式随机数
,然后通过服务端sdk生成一个订单交易。
Authorization(服务端授权)
https://developers.braintreepayments.com/guides/authorization/overview
A tokenization key
is a lightweight reusable value that authorizes payment method tokenization.(游客下单使用)
A client token
is a short-lived value that authorizes payment method tokenization, payment method retrieval, and client-side vaulting.(登陆用户下单使用)
如果您的用户下单必须是登陆用户,使用 client token
即可
前端商城UI
https://developers.braintreepayments.com/start/drop-in
JavaScript Drop-in UI
生成后的演示地址:https://codepen.io/braintree/pen/c77480f28c18484e8cd7748c8fe4fe84