gpt4 book ai didi

paypal - 如何在 Paypal 定期配置文件快速结帐中的 CallShortcutExpressCheckout 后调用 CreateRecurringPaymentsProfile

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

我已经在我的网站上下载并实现了这个 paypal 集成库。 https://github.com/hrendoh/PayPal-Express-Checkout-example

没有创建重复配置文件。

快速结帐的函数调用是

  $resArray = CallShortcutExpressCheckout ($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL);
$ack = strtoupper($resArray["ACK"]);
if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING")
{
// if SetExpressCheckout is returned with success, move to paypal site for payments.
RedirectToPayPal ( $resArray["TOKEN"] );
}


function CallShortcutExpressCheckout( $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL)
{
//------------------------------------------------------------------------------------------------------------------------------------
// Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation

$nvpstr="&AMT=". $paymentAmount;
$nvpstr = $nvpstr . "&PAYMENTACTION=" . $paymentType;
$nvpstr = $nvpstr . "&BILLINGAGREEMENTDESCRIPTION=".urlencode("Test Recurring Payment($1 monthly)");
$nvpstr = $nvpstr . "&BILLINGTYPE=RecurringPayments";
$nvpstr = $nvpstr . "&RETURNURL=" . $returnURL;
$nvpstr = $nvpstr . "&CANCELURL=" . $cancelURL;
$nvpstr = $nvpstr . "&CURRENCYCODE=" . $currencyCodeType;

$_SESSION["currencyCodeType"] = $currencyCodeType;
$_SESSION["PaymentType"] = $paymentType;

//'---------------------------------------------------------------------------------------------------------------
//' Make the API call to PayPal
//' If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment.
//' If an error occured, show the resulting errors
//'---------------------------------------------------------------------------------------------------------------

$resArray=hash_call("SetExpressCheckout", $nvpstr);
$ack = strtoupper($resArray["ACK"]);
if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING")
{
$token = urldecode($resArray["TOKEN"]);
$_SESSION['TOKEN']=$token;
}

return $resArray;
}

此函数用于创建一个循环配置文件,该配置文件不会在示例代码中的任何地方调用。

function CreateRecurringPaymentsProfile()
{
//'--------------------------------------------------------------
//' At this point, the buyer has completed authorizing the payment
//' at PayPal. The function will call PayPal to obtain the details
//' of the authorization, incuding any shipping information of the
//' buyer. Remember, the authorization is not a completed transaction
//' at this state - the buyer still needs an additional step to finalize
//' the transaction
//'--------------------------------------------------------------
$token = urlencode($_SESSION['TOKEN']);
$email = urlencode($_SESSION['email']);
$shipToName = urlencode($_SESSION['shipToName']);
$shipToStreet = urlencode($_SESSION['shipToStreet']);
$shipToCity = urlencode($_SESSION['shipToCity']);
$shipToState = urlencode($_SESSION['shipToState']);
$shipToZip = urlencode($_SESSION['shipToZip']);
$shipToCountry = urlencode($_SESSION['shipToCountry']);

//'---------------------------------------------------------------------------
//' Build a second API request to PayPal, using the token as the
//' ID to get the details on the payment authorization
//'---------------------------------------------------------------------------
$nvpstr="&TOKEN=".$token;
#$nvpstr.="&EMAIL=".$email;
$nvpstr.="&SHIPTONAME=".$shipToName;
$nvpstr.="&SHIPTOSTREET=".$shipToStreet;
$nvpstr.="&SHIPTOCITY=".$shipToCity;
$nvpstr.="&SHIPTOSTATE=".$shipToState;
$nvpstr.="&SHIPTOZIP=".$shipToZip;
$nvpstr.="&SHIPTOCOUNTRY=".$shipToCountry;
$nvpstr.="&PROFILESTARTDATE=".urlencode("2011-07-01T0:0:0");
$nvpstr.="&DESC=".urlencode("Test Recurring Payment($1 monthly)");
$nvpstr.="&BILLINGPERIOD=Month";
$nvpstr.="&BILLINGFREQUENCY=5";
$nvpstr.="&AMT=1";
$nvpstr.="&CURRENCYCODE=USD";
$nvpstr.="&IPADDRESS=" . $_SERVER['REMOTE_ADDR'];

//'---------------------------------------------------------------------------
//' Make the API call and store the results in an array.
//' If the call was a success, show the authorization details, and provide
//' an action to complete the payment.
//' If failed, show the error
//'---------------------------------------------------------------------------
$resArray=hash_call("CreateRecurringPaymentsProfile",$nvpstr);
$ack = strtoupper($resArray["ACK"]);
return $resArray;
}

我可以调用此函数以在 returnurl 中创建重复配置文件并将 token ID 和付款人 ID 传递给此函数吗?

最佳答案

无论您使用的是什么库,流程都应该是 SetExpressCheckout , GetExpressCheckoutDetails (可选),然后您可以跟进其中一个/或/两个 DoExpresscheckoutPaymentCreateRecurringPaymentsProfile .

如果您打算使用 CRPP,则需要确保 SEC 包含计费协议(protocol)参数,否则在调用 CRPP 时您将遇到无效 token 错误。 Here's an old sample的 RAW API 请求流使其工作。

然后,如果你有兴趣,不妨看看我的PHP class library for PayPal让这对你来说更容易。我知道我的作品。 :)

关于paypal - 如何在 Paypal 定期配置文件快速结帐中的 CallShortcutExpressCheckout 后调用 CreateRecurringPaymentsProfile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20338048/

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