尝试为paypal创建帐单协议时,获取Http响应代码500错误 - PHP

时间:2016-06-14 13:26:45

标签: php paypal laravel-5 paypal-rest-sdk

我在laravel中创建结算协议时遇到错误。这是错误。

访问https://api.sandbox.paypal.com/v1/payments/billing-agreements/时获得Http响应代码500。

  

{“name”:“INTERNAL_SERVICE_ERROR”,“message”:“内部服务错误   具有   发生”, “information_link”: “https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR”, “debug_id”: “*********”}

这是我的代码:

$payerInfo = new PayerInfo();
$payerInfo->setFirstName($user->first_name)
          ->setLastName($user->last_name)
          ->setEmail($user->email);

$payer = new Payer();
$payer->setPaymentMethod('paypal')
      ->setPayerInfo($payerInfo);

$newPlan = new Plan();
$newPlan->setId($plan_id);

$agreement = new Agreement();
$agreement->setName($plan[0]->name.' Subscription')
           ->setDescription($plan[0]->name." Subscription")
           ->setStartDate(gmdate("Y-m-d\TH:i:s\Z", time()+60))
           ->setPayer($payer)
           ->setPlan($newPlan);

try {
    $agreement->create($api_context);
} catch(PayPal\Exception\PayPalConnectionException $e) {
    echo $ex->getCode(); // Prints the Error Code
    echo $ex->getData(); // Prints the detailed error message 
    die($ex);
}

任何人都可以指导我出错吗?

1 个答案:

答案 0 :(得分:0)

Paypal有时会在使用经常使用的测试CC时抛出错误500,所以尝试使用其他测试CC,或者尝试使用真正的CC编号,只要您处于沙箱模式,它就不会向您收费或类似这一点。