所以我开始这个小课程做PayPal空洞,退款和订阅取消。我的问题是,推荐的做法是什么?我的意思是,如果我试图使交易无效,然后忽略错误,然后退还,然后取消订阅?
请注意,在我的情况下,交易是通过点击PayPal订阅按钮开始的,然后在6个月期限结束后续订一次,然后客户想要退款并停止进一步订阅。
<?php
class Paypp {
public static function voidCard($r) {
$asData = array(
'METHOD' => 'DoVoid',
'AUTHORIZATIONID' => @ $r['paypal_txn_id'] // tnx_id from subscr_payment IPN
);
return self::_sendData($asData);
}
public static function cancelSubscription($r) {
$asData = array(
'METHOD' => 'ManageRecurringPaymentsProfileStatus',
'PROFILEID' => @ $r['paypal_subscr_profile_id'], // subscr_id from subscr_payment IPN
'ACTION' => 'cancel'
);
return self::_sendData($asData);
}
public static function refundCard($r) {
$asData = array(
'METHOD' => 'RefundTransaction',
'TRANSACTIONID' => @ $r['paypal_txn_id'],
'REFUNDTYPE' => 'full',
'CURRENCYCODE' => @ $r['currency'],
'AMT' => @ $r['gross']
);
return self::_sendData($asData);
}
private static function _sendData($asData) {
global $config;
$sActive = $config->PAYMENT_GATEWAY_DATA->pp->ACTIVE;
$sURL = $config->PAYMENT_GATEWAY_DATA->pp->$sActive->NVP_URL;
$sVersion = $config->PAYMENT_GATEWAY_DATA->pp->$sActive->NVP_VERSION;
$sUser = $config->PAYMENT_GATEWAY_DATA->pp->$sActive->NVP_USER;
$sPass = $config->PAYMENT_GATEWAY_DATA->pp->$sActive->NVP_PASS;
$sSig = $config->PAYMENT_GATEWAY_DATA->pp->$sActive->NVP_SIG;
$asExtra = array(
'VERSION' => $sVersion,
'USER' => $sUser,
'PWD' => $sPass,
'SIGNATURE' => $sSig
);
$asData = array_merge($asData,$asExtra);
$asOpt = array(
CURLOPT_HEADER => FALSE,
CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_POSTFIELDS => http_build_query($asData),
CURLOPT_VERBOSE => TRUE,
);
$hCurl = curl_init($sURL);
curl_setopt_array($hCurl, $asOpt);
$bVerifySSL = @ $config->VERIFY_SSL;
curl_setopt($hCurl, CURLOPT_SSL_VERIFYPEER, $bVerifySSL);
$sResponse = curl_exec($hCurl);
curl_close($hCurl);
return $sResponse;
}
} // end class
答案 0 :(得分:2)
跳过虚空步骤。空白仅对授权和订单有效,您无法通过订阅创建。但是,是的,您需要取消订阅并退还个人付款。
答案 1 :(得分:0)
通过沙盒中的反复试验,我发现了工作流程应该是什么:
跳过虚空。根据PayPal代表的说法:“空白仅对授权和订单有效,您无法通过订阅创建。”
是的,退款。它再次运行txn_id,这对于您在订阅过程中收到的每个subscr_payment都是唯一的。因此,您只需退还您在IPN上收到的最新subscr_payment。
是的,取消订阅 - 仅退款不会为您执行此操作。