简体   繁体   中英

PayPal: Refund money from Payment

I am using the paypal API for .NET and I am creating a payment via method: POST /v1/payments/payment.

My payment create request:

Payment = {
  intent: 'sale',
  payer = {
    payment_method = 'paypal'
  },
  transactions = [
    transaction= = {
      amount = {
        currency = 'GBP',
        total = '10.00'
      },
      item_list = {
        items = [
          item = {
            quantity = '1',
            name = 'name',
            price = '10.00',
            currency = 'GBP',
            sku = 'description'
          }
        ],
        shipping_address = {
          recipient_name = 'name',
          line1 = 'address',
          city = 'city',
          country_code = 'GB',
          postal_code = 'G69 7LS'
        }
      }
    }
  ],
  redirect_urls = {
    return_url = 'http://localhost/',
    cancel_url = 'http://localhost/'
  }
}

As you can see, I"m not creating a related transaction of the type "sale".

After the payment is created and executed, in some cases we need to return the client's money, but to make a refund we need a saleId. I tried to generate a saleId through the payment creation, but it still fails because the sale object seems to be ignored by the API.

After you make this call, PayPal returns a link to direct the customer to PayPal. After that, it returns to the return URL you specified. You then perform an execute payment call:

https://api.sandbox.paypal.com/v1/payments/payment/<Payment-Id>/execute/

In that response will be the information you are looking for.

Response=>transactions=>related_resources=>sale=>id is the variable with the id.

In addition, Response=>transactions=>related_resources=>links will have a link for refunding the transaction.

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