PayPal:从支付中退款

问题描述:

我使用.NET的paypal API,并通过方法创建付款:POST/v1/payments/payment。PayPal:从支付中退款

我的付款创建要求:

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/' 
    } 
} 

正如你所看到的,我的“M没有创造类型的关联交易‘买卖’

创建并执行付款后,一些。我们需要退还客户的资金,但为了退款,我们需要一个saleId。我试图通过付款创建生成一个saleId,但它仍然失败,因为销售对象似乎被API忽略。

+0

不能流利地使用API​​(所以如果我错过了一个细节,请谅解),但根据[文档](https://developer.paypal.com/docs/api/#execute-an-approved-paypal-支付),你应该收到一个'[response] .transactions.related_resources.sale.id',它将被传回[退款](https://developer.paypal.com/docs/api/#refund-a-sale )。当你说忽略时,响应中是否缺少'[response] .transactions.related_resources.sale'? –

+0

支付是作为答案给出的,它带有一个空数组payment_resources。 –

在您拨打此电话后,PayPal会返回一个指向di的链接将客户交给PayPal。之后,它将返回到您指定的返回网址。然后您执行付款电话:

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

在此回复中将为您查找的信息。

Response => transactions => related_resources => sale => id是带有id的变量。

此外,Response => transactions => related_resources =>链接将具有用于退款交易的链接。

+0

我对API页面给出的解释并不很了解,但他的解释对我有很大的帮助。谢谢。 –