2
votes

I am facing an error while creating billing agreement in laravel. Here is the error.

Got Http response code 500 when accessing https://api.sandbox.paypal.com/v1/payments/billing-agreements/.

{"name":"INTERNAL_SERVICE_ERROR","message":"An internal service error has occurred","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR","debug_id":"*********"}

Here is my code:

$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);
}

Can any one guide where I am going wrong?

1

1 Answers

0
votes

Paypal sometimes throws error 500 when using frequently used test CC like the one you are using, so try another one or just try with a real CC number as long as you are in sandbox mode it won't charge you or anything like that.