public function process($transaction, $description = "Payment Description ") { //do some checks here $payer = PaypalPayment::Payer(); $payer->setPaymentMethod("paypal"); $paypal_transaction = PaypalPayment::Transaction(); $paypal_transaction->setAmount($this->amount); $paypal_transaction->setItemList($this->item_list); $paypal_transaction->setDescription($description); $redirectUrls = PaypalPayment::RedirectUrls(); $redirectUrls->setReturn_url(url('checkout/approved?transaction=' . $transaction->transaction_id)); $redirectUrls->setCancel_url(url('checkout/cancel/' . $transaction->transaction_id)); $this->payment = PaypalPayment::Payment(); $this->payment->setIntent("sale"); $this->payment->setPayer($payer); $this->payment->setRedirectUrls($redirectUrls); $this->payment->setTransactions(array($paypal_transaction)); try { $this->payment->create($this->_apiContext); } catch (\PayPal\Exception\PPConnectionException $ex) { echo "Exception: " . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); exit(1); } }