Esraa Osama Esraa Osama - 3 months ago 14
PHP Question

Error with getCheckout functoin in netshel paypal

I have this error while I am trying to configure paypal with laravel


FatalErrorException in Paypalel.php line 32: Non-abstract method
App\Http\Controllers\Paypalel::getCheckout() must contain body


This is the code

public function getCheckout($title,$disc,$price);
{


// get the id of the product
$payer = PayPal::Payer();
$payer->setPaymentMethod('paypal');

$amount = PayPal:: Amount();
$amount->setCurrency('USD');
$amount->setTotal($price); // This is the simple way,
// you can alternatively describe everything in the order separately;
// Reference the PayPal PHP REST SDK for details.

$transaction = PayPal::Transaction();
$transaction->setAmount($amount);
$transaction->setDescription($disc);

$redirectUrls = PayPal:: RedirectUrls();
$redirectUrls->setReturnUrl(action('ProductController@getDone'));
$redirectUrls->setCancelUrl(action('ProductController@getCancel'));

$payment = PayPal::Payment();
$payment->setIntent('sale');
$payment->setPayer($payer);
$payment->setRedirectUrls($redirectUrls);
$payment->setTransactions(array($transaction));

$response = $payment->create($this->_apiContext);
$redirectUrl = $response->links[1]->href;

return Redirect::to( $redirectUrl );
}

Answer

There's a stray semicolon ;

public function getCheckout($title,$disc,$price); {
                                                ^

Remove that

public function getCheckout($title,$disc,$price) {
Comments