【问题标题】:$_POST['txn_id'] not set for paypal subscription$_POST['txn_id'] 未设置为贝宝订阅
【发布时间】:2013-11-08 13:12:07
【问题描述】:

我正在使用以下代码进行订阅。但是,我没有得到这笔交易的 TXN_ID .....请帮助。为了取消目的,需要 txn_id。

***Subscription HTML***
<form name="paypal" id="paypal" action="https://www.sandbox.paypal.com/cgi-bin/webscr">
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<input type="hidden" name="business" value="XXXXXXXXX@gmail.com">
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="a3" value="2.00">
<input type="hidden" name="p3" value="3">
<input type="hidden" name="t3" value="M">
<input type="hidden" name="return" value="subscription.php?sus=sus&cid=201"> 
<input type="hidden" name="cancel_return" value="subscription.php?can=can">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="item_name" value="Test Subscription">
<input type="hidden" name="item_number" value="Subscription">
<input type="hidden" value="Please go back to website ..." name="cbt">

我正在使用以下代码取消并退还金额 取消代码。

function change_subscription_status($tran_id,$amount ) {
$version        = urlencode('51.0');
$API_Password   = urlencode( '1111111111' );
$API_UserName   = urlencode( 'xxxxxxxxxxx_biz_api1.gmail.com' );
$transactionID  = urlencode( $tran_id );
$refundType     = urlencode('Partial');
$amount         = $amount;
$currencyID     = urlencode('USD');
$API_Signature  = urlencode( 'xxxxxxxxxxxxxxxxxxxxxxxxx' );
$nvpStr         = "&TRANSACTIONID=$transactionID&REFUNDTYPE=$refundType&AMT=$amount&CURRENCYCODE=$currencyID";
$api_request    = "METHOD=RefundTransaction&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api-3t.sandbox.paypal.com/nvp');
curl_setopt($ch, CURLOPT_VERBOSE, 1);
// Turn off the server and peer verification (TrustManager Concept).
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
// Set the request as a POST FIELD for curl.
curl_setopt($ch, CURLOPT_POSTFIELDS, $api_request);
// Get response from the server.
$httpResponse = curl_exec($ch);
curl_close( $ch );
if(!$httpResponse) {
exit("$methodName_ failed: ".curl_error($ch).'('.curl_errno($ch).')');
}
// Extract the response details.
return $httpResponseAr = explode("&", $httpResponse);
}

【问题讨论】:

    标签: php paypal paypal-subscriptions


    【解决方案1】:

    当您设置协议时,它不会给您txn_id,因为从技术上讲,您没有得到任何信息。您需要设置一个 IPN 侦听器,以便当它为您收费时,您可以从中获取txn_id。然后您就可以进行退款了。

    【讨论】:

    • 感谢您的回复。请问可以发IPN Listerner Code吗?
    【解决方案2】:

    对于任何可能遇到此问题的人,定期付款不涉及交易 ID。 Paypal recurring payment not retrieving Transaction ID

    【讨论】:

      猜你喜欢
      • 2019-12-02
      • 2012-02-23
      • 1970-01-01
      • 2020-06-08
      • 2022-11-30
      • 2019-08-04
      • 2016-04-03
      相关资源
      最近更新 更多