/** * Calls the Paypal API for executing the payment * * @param Cart $cart * @param $error_message * @return bool|mixed */ public function processPayment(Cart $cart, &$error_message) { $payer_id = Context::get('payer_id'); $token = Context::get('token'); $paypalAPI = new PaypalExpressCheckoutAPI($this->gateway_api == PaypalExpressCheckout::LIVE_URL , $this->api_username , $this->api_password , $this->signature ); // Get shop info $shop_info = new ShopInfo($cart->module_srl); // Prepare cart info $items = $this->getItemsFromCart($cart); $paypalAPI->doExpressCheckoutPayment($token , $payer_id , $items , ShopDisplay::numberFormat($cart->getItemTotal()) , 0 , ShopDisplay::numberFormat($cart->getShippingCost()) , ShopDisplay::numberFormat($cart->getTotal()) , $shop_info->getCurrency() ); if(!$paypalAPI->success) { $error_message = $paypalAPI->error_message; return FALSE; } else { Context::set('payment_status', $paypalAPI->payment_status); return TRUE; } }