setUsername(config('paypal.credentials.username')); $gateway->setPassword(config('paypal.credentials.password')); $gateway->setSignature(config('paypal.credentials.signature')); $gateway->setTestMode(config('paypal.credentials.sandbox')); return $gateway; } /** * @param array $parameters * @return mixed */ public function purchase(array $parameters) { $response = $this->gateway() ->purchase($parameters) ->send(); return $response; } /** * @param array $parameters */ public function complete(array $parameters) { $response = $this->gateway() ->completePurchase($parameters) ->send(); return $response; } /** * @param $amount */ public function formatAmount($amount) { return number_format($amount, 2, '.', ''); } /** * @param Reservation $reservation */ public function getCancelUrl() { return route('paypal.cancelled'); } /** * @param Reservation $reservation */ public function getReturnUrl() { return route('paypal.completed'); } /** * @param Reservation $reservation */ public function getNotifyUrl() { $env = config('paypal.credentials.sandbox') ? "sandbox" : "live"; return route('paypal.webhook', $env); } }