我想建立一个网络应用,用户可以通过他们的paypal账户向另一个用户付款。
我想要的是类似这样的东西。https:/developer.paypal.comdemocheckout#patternclient(模式客户端)
一个页面,用户可以点击一个按钮,用Paypal或信用卡支付。给其他用户.但我看不到在这个例子中,我如何配置收件人账户。似乎付款是到我的帐户,但我想。向他选择的另一个用户支付的款项。.
我也找过这些API。https:/developer.paypal.comdocsapirest-sdks#。但无法找到一个例子,允许建立一个用户向另一个用户付款的客户端。当然,我需要得到确认,付款已经完成。
EDIT:
我已经尝试了这里的代码: https:/www.npmjs.compackage@paypalcheckout -server -sdk。
并更新添加了收款人字段。
exports.pay = function (req, res) {
// 1. Set up your server to make calls to PayPal
// 1a. Import the SDK package
const paypal = require('@paypal/checkout-server-sdk');
// 1b. Add your client ID and secret
const PAYPAL_CLIENT = 'xxx';
const PAYPAL_SECRET = 'yyy';
// 1c. Set up the SDK client
const env = new paypal.core.SandboxEnvironment(PAYPAL_CLIENT, PAYPAL_SECRET);
const client = new paypal.core.PayPalHttpClient(env);
// 2. Set up your server to receive a call from the client
// 3. Call PayPal to set up a transaction with payee
const request = new paypal.orders.OrdersCreateRequest();
request.requestBody({
"intent": "CAPTURE",
"purchase_units": [
{
"amount": {
"currency_code": "USD",
"value": "100.00"
},
"payee": {
"email_address": "[email protected]"
}
}
]
});
const createOrder = async function () {
const response = await client.execute(request);
console.log(`Response: ${JSON.stringify(response)}`);
// If call returns body in response, you can get the deserialized version from the result attribute of the response.
console.log(`Order: ${JSON.stringify(response.result)}`);
return res.status(200).json(response.result);
};
createOrder();
};
这将返回一个4个链接的列表。第二条似乎是要把客户重定向到(https:/www.sandbox.paypal.comcheckoutnow?token=9RM83779YH010823U). 但是,如果我去那里,我仍然无法在 "发送至 "中看到收款人地址([email protected])。
你想要的是设置一个 payee
对象。https:/developer.paypal.comdocscheckoutintegration-featurescustom-payee。