Paypal说我的CancelURL无效?

时间:2012-08-23 15:38:14

标签: paypal

我正在创建一个网站,我只是在添加付款 我正在使用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流量路由到我的localhost,这对我的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);

1 个答案:

答案 0 :(得分:0)

你必须改变:

$req_details_type->ReturnURL = urlencode('https://www.example.com/paypal/getExpressCheckoutDetails');
$req_details_type->CancelURL = urlencode('https://www.example.com/users/account/');

by:

$req_details_type->ReturnURL = 'https://www.example.com/paypal/getExpressCheckoutDetails';
$req_details_type->CancelURL = 'https://www.example.com/users/account/';

进行urlencode();这里不需要将你的url转换为字符串