我正在创建一个网站,只是添加付款。
我正在使用Paypal SDK并设置了我的SetExpressCheckout()
.
这是回应,
object(SetExpressCheckoutResponseType)[72]
public 'Token' => null
public 'Timestamp' => string '2012-08-23T15:21:15Z' (length=20)
public 'Ack' => string 'Failure' (length=7)
public 'CorrelationID' => string 'e0278e8e18b4f' (length=13)
public 'Errors' =>
object(ErrorType)[78]
public 'ShortMessage' => string 'Transaction refused because of an invalid argument. See additional error messages for details.' (length=94)
public 'LongMessage' => string 'CancelURL is invalid.' (length=21)
public 'ErrorCode' => string '10472' (length=5)
public 'SeverityCode' => string 'Error' (length=5)
public 'ErrorParameters' => null
public 'Version' => string '93.0' (length=4)
public 'Build' => string '3556406' (length=7)
我不确定发生了什么。我的CancelURL
样子,urlencode('https://www.example.com/users/account/');
. 我已经包含了尾部斜杠,有些人认为这会导致它无效。
我唯一能想到的是,因为我的网站在任何地方都不在线,所以 Paypal 无法访问该页面。我创建了一个虚拟页面并将其上传到/users/account/
服务器上,因此它可以访问但仍然没有。我还有一个条目可以将流量etc/hosts
路由example.com
到我的本地主机,这对于我的 Facebook Auth 位来说效果很好。
任何人都知道 CancelURL 的限制是什么以及为什么 Paypal 会拒绝我的请求?
请求生成
$int = new PayPalAPIInterfaceServiceService();
$amount = new BasicAmountType();
$amount->currencyID = CakeSession::read('Locale.currency');
$amount->value = Configure::read('Subscription.price.'.CakeSession::read('Locale.shortname'));
$req_details_type = new SetExpressCheckoutRequestDetailsType();
$req_details_type->OrderTotal = $amount;
$req_details_type->ReturnURL = urlencode('https://www.example.com/paypal/getExpressCheckoutDetails');
$req_details_type->CancelURL = urlencode('https://www.example.com/users/account/');
$req_details_type->MaxAmount = $amount;
$req_details_type->OrderDescription = "Monthly subscription to Example.com Pro";
$req_details_type->ReqConfirmShipping = 0;
$req_details_type->NoShipping = 1;
$req_details_type->LocaleCode = CakeSession::read('Locale.shortname') == 'usa'? 'US' : 'GB';
$req_details_type->PaymentAction = 'Authorization';
$req_details_type->BuyerEmail = AuthComponent::user('email');
$req_details_type->BrandName = urlencode("Example.com");
$req_type = new SetExpressCheckoutRequestType();
$req_type->SetExpressCheckoutRequestDetails = $req_details_type;
$req = new SetExpressCheckoutReq();
$req->SetExpressCheckoutRequest = $req_type;
$response = $int->SetExpressCheckout($req);
var_dump($response);