gpt4 book ai didi

php - 通过 Paypal 的 API 取消定期付款

转载 作者:太空宇宙 更新时间:2023-11-03 15:56:38 26 4
gpt4 key购买 nike

我有这个代码:

$cancel_payment = UpdateRecurringPaymentsProfile( $paypal_profileid , 'Cancel' );

function UpdateRecurringPaymentsProfile( $user_id, $method )
{
//$user_id is the profile ID returned in the CreateRecurringPaymentsProfile response.
$nvpstr = "&profileid=".$user_id;
$nvpstr .= "&PROFILESTATUS=".$method;
$nvpstr .= "&ACTION=Cancel";
$resArray = hash_call( "UpdateRecurringPaymentsProfile" , $nvpstr );
return $resArray;
}

function hash_call($methodName,$nvpStr)
{
//declaring of global variables
global $API_Endpoint, $version, $API_UserName, $API_Password, $API_Signature;
global $USE_PROXY, $PROXY_HOST, $PROXY_PORT;
global $gv_ApiErrorURL;
global $sBNCode;

//setting the curl parameters.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$API_Endpoint);
curl_setopt($ch, CURLOPT_VERBOSE, 1);

//turning 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);

//if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
//Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
if($USE_PROXY)
curl_setopt ($ch, CURLOPT_PROXY, $PROXY_HOST. ":" . $PROXY_PORT);

//NVPRequest for submitting to server
$nvpreq="METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode($version) . "&PWD=" . urlencode($API_Password) . "&USER=" . urlencode($API_UserName) . "&SIGNATURE=" . urlencode($API_Signature) . $nvpStr . "&BUTTONSOURCE=" . urlencode($sBNCode);

// var_dump($nvpreq);
//setting the nvpreq as POST FIELD to curl
curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);

//getting response from server
$response = curl_exec($ch);

//convrting NVPResponse to an Associative Array
$nvpResArray=deformatNVP($response);
$nvpReqArray=deformatNVP($nvpreq);
$_SESSION['nvpReqArray']=$nvpReqArray;

if (curl_errno($ch))
{
// moving to display page to display curl errors
$_SESSION['curl_error_no']=curl_errno($ch) ;
$_SESSION['curl_error_msg']=curl_error($ch);

//Execute the Error handling module to display errors.
}
else
{
//closing the curl
curl_close($ch);
}

return $nvpResArray;
}

我只是向您展示我的代码片段..

此代码不返回任何错误。问题是,当我在我的 Paypal 仪表板上查看我的“预批准付款”时(我正在使用沙盒),我没有看到已取消的状态,它仍然处于事件状态。简而言之,我的代码有误或有问题。

谁能指导我如何在 paypal 中取消定期付款?

最佳答案

要取消定期付款,您需要使用 ManageRecurringPaymentsProfileStatus API操作并设置action为Cancel

关于php - 通过 Paypal 的 API 取消定期付款,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12469611/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com