public function getAuthorisation() { global $cookie, $cart; // Getting cart informations $currency = new Currency(intval($cookie->id_currency)); if (!Validate::isLoadedObject($currency)) { $this->_logs[] = $this->l('Not a valid currency'); } if (sizeof($this->_logs)) { return false; } // Making request $vars = '?fromPayPal=1'; $returnURL = (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://') . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/paypalapi/payment/submit.php' . $vars; $cancelURL = (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://') . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'order.php'; $paymentAmount = number_format(floatval($cart->getOrderTotalLC()), 2, '.', ''); $currencyCodeType = strval($currency->iso_code); $paymentType = 'Sale'; $request = '&Amt=' . urlencode($paymentAmount) . '&PAYMENTACTION=' . urlencode($paymentType) . '&ReturnUrl=' . urlencode($returnURL) . '&CANCELURL=' . urlencode($cancelURL) . '&CURRENCYCODE=' . urlencode($currencyCodeType) . '&NOSHIPPING=1'; if ($this->_header) { $request .= '&HDRIMG=' . urlencode($this->_header); } // Calling PayPal API include _PS_MODULE_DIR_ . 'paypalapi/api/PaypalLib.php'; $ppAPI = new PaypalLib(); $result = $ppAPI->makeCall($this->getAPIURL(), $this->getAPIScript(), 'SetExpressCheckout', $request); $this->_logs = array_merge($this->_logs, $ppAPI->getLogs()); return $result; }
public function getAuthorisation() { global $cookie, $cart; // Getting cart informations $currency = new Currency(intval($cookie->id_currency)); if (!Validate::isLoadedObject($currency)) { $this->_logs[] = $this->l('Not a valid currency'); } if (sizeof($this->_logs)) { return false; } // Making request $vars = '?fromPayPal=1'; $returnURL = Tools::getHttpHost(true, true) . __PS_BASE_URI__ . 'modules/paypalapi/payment/submit.php' . $vars; $cancelURL = Tools::getHttpHost(true, true) . __PS_BASE_URI__ . 'order.php'; $paymentAmount = floatval($cart->getOrderTotal()); $currencyCodeType = strval($currency->iso_code); $paymentType = 'Sale'; $request = '&Amt=' . urlencode($paymentAmount) . '&PAYMENTACTION=' . urlencode($paymentType) . '&ReturnUrl=' . urlencode($returnURL) . '&CANCELURL=' . urlencode($cancelURL) . '&CURRENCYCODE=' . urlencode($currencyCodeType) . '&NOSHIPPING=1'; if ($this->_pp_integral) { $request .= '&SOLUTIONTYPE=Sole&LANDINGPAGE=Billing'; } else { $request .= '&SOLUTIONTYPE=Mark&LANDINGPAGE=Login'; } $request .= '&LOCALECODE=' . strval($this->getCountryCode()); if ($this->_header) { $request .= '&HDRIMG=' . urlencode($this->_header); } // Calling PayPal API include _PS_MODULE_DIR_ . 'paypalapi/api/paypallib.php'; $ppAPI = new PaypalLib(); $result = $ppAPI->makeCall($this->getAPIURL(), $this->getAPIScript(), 'SetExpressCheckout', $request); $this->_logs = array_merge($this->_logs, $ppAPI->getLogs()); return $result; }
public function getAuthorisation() { global $cookie, $cart; // Getting cart informations $currency = new Currency((int) $cart->id_currency); if (!Validate::isLoadedObject($currency)) { $this->_logs[] = $this->l('Not a valid currency'); } if (sizeof($this->_logs)) { return false; } // Making request $vars = '?fromPayPal=1'; $returnURL = Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/paypal/payment/submit.php' . $vars; $cancelURL = Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'order.php'; $paymentAmount = (double) $cart->getOrderTotal(); $currencyCodeType = strval($currency->iso_code); $paymentType = Configuration::get('PAYPAL_CAPTURE') == 1 ? 'Authorization' : 'Sale'; $request = '&Amt=' . urlencode($paymentAmount) . '&PAYMENTACTION=' . urlencode($paymentType) . '&ReturnUrl=' . urlencode($returnURL) . '&CANCELURL=' . urlencode($cancelURL) . '&CURRENCYCODE=' . urlencode($currencyCodeType) . '&NOSHIPPING=1'; if (Configuration::get('PAYPAL_PAYMENT_METHOD') == 0) { $request .= '&SOLUTIONTYPE=Sole&LANDINGPAGE=Billing'; } else { $request .= '&SOLUTIONTYPE=Mark&LANDINGPAGE=Login'; } $request .= '&LOCALECODE=' . strtoupper(Language::getIsoById($cart->id_lang)); if (Configuration::get('PAYPAL_HEADER')) { $request .= '&HDRIMG=' . urlencode(Configuration::get('PAYPAL_HEADER')); } // Customer informations $customer = new Customer((int) $cart->id_customer); $request .= '&EMAIL=' . urlencode($customer->email); //customer // address of delivery $address = new Address((int) $cart->id_address_delivery); $country = new Country((int) $address->id_country); if ($address->id_state) { $state = new State((int) $address->id_state); } $request .= '&SHIPTONAME=' . urlencode($address->firstname . ' ' . $address->lastname); $request .= '&SHIPTOSTREET=' . urlencode($address->address1); $request .= '&SHIPTOSTREET2=' . urlencode($address->address2); $request .= '&SHIPTOCITY=' . urlencode($address->city); $request .= '&SHIPTOSTATE=' . ($address->id_state ? $state->iso_code : $country->iso_code); $request .= '&SHIPTOZIP=' . urlencode($address->postcode); $request .= '&SHIPTOCOUNTRY=' . urlencode($country->iso_code); $request .= '&SHIPTOPHONENUM=' . urlencode($address->phone); $request .= '&ADDROVERRIDE=1'; // Calling PayPal API include _PS_MODULE_DIR_ . 'paypal/api/paypallib.php'; $ppAPI = new PaypalLib(); $result = $ppAPI->makeCall($this->getAPIURL(), $this->getAPIScript(), 'SetExpressCheckout', $request); $this->_logs = array_merge($this->_logs, $ppAPI->getLogs()); return $result; }
public function getCustomerInfos() { global $cookie; // Making request $request = '&TOKEN=' . urlencode(strval($cookie->paypal_token)); // Calling PayPal API include _PS_MODULE_DIR_ . 'paypalapi/api/PaypalLib.php'; $ppAPI = new PaypalLib(); $result = $ppAPI->makeCall($this->getAPIURL(), $this->getAPIScript(), 'GetExpressCheckoutDetails', $request); $this->_logs = array_merge($this->_logs, $ppAPI->getLogs()); return $result; }
private function callAPI($fields) { $this->logs = array(); $paypal_lib = new PaypalLib(); $this->result = $paypal_lib->makeCall($this->getAPIURL(), $this->getAPIScript(), $this->method, $fields, $this->method_version); $this->logs = array_merge($this->logs, $paypal_lib->getLogs()); $this->_storeToken(); }
public function makePayPalAPIValidation($cookie, $cart, $id_currency, $payerID, $type) { global $cookie; if (!$this->active) { return; } if (!$this->_isPayPalAPIAvailable()) { return; } // Filling-in vars $id_cart = (int) $cart->id; $currency = new Currency((int) $id_currency); $iso_currency = $currency->iso_code; $token = $cookie->paypal_token; $total = (double) $cart->getOrderTotal(true, PayPal::BOTH); $paymentType = Configuration::get('PAYPAL_CAPTURE') == 1 ? 'Authorization' : 'Sale'; $serverName = urlencode($_SERVER['SERVER_NAME']); $bn = $type == 'express' ? 'ECS' : 'ECM'; $notifyURL = urlencode(PayPal::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/paypal/ipn.php'); // Getting address if (isset($cookie->id_cart) and $cookie->id_cart) { $cart = new Cart((int) $cookie->id_cart); } if (isset($cart->id_address_delivery) and $cart->id_address_delivery) { $address = new Address((int) $cart->id_address_delivery); } $requestAddress = ''; if (Validate::isLoadedObject($address)) { $country = new Country((int) $address->id_country); $state = new State((int) $address->id_state); $requestAddress = '&SHIPTONAME=' . urlencode($address->company . ' ' . $address->firstname . ' ' . $address->lastname) . '&SHIPTOSTREET=' . urlencode($address->address1 . ' ' . $address->address2) . '&SHIPTOCITY=' . urlencode($address->city) . '&SHIPTOSTATE=' . urlencode($address->id_state ? $state->iso_code : $country->iso_code) . '&SHIPTOCOUNTRYCODE=' . urlencode($country->iso_code) . '&SHIPTOZIP=' . urlencode($address->postcode); } // Making request $request = '&TOKEN=' . urlencode($token) . '&PAYERID=' . urlencode($payerID) . '&PAYMENTACTION=' . $paymentType . '&AMT=' . $total . '&CURRENCYCODE=' . $iso_currency . '&IPADDRESS=' . $serverName . '&NOTIFYURL=' . $notifyURL . '&BUTTONSOURCE=PRESTASHOP_' . $bn . $requestAddress; $discounts = (double) $cart->getOrderTotal(true, PayPal::ONLY_DISCOUNTS); if ($discounts == 0) { $products = $cart->getProducts(); $amt = 0; for ($i = 0; $i < sizeof($products); $i++) { $request .= '&L_NAME' . $i . '=' . substr(urlencode($products[$i]['name'] . (isset($products[$i]['attributes']) ? ' - ' . $products[$i]['attributes'] : '') . (isset($products[$i]['instructions']) ? ' - ' . $products[$i]['instructions'] : '')), 0, 127); $request .= '&L_AMT' . $i . '=' . urlencode($this->PayPalRound($products[$i]['price'])); $request .= '&L_QTY' . $i . '=' . urlencode($products[$i]['cart_quantity']); $amt += $this->PayPalRound($products[$i]['price']) * $products[$i]['cart_quantity']; } $shipping = $this->PayPalRound($cart->getOrderShippingCost($cart->id_carrier, false)); $request .= '&ITEMAMT=' . urlencode($amt); $request .= '&SHIPPINGAMT=' . urlencode($shipping); $request .= '&TAXAMT=' . urlencode((double) max($this->PayPalRound($total - $amt - $shipping), 0)); } else { $products = $cart->getProducts(); $description = 0; for ($i = 0; $i < sizeof($products); $i++) { $description .= ($description == '' ? '' : ', ') . $products[$i]['cart_quantity'] . " x " . $products[$i]['name'] . (isset($products[$i]['attributes']) ? ' - ' . $products[$i]['attributes'] : '') . (isset($products[$i]['instructions']) ? ' - ' . $products[$i]['instructions'] : ''); } $request .= '&ORDERDESCRIPTION=' . urlencode(substr($description, 0, 120)); } // Calling PayPal API include_once _PS_MODULE_DIR_ . 'paypal/api/paypallib.php'; $ppAPI = new PaypalLib(); $result = $ppAPI->makeCall($this->getAPIURL(), $this->getAPIScript(), 'DoExpressCheckoutPayment', $request); $this->_logs = array_merge($this->_logs, $ppAPI->getLogs()); // Checking PayPal result if (!is_array($result) or !sizeof($result)) { $this->displayPayPalAPIError($this->l('Authorization to PayPal failed.'), $this->_logs); } elseif (!isset($result['ACK']) or strtoupper($result['ACK']) != 'SUCCESS') { $this->displayPayPalAPIError($this->l('PayPal return error.'), $this->_logs); } elseif (!isset($result['TOKEN']) or $result['TOKEN'] != $cookie->paypal_token) { $logs[] = '<b>' . $ppExpress->l('Token given by PayPal is not the same as the cookie token', 'submit') . '</b>'; $ppExpress->displayPayPalAPIError($ppExpress->l('PayPal return error.', 'submit'), $logs); } // Making log $id_transaction = $result['TRANSACTIONID']; if (Configuration::get('PAYPAL_CAPTURE')) { $this->_logs[] = $this->l('Authorization for deferred payment granted by PayPal.'); } else { $this->_logs[] = $this->l('Order finished with PayPal!'); } $message = Tools::htmlentitiesUTF8(strip_tags(implode("\n", $this->_logs))); // Order status switch ($result['PAYMENTSTATUS']) { case 'Completed': $id_order_state = Configuration::get('PS_OS_PAYMENT'); break; case 'Pending': if ($result['PENDINGREASON'] != 'authorization') { $id_order_state = Configuration::get('PS_OS_PAYPAL'); } else { $id_order_state = (int) Configuration::get('PAYPAL_OS_AUTHORIZATION'); } break; default: $id_order_state = Configuration::get('PS_OS_ERROR'); } // Call payment validation method $this->validateOrder($id_cart, $id_order_state, (double) $cart->getOrderTotal(true, PayPal::BOTH), $this->displayName, $message, array('transaction_id' => $id_transaction, 'payment_status' => $result['PAYMENTSTATUS'], 'pending_reason' => $result['PENDINGREASON']), $id_currency, false, $cart->secure_key); // Clean cookie unset($cookie->paypal_token); // Displaying output $order = new Order((int) $this->currentOrder); Tools::redirectLink(__PS_BASE_URI__ . 'order-confirmation.php?id_cart=' . (int) $id_cart . '&id_module=' . (int) $this->id . '&id_order=' . (int) $this->currentOrder . '&key=' . $order->secure_key); }
public function getAuthorisation() { global $cookie, $cart; // Getting cart informations $currency = new Currency((int) $cart->id_currency); if (!Validate::isLoadedObject($currency)) { $this->_logs[] = $this->l('Not a valid currency'); } if (sizeof($this->_logs)) { return false; } // Making request $vars = '?fromPayPal=1'; $returnURL = Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/paypal/payment/submit.php' . $vars; $cancelURL = Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'order.php'; $paymentAmount = (double) $cart->getOrderTotal(); $currencyCodeType = strval($currency->iso_code); $paymentType = Configuration::get('PAYPAL_CAPTURE') == 1 ? 'Authorization' : 'Sale'; $request = '&Amt=' . urlencode($paymentAmount) . '&PAYMENTACTION=' . urlencode($paymentType) . '&ReturnUrl=' . urlencode($returnURL) . '&CANCELURL=' . urlencode($cancelURL) . '&CURRENCYCODE=' . urlencode($currencyCodeType) . '&NOSHIPPING=1'; if (Configuration::get('PAYPAL_PAYMENT_METHOD') == 0) { $request .= '&SOLUTIONTYPE=Sole&LANDINGPAGE=Billing'; } else { $request .= '&SOLUTIONTYPE=Mark&LANDINGPAGE=Login'; } $request .= '&LOCALECODE=' . strtoupper(Language::getIsoById($cart->id_lang)); if (Configuration::get('PAYPAL_HEADER')) { $request .= '&HDRIMG=' . urlencode(Configuration::get('PAYPAL_HEADER')); } // Customer informations $customer = new Customer((int) $cart->id_customer); $request .= '&EMAIL=' . urlencode($customer->email); //customer // address of delivery $id_address = $cart->id_address_delivery; $address = new Address((int) $id_address); $country = new Country((int) $address->id_country); if ($address->id_state) { $state = new State((int) $address->id_state); } $discounts = (double) $cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS); if ($discounts == 0) { if ($params['cart']->id_customer) { $customer = new Customer((int) $params['cart']->id_customer); $taxCalculationMethod = Group::getPriceDisplayMethod((int) $customer->id_default_group); } else { $taxCalculationMethod = Group::getDefaultPriceDisplayMethod(); } $priceField = $taxCalculationMethod == PS_TAX_EXC ? 'price' : 'price_wt'; $products = $cart->getProducts(); $amt = 0; for ($i = 0; $i < sizeof($products); $i++) { $request .= '&L_NAME' . $i . '=' . substr(urlencode($products[$i]['name'] . (isset($products[$i]['attributes']) ? ' - ' . $products[$i]['attributes'] : '') . (isset($products[$i]['instructions']) ? ' - ' . $products[$i]['instructions'] : '')), 0, 127); $request .= '&L_AMT' . $i . '=' . urlencode($this->PayPalRound($products[$i][$priceField])); $request .= '&L_QTY' . $i . '=' . urlencode($products[$i]['cart_quantity']); $amt += $this->PayPalRound($products[$i][$priceField] * $products[$i]['cart_quantity']); } $shipping = $this->PayPalRound($cart->getOrderShippingCost($cart->id_carrier, false)); $request .= '&ITEMAMT=' . urlencode($amt); $request .= '&SHIPPINGAMT=' . urlencode($shipping); $request .= '&TAXAMT=' . urlencode((double) max($this->PayPalRound($paymentAmount - $amt - $shipping), 0)); } else { $products = $cart->getProducts(); $description = 0; for ($i = 0; $i < sizeof($products); $i++) { $description .= ($description == '' ? '' : ', ') . $products[$i]['cart_quantity'] . " x " . $products[$i]['name'] . (isset($products[$i]['attributes']) ? ' - ' . $products[$i]['attributes'] : '') . (isset($products[$i]['instructions']) ? ' - ' . $products[$i]['instructions'] : ''); } $request .= '&ORDERDESCRIPTION=' . urlencode(substr($description, 0, 120)); } $request .= '&SHIPTONAME=' . urlencode($address->firstname . ' ' . $address->lastname); $request .= '&SHIPTOSTREET=' . urlencode($address->address1); $request .= '&SHIPTOSTREET2=' . urlencode($address->address2); $request .= '&SHIPTOCITY=' . urlencode($address->city); $request .= '&SHIPTOSTATE=' . ($address->id_state ? $state->iso_code : $country->iso_code); $request .= '&SHIPTOZIP=' . urlencode($address->postcode); $request .= '&SHIPTOCOUNTRY=' . urlencode($country->iso_code); $request .= '&SHIPTOPHONENUM=' . urlencode($address->phone); $request .= '&ADDROVERRIDE=1'; // Calling PayPal API include _PS_MODULE_DIR_ . 'paypal/api/paypallib.php'; $ppAPI = new PaypalLib(); $result = $ppAPI->makeCall($this->getAPIURL(), $this->getAPIScript(), 'SetExpressCheckout', $request); $this->_logs = array_merge($this->_logs, $ppAPI->getLogs()); return $result; }
public function validOrder($cookie, $cart, $id_currency, $payerID, $type) { global $cookie; if (!$this->active) { return; } // Filling-in vars $id_cart = intval($cart->id); $currency = new Currency(intval($id_currency)); $iso_currency = $currency->iso_code; $token = strval($cookie->paypal_token); $total = floatval($cart->getOrderTotal(true, 3)); $payerID = strval($payerID); $paymentType = 'Sale'; $serverName = urlencode($_SERVER['SERVER_NAME']); $bn = $type == 'express' ? 'ECS' : 'ECM'; $notifyURL = urlencode('http://' . Tools::getHttpHost(false, true) . __PS_BASE_URI__ . 'modules/paypalapi/ipn.php'); // Getting address if (isset($cookie->id_cart) and $cookie->id_cart) { $cart = new Cart(intval($cookie->id_cart)); } if (isset($cart->id_address_delivery) and $cart->id_address_delivery) { $address = new Address(intval($cart->id_address_delivery)); } $requestAddress = ''; if (Validate::isLoadedObject($address)) { $country = new Country(intval($address->id_country)); $state = new State(intval($address->id_state)); $requestAddress = '&SHIPTONAME=' . urlencode($address->company . ' ' . $address->lastname . ' ' . $address->firstname) . '&SHIPTOSTREET=' . urlencode($address->address1 . ' ' . $address->address2) . '&SHIPTOCITY=' . urlencode($address->city) . '&SHIPTOSTATE=' . urlencode($state->iso_code) . '&SHIPTOCOUNTRYCODE=' . urlencode($country->iso_code) . '&SHIPTOZIP=' . urlencode($address->postcode); } // Making request $request = '&TOKEN=' . urlencode($token) . '&PAYERID=' . urlencode($payerID) . '&PAYMENTACTION=' . $paymentType . '&AMT=' . $total . '&CURRENCYCODE=' . $iso_currency . '&IPADDRESS=' . $serverName . '&NOTIFYURL=' . $notifyURL . '&BUTTONSOURCE=PRESTASHOP_' . $bn . $requestAddress; // Calling PayPal API include _PS_MODULE_DIR_ . 'paypalapi/api/paypallib.php'; $ppAPI = new PaypalLib(); $result = $ppAPI->makeCall($this->getAPIURL(), $this->getAPIScript(), 'DoExpressCheckoutPayment', $request); $this->_logs = array_merge($this->_logs, $ppAPI->getLogs()); // Checking PayPal result if (!is_array($result) or !sizeof($result)) { $this->displayError($this->l('Authorisation to PayPal failed'), $this->_logs); } elseif (!isset($result['ACK']) or strtoupper($result['ACK']) != 'SUCCESS') { $this->displayError($this->l('PayPal returned error'), $this->_logs); } elseif (!isset($result['TOKEN']) or $result['TOKEN'] != $cookie->paypal_token) { $logs[] = '<b>' . $ppExpress->l('Token given by PayPal is not the same that cookie one', 'submit') . '</b>'; $ppExpress->displayError($ppExpress->l('PayPal returned error', 'submit'), $logs); } // Making log $id_transaction = strval($result['TRANSACTIONID']); $this->_logs[] = $this->l('Order finished with PayPal!'); $message = Tools::htmlentitiesUTF8(strip_tags(implode("\n", $this->_logs))); // Order status switch ($result['PAYMENTSTATUS']) { case 'Completed': $id_order_state = _PS_OS_PAYMENT_; break; case 'Pending': $id_order_state = _PS_OS_PAYPAL_; break; default: $id_order_state = _PS_OS_ERROR_; } // Execute Module::validateOrder() $this->validateOrder($id_cart, $id_order_state, floatval($cart->getOrderTotal(true, 3)), $this->displayName, $message, array(), $id_currency); // Filling PayPal table $this->addOrder($id_transaction); // Displaying output $this->displayFinal($id_cart); }
public function validOrder($cookie, $cart, $id_currency, $payerID, $type) { if (!$this->active) { return; } // Filling-in vars $id_cart = intval($cart->id); $currency = new Currency(intval($id_currency)); $iso_currency = $currency->iso_code; $token = strval($cookie->paypal_token); $total = number_format(floatval($cart->getOrderTotal(true, 3)), 2, '.', ''); $payerID = strval($payerID); $paymentType = 'Sale'; $serverName = urlencode($_SERVER['SERVER_NAME']); $bn = $type == 'express' ? 'ECS' : 'ECM'; $notifyURL = urlencode('http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/paypalapi/ipn.php'); // Making request $request = '&TOKEN=' . urlencode($token) . '&PAYERID=' . urlencode($payerID) . '&PAYMENTACTION=' . $paymentType . '&AMT=' . $total . '&CURRENCYCODE=' . $iso_currency . '&IPADDRESS=' . $serverName . '&NOTIFYURL=' . $notifyURL . '&BUTTONSOURCE=PRESTASHOP_' . $bn; // Calling PayPal API include _PS_MODULE_DIR_ . 'paypalapi/api/PaypalLib.php'; $ppAPI = new PaypalLib(); $result = $ppAPI->makeCall($this->getAPIURL(), $this->getAPIScript(), 'DoExpressCheckoutPayment', $request); $this->_logs = array_merge($this->_logs, $ppAPI->getLogs()); // Checking PayPal result if (!is_array($result) or !sizeof($result)) { $this->displayError($this->l('Authorisation to PayPal failed'), $this->_logs); } elseif (!isset($result['ACK']) or strtoupper($result['ACK']) != 'SUCCESS') { $this->displayError($this->l('PayPal returned error'), $this->_logs); } elseif (!isset($result['TOKEN']) or $result['TOKEN'] != $cookie->paypal_token) { $logs[] = '<b>' . $ppExpress->l('Token given by PayPal is not the same that cookie one', 'submit') . '</b>'; $ppExpress->displayError($ppExpress->l('PayPal returned error', 'submit'), $logs); } // Making log $id_transaction = strval($result['TRANSACTIONID']); $this->_logs[] = $this->l('Order finished with PayPal!'); $message = Tools::htmlentitiesUTF8(strip_tags(implode("\n", $this->_logs))); // Order status switch ($result['PAYMENTSTATUS']) { case 'Completed': $id_order_state = _PS_OS_PAYMENT_; break; case 'Pending': $id_order_state = _PS_OS_PAYPAL_; break; default: $id_order_state = _PS_OS_ERROR_; } // Execute Module::validateOrder() $this->validateOrder($id_cart, $id_order_state, floatval($cart->getOrderTotal(true, 3)), $this->displayName, $message, array(), $id_currency); // Filling PayPal table $this->addOrder($id_transaction); // Displaying output $this->displayFinal($id_cart); }