我想建立一个网络应用程序,用户可以通过他们的paypal帐户支付给其他用户。
我想要的是类似于此的东西:https://developer.paypal.com/demo/checkout/#/pattern/client
一个页面,用户可以点击一个按钮,要么用贝宝支付,要么信用卡,到另一个用户。但我看不出在本例中如何配置接收方帐户。似乎是付款到我的帐户,但我希望的付款要支付给另一个用户,他选择。
我还查看了所有这些API:https://developer.paypal.com/docs/api/rest-sdks/#,但无法找到允许在用户向另一个用户付费的情况下构建客户端的示例。当然,我需要得到付款已经完成的确认。
编辑:
我已经尝试过这里的代码:https://www.npmjs.com/package/@paypal/checkout-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": "payee@gmail.com"
}
}
]
});
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.com/checkoutnow?token=9RM83779YH010823U)的那个。但是,如果我去那里,我仍然看不到收款人地址(payee@gmail.com)在“发送到”。

发布于 2020-04-27 09:25:25
https://stackoverflow.com/questions/61454900
复制相似问题