PayPalAPIInterfaceServiceService :: SetExpressCheckout()返回null响应对象

时间:2013-03-20 21:07:50

标签: paypal paypal-sandbox

我正在使用Yii构建一个需要通过PayPal付款的应用程序。经过大量挖掘,我发现ExpressCheckout是使用的方法。下面的代码在一段时间之前运行良好(一些(?)周之前,我想在PayPal推出他们的新开发人员平台之前),使用PHP SDK的1.2.95版本。现在,使用最新版本v.2.2.98,代码失败。

require_once(Yii::getPathOfAlias('application.libraries.paypal') . '/PPBootStrap.php');
$logger = new PPLoggingManager('SetExpressCheckout');

$PaymentDetails = new PaymentDetailsType();
$PaymentDetails->OrderTotal =  $PaymentDetails->ItemTotal =
  new BasicAmountType('USD', $subscription->price);
$PaymentDetails->PaymentAction = "Sale";
$PaymentDetails->OrderDescription = $subscription->description;

$setECReqDetails = new SetExpressCheckoutRequestDetailsType();
$setECReqDetails->PaymentDetails[0] = $PaymentDetails;
$setECReqDetails->CancelURL = 'someCancelUrl';
$setECReqDetails->ReturnURL = 'someReturnUrl';

$setECReqType = new SetExpressCheckoutRequestType();
$setECReqType->SetExpressCheckoutRequestDetails = $setECReqDetails;

$setECReq = new SetExpressCheckoutReq();
$setECReq->SetExpressCheckoutRequest = $setECReqType;

$paypalService = new PayPalAPIInterfaceServiceService();

$ok = TRUE;
try {
  $setECResponse = $paypalService->SetExpressCheckout($setECReq);
  if($setECResponse && strtoupper($setECResponse->Ack) =='SUCCESS') {
    $token = $setECResponse->Token;
    // Redirect to paypal.com here
    $this->redirect(
      'https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=' . $token);
  }
}
catch (Exception $ex) {
  Yii::trace(__METHOD__ . ': Exception while interacting with PayPal API, error: '
    . $ex->getMessage());
  $ok = FALSE;
}

违规行是:

$setECResponse = $paypalService->SetExpressCheckout($setECReq);

在PayPalAPIInterfaceServiceService :: SetExpressCheckout()中,这两行:

$resp = $this->call('PayPalAPIAA', 'SetExpressCheckout', $setExpressCheckoutReq, $apiCredential);
$ret->init(PPUtils::xmlToArray($resp));

是个问题。 $resp为空,因此下一行在PPUtils::xmlToArray($resp)方法调用失败。

显然,要么我在这里遗漏了一些东西,要么PayPal做错了。

任何帮助?

1 个答案:

答案 0 :(得分:0)

经过大量调试后,问题的原因是service.EndPoint.PayPalAPI中没有定义sdk_config.ini参数。由于某种原因,我不记得,此参数已从先前版本的工作配置文件中删除。

现在,快速结账方法工作正常,即使使用最新的2.3.100版本的API。