Paypal退款/取消订单自动退款

时间:2014-11-26 05:07:17

标签: php api paypal return

我一直在搜索这个,似乎所有人都要说要退款,你必须去paypal网站等,然后客户会在那里发出退款。

我需要的是: 当客户想要退款时,会在我的网站上向管理员发送批准,然后当管理员批准时,管理员将在网站内选择退还客户的金额。 (然后我猜,它会指向paypal并输入电子邮件和密码?)

这可能吗?除付费外,每个流程都在我的网站上?我似乎没有找到解决方案,我也没有任何领导。感谢。

1 个答案:

答案 0 :(得分:0)

绝对可能,

首先要提出退款请求,您必须存储 Paypal的交易ID

管理员点击退款批准按钮后

var refundTransactionRequestType = new RefundTransactionRequestType
{
    Version = RefundTransactionRequestVersion, //it must be same version with Express Checkout Request Version
    RefundTypeSpecified = true,
    TransactionID = transactionId //HERE You need to set Paypal's TransactionID
};


var refundTransactionRequest = new RefundTransactionRequest( 
            _customSecurityHeaderType, //CustomSecurityHeaderType will have your paypal merchant credentials
            new RefundTransactionReq //Your RefundTransactionRequestType
            {
                RefundTransactionRequest = refundTransactionRequestType
            });

RefundTransactionResponse refundTransactionResponse;


try
{
    PayPalAPIInterface apiInterface = new PayPalAPIInterfaceClient();
    refundTransactionResponse = apiInterface.RefundTransaction(refundTransactionRequest);
}
catch (FaultException err)
{
    return 123123;//Error CODE
}

代码适用于C#,但它具有相同的逻辑

Here is reference for RefundTransaction SOAP

Here is reference for RefundTransaction NVP