贝宝P2P付款API

时间:2020-04-27 08:43:14

标签: paypal p2p

我想构建一个Web应用程序,使用户可以通过其Paypal帐户向其他用户付款。

我想要的东西与此类似: https://developer.paypal.com/demo/checkout/#/pattern/client

用户可在该页面上单击按钮以使用Paypal或信用卡向另一用户付款。 但是我看不到如何在此示例中配置接收者帐户。似乎已经向我的帐户付款了,但是我希望向他选择的另一个用户付款

我还查看了所有这些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)。

Paypal wrong send to

1 个答案:

答案 0 :(得分:0)