简体   繁体   中英

Paypal .Net SDK payment API calls on behalf of third party Permission

I use Paypal .Net SDK ( https://github.com/paypal/PayPal-NET-SDK ) for payment API calls. It needs an APIContext object to be passed in API calls.

By using clientid and clientsecret of my paypal app, I can obtain accesstoken to create the APIContext object. But this makes payment into my merchant account.

I wanted to make payment and refund API calls on behalf of other merchants. For that I used Paypal Permission SDK ( https://github.com/paypal/permissions-sdk-dotnet ) to obatain permissions from Third Party Merchants. Once a merchant grants permission, I get token and secret. At this stage I cannot find any documentation how do I use that token and secret to call paypal API?

Can anyone guide me how to use that token and secret (received from permission API) to make valid APIContext, which can be used to call various paypal.net sdk API calls?

My answer is a bit late, but may help others as I found this question when searching for how to do this.

This applies if using the PayPal .NET SDK.

Create a PayPal.Api.Payee object and add this to your PayPal.Api.Transaction object that you use to make your payment.

Example 1:

var payee = new PayPal.Api.Payee()
{
    email = "test@example.com"
}

var transaction = new PayPal.Api.Transaction();
transaction.payee = payee;

Example 2:

var paypal = new PayPal.Api.Transaction()
{
    description = "Transaction description.",
    invoice_number = "123",
    amount = new Amount()
    {
        currency = "USD",
        total = "100.00",
        details = new Details()
        {
            tax = "0",
            shipping = "25.00",
            subtotal = "75.00"
        }
    },
    item_list = new ItemList()
    {
        items = new List<Item>()
        {
            new Item()
            {
                name = "title",
                currency = "USD",
                price = "75.00",
                quantity = "1",
                sku = "MySKU"
            }
        }
    },
    payee = new Payee()
    {
        email = "email@example.com"
    }
};

Instead of email you could use merchant_id or phone to identify the third party to receive the funds.

Note: the third party must have granted your PayPal application the appropriate permission for the type of transaction you are attempting.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM