From eb7fb0731567823bd4d8e69b10dc136419528bf9 Mon Sep 17 00:00:00 2001 From: PayXpert Integration Date: Tue, 24 Apr 2018 18:00:32 +0200 Subject: [PATCH] v1.1.1 Adapted structure to fit Prestashop guidelines, setting module name in payment options selection --- .version | 2 +- README.md | 1 + modules/payxpert/config.xml => config.xml | 4 +- controllers/front/iframe.php | 72 + .../front/index.php | 0 controllers/front/payment.php | 103 ++ controllers/front/redirect.php | 67 + controllers/front/return.php | 57 + controllers/front/validation.php | 153 +++ .../controllers => controllers}/index.php | 0 modules/payxpert/en.php => en.php | 0 modules/payxpert/fr.php => fr.php | 0 .../payxpert/images/index.php => index.php | 0 .../lib => lib}/Connect2PayClient.php | 0 .../views/templates => lib}/index.php | 0 logo.gif | Bin 0 -> 1310 bytes logo.png | Bin 0 -> 1310 bytes modules/payxpert/controllers/front/iframe.php | 71 - .../payxpert/controllers/front/payment.php | 101 -- .../payxpert/controllers/front/redirect.php | 67 - modules/payxpert/controllers/front/return.php | 56 - .../payxpert/controllers/front/validation.php | 131 -- modules/payxpert/logo.gif | Bin 591 -> 0 bytes modules/payxpert/logo.png | Bin 2472 -> 0 bytes modules/payxpert/payxpert.php | 1032 --------------- modules/payxpert/validation.php | 107 -- .../payxpert/views/templates/admin/infos.tpl | 26 - .../payment_infos_bank_transfer_ideal.tpl | 3 - ...payment_infos_bank_transfer_przelewy24.tpl | 3 - .../payment_infos_bank_transfer_sofort.tpl | 3 - .../front/payment_infos_credit_card.tpl | 3 - modules/payxpert/payment.php => payment.php | 17 +- payxpert.php | 1176 +++++++++++++++++ modules/payxpert/redirect.php => redirect.php | 13 +- validation.php | 107 ++ {modules/payxpert => views}/css/iframe.css | 2 +- {modules/payxpert => views}/css/index.php | 0 {modules/payxpert => views}/css/payxpert.css | 2 +- .../payxpert/images => views/img}/baian.png | Bin .../images => views/img}/fullpass.png | Bin {modules/payxpert => views/img}/index.php | 0 .../images => views/img}/logo-baian.gif | Bin .../images => views/img}/logo-baian.png | Bin .../images => views/img}/logo-fullpass.gif | Bin .../images => views/img}/logo-fullpass.png | Bin .../images => views/img}/logo-payxpert.gif | Bin .../images => views/img}/logo-payxpert.png | Bin .../images => views/img}/logo-payzone.gif | Bin .../images => views/img}/logo-payzone.png | Bin .../img}/payment-types/creditcard.png | Bin .../img}/payment-types/creditcard_icon.png | Bin .../img}/payment-types/ideal.png | Bin .../img/payment-types}/index.php | 0 .../img}/payment-types/przelewy24.png | Bin .../img}/payment-types/sofort.png | Bin .../images => views/img}/payxpert.png | Bin .../payxpert/images => views/img}/payzone.png | Bin {modules/payxpert/views => views}/index.php | 0 .../templates/admin/config.tpl | 9 +- views/templates/admin/index.php | 35 + views/templates/admin/infos.tpl | 26 + .../views => views}/templates/front/index.php | 0 .../templates/front/payment_error.tpl | 6 +- .../templates/front/payment_error17.tpl | 4 +- .../templates/front/payment_execution.tpl | 8 +- .../front/payment_execution_bank_transfer.tpl | 8 +- .../front/payment_execution_credit_card.tpl | 8 +- .../payment_infos_bank_transfer_ideal.tpl | 21 + ...payment_infos_bank_transfer_przelewy24.tpl | 21 + .../payment_infos_bank_transfer_sofort.tpl | 21 + .../front/payment_infos_credit_card.tpl | 21 + .../views => views}/templates/hook/iframe.tpl | 4 +- .../views => views}/templates/hook/index.php | 0 .../templates/hook/orderconfirmation.tpl | 10 +- .../templates/hook/payment.tpl | 6 +- .../views => views}/templates/hook/return.tpl | 4 +- views/templates/index.php | 36 + 77 files changed, 1979 insertions(+), 1648 deletions(-) rename modules/payxpert/config.xml => config.xml (91%) create mode 100644 controllers/front/iframe.php rename {modules/payxpert/controllers => controllers}/front/index.php (100%) create mode 100644 controllers/front/payment.php create mode 100644 controllers/front/redirect.php create mode 100644 controllers/front/return.php create mode 100644 controllers/front/validation.php rename {modules/payxpert/controllers => controllers}/index.php (100%) rename modules/payxpert/en.php => en.php (100%) rename modules/payxpert/fr.php => fr.php (100%) rename modules/payxpert/images/index.php => index.php (100%) rename {modules/payxpert/lib => lib}/Connect2PayClient.php (100%) rename {modules/payxpert/views/templates => lib}/index.php (100%) create mode 100644 logo.gif create mode 100644 logo.png delete mode 100644 modules/payxpert/controllers/front/iframe.php delete mode 100644 modules/payxpert/controllers/front/payment.php delete mode 100644 modules/payxpert/controllers/front/redirect.php delete mode 100644 modules/payxpert/controllers/front/return.php delete mode 100644 modules/payxpert/controllers/front/validation.php delete mode 100644 modules/payxpert/logo.gif delete mode 100644 modules/payxpert/logo.png delete mode 100644 modules/payxpert/payxpert.php delete mode 100644 modules/payxpert/validation.php delete mode 100644 modules/payxpert/views/templates/admin/infos.tpl delete mode 100644 modules/payxpert/views/templates/front/payment_infos_bank_transfer_ideal.tpl delete mode 100644 modules/payxpert/views/templates/front/payment_infos_bank_transfer_przelewy24.tpl delete mode 100644 modules/payxpert/views/templates/front/payment_infos_bank_transfer_sofort.tpl delete mode 100644 modules/payxpert/views/templates/front/payment_infos_credit_card.tpl rename modules/payxpert/payment.php => payment.php (77%) create mode 100644 payxpert.php rename modules/payxpert/redirect.php => redirect.php (86%) create mode 100644 validation.php rename {modules/payxpert => views}/css/iframe.css (95%) rename {modules/payxpert => views}/css/index.php (100%) rename {modules/payxpert => views}/css/payxpert.css (76%) rename {modules/payxpert/images => views/img}/baian.png (100%) rename {modules/payxpert/images => views/img}/fullpass.png (100%) rename {modules/payxpert => views/img}/index.php (100%) rename {modules/payxpert/images => views/img}/logo-baian.gif (100%) rename {modules/payxpert/images => views/img}/logo-baian.png (100%) rename {modules/payxpert/images => views/img}/logo-fullpass.gif (100%) rename {modules/payxpert/images => views/img}/logo-fullpass.png (100%) rename {modules/payxpert/images => views/img}/logo-payxpert.gif (100%) rename {modules/payxpert/images => views/img}/logo-payxpert.png (100%) rename {modules/payxpert/images => views/img}/logo-payzone.gif (100%) rename {modules/payxpert/images => views/img}/logo-payzone.png (100%) rename {modules/payxpert/images => views/img}/payment-types/creditcard.png (100%) rename {modules/payxpert/images => views/img}/payment-types/creditcard_icon.png (100%) rename {modules/payxpert/images => views/img}/payment-types/ideal.png (100%) rename {modules/payxpert/views/templates/admin => views/img/payment-types}/index.php (100%) rename {modules/payxpert/images => views/img}/payment-types/przelewy24.png (100%) rename {modules/payxpert/images => views/img}/payment-types/sofort.png (100%) rename {modules/payxpert/images => views/img}/payxpert.png (100%) rename {modules/payxpert/images => views/img}/payzone.png (100%) rename {modules/payxpert/views => views}/index.php (100%) rename {modules/payxpert/views => views}/templates/admin/config.tpl (94%) create mode 100644 views/templates/admin/index.php create mode 100644 views/templates/admin/infos.tpl rename {modules/payxpert/views => views}/templates/front/index.php (100%) rename {modules/payxpert/views => views}/templates/front/payment_error.tpl (93%) rename {modules/payxpert/views => views}/templates/front/payment_error17.tpl (93%) rename {modules/payxpert/views => views}/templates/front/payment_execution.tpl (91%) rename {modules/payxpert/views => views}/templates/front/payment_execution_bank_transfer.tpl (90%) rename {modules/payxpert/views => views}/templates/front/payment_execution_credit_card.tpl (90%) create mode 100644 views/templates/front/payment_infos_bank_transfer_ideal.tpl create mode 100644 views/templates/front/payment_infos_bank_transfer_przelewy24.tpl create mode 100644 views/templates/front/payment_infos_bank_transfer_sofort.tpl create mode 100644 views/templates/front/payment_infos_credit_card.tpl rename {modules/payxpert/views => views}/templates/hook/iframe.tpl (85%) rename {modules/payxpert/views => views}/templates/hook/index.php (100%) rename {modules/payxpert/views => views}/templates/hook/orderconfirmation.tpl (82%) rename {modules/payxpert/views => views}/templates/hook/payment.tpl (82%) rename {modules/payxpert/views => views}/templates/hook/return.tpl (82%) create mode 100644 views/templates/index.php diff --git a/.version b/.version index 1cc5f65..8cfbc90 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -1.1.0 \ No newline at end of file +1.1.1 \ No newline at end of file diff --git a/README.md b/README.md index 7a945bb..4500e68 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ The author of this plugin can NEVER be held responsible for this software. There is no warranty what so ever. You accept this by using this software. ## Changelog +* 1.1.1 - Setting module name in payment options selection * 1.1.0 - Added iframe option * 1.0.7 - Supports Prestashop 1.7 * 1.0.1 - Improve Prestashop versions support diff --git a/modules/payxpert/config.xml b/config.xml similarity index 91% rename from modules/payxpert/config.xml rename to config.xml index 1ae818a..54cc887 100644 --- a/modules/payxpert/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ payxpert - + @@ -10,4 +10,4 @@ 1 1 - \ No newline at end of file + diff --git a/controllers/front/iframe.php b/controllers/front/iframe.php new file mode 100644 index 0000000..627977d --- /dev/null +++ b/controllers/front/iframe.php @@ -0,0 +1,72 @@ +context->controller->addCSS(($this->module->getPath()) . 'views/css/iframe.css', 'all'); + $cart = $this->context->cart; + + $params = array(); + + // These should be filled only with Prestashop >= 1.7 + $paymentType = Tools::getValue('payment_type', null); + $paymentProvider = Tools::getValue('payment_provider', null); + + if (version_compare(_PS_VERSION_, '1.7', '>=')) { + if ($paymentType !== null && PayXpert\Connect2Pay\C2PValidate::isPayment($paymentType)) { + $payment = $this->module->getPaymentClient($cart, $paymentType, $paymentProvider); + + if ($payment->preparePayment() == false) { + $message = "PayXpert : can't prepare transaction - " . $payment->getClientErrorMessage(); + $this->module->addLog($message, 3); + Tools::redirect($this->module->getPageLinkCompat('order', true, null, "step=3")); + } + + $src = $payment->getCustomerRedirectURL(); + } + } + + $this->context->smarty->assign( + array(/* */ + 'src' => $src, /* */ + 'this_link_back' => $this->module->getPageLinkCompat('order', true, null, "step=3") + ) /* */ + ); + + $this->setTemplate('module:payxpert/views/templates/hook/iframe.tpl'); + } +} diff --git a/modules/payxpert/controllers/front/index.php b/controllers/front/index.php similarity index 100% rename from modules/payxpert/controllers/front/index.php rename to controllers/front/index.php diff --git a/controllers/front/payment.php b/controllers/front/payment.php new file mode 100644 index 0000000..73c2f3c --- /dev/null +++ b/controllers/front/payment.php @@ -0,0 +1,103 @@ +context->cart; + + // Default value for Prestashop < 1.7 + $template = 'payment_execution.tpl'; + + $params = array(); + + // These should be filled only with Prestashop >= 1.7 + $paymentType = Tools::getValue('payment_type', null); + $paymentProvider = Tools::getValue('payment_provider', null); + + if (version_compare(_PS_VERSION_, '1.7', '>=')) { + if ($paymentType !== null && PayXpert\Connect2Pay\C2PValidate::isPayment($paymentType)) { + $params['payment_type'] = $paymentType; + + if ($paymentProvider !== null && PayXpert\Connect2Pay\C2PValidate::isProvider($paymentProvider)) { + $params['payment_provider'] = $paymentProvider; + } + + switch ($paymentType) { + case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_TYPE_BANKTRANSFER: + $template = 'module:' . $this->module->name . '/views/templates/front/payment_execution_bank_transfer.tpl'; + + if (isset($params['payment_provider'])) { + switch ($params['payment_provider']) { + case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_PROVIDER_SOFORT: + $paymentLogo = 'sofort'; + break; + case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_PROVIDER_PRZELEWY24: + $paymentLogo = 'przelewy24'; + break; + case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_PROVIDER_IDEALKP: + $paymentLogo = 'ideal'; + break; + } + } + break; + default: + // Default is Credit Card + $template = 'module:' . $this->module->name . '/views/templates/front/payment_execution_credit_card.tpl'; + $paymentLogo = 'creditcard'; + break; + } + + $this->context->smarty->assign("payment_logo", $paymentLogo); + } + } + + $this->context->smarty->assign( + array(/* */ + 'nbProducts' => $cart->nbProducts(), /* */ + 'cust_currency' => (int)($cart->id_currency), /* */ + 'total' => $cart->getOrderTotal(true, Cart::BOTH), /* */ + 'isoCode' => $this->context->language->iso_code, /* */ + 'this_path' => $this->module->getPathUri(), /* */ + 'this_link' => $this->module->getModuleLinkCompat('payxpert', 'redirect', $params), /* */ + 'this_link_back' => $this->module->getPageLinkCompat('order', true, null, "step=3") /* */ + ) /* */ + ); + + $this->setTemplate($template); + } +} diff --git a/controllers/front/redirect.php b/controllers/front/redirect.php new file mode 100644 index 0000000..4385c53 --- /dev/null +++ b/controllers/front/redirect.php @@ -0,0 +1,67 @@ +context->cart)) { + $this->context->cart = new Cart(); + } + + $cart = $this->context->cart; + + // These should be filled only with Prestashop >= 1.7 + $paymentType = Tools::getValue('payment_type', null); + $paymentProvider = Tools::getValue('payment_provider', null); + + $errorMessage = $this->module->redirect($cart, $paymentType, $paymentProvider); + + $this->display_column_left = false; + parent::initContent(); + + $this->context->smarty->assign( + array(/* */ + 'errorMessage' => $errorMessage, /* */ + 'this_path' => $this->module->getPathUri(), /* */ + 'this_path_ssl' => Configuration::get('PS_SSL_ENABLED') ? 'https' : 'http' . '://' . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'modules/payxpert/', /* */ + 'this_link_back' => $this->module->getPageLinkCompat('order', true, null, "step=3") /* */ + ) /* */ + ); + + if (version_compare(_PS_VERSION_, '1.7', '>=')) { + $this->setTemplate('module:' . $this->module->name . '/views/templates/front/payment_error17.tpl'); + } else { + $this->setTemplate('payment_error.tpl'); + } + } +} diff --git a/controllers/front/return.php b/controllers/front/return.php new file mode 100644 index 0000000..ca7a91b --- /dev/null +++ b/controllers/front/return.php @@ -0,0 +1,57 @@ +context->cart)) { + $this->context->cart = new Cart(); + } + + $url = $this->module->getPageLinkCompat('order-confirmation'); + + $cart = $this->context->cart; + $customer = new Customer((int) ($cart->id_customer)); + $ctrlURLPrefix = Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://'; + + $url .= '?id_cart=' . (int)($cart->id) . '&id_module=' . (int)($this->module->id) . '&key=' . $customer->secure_key; + + $this->context->smarty->assign( + array(/* */ + 'url' => $url + ) /* */ + ); + + $this->setTemplate('module:' . $this->module->name . '/views/templates/hook/return.tpl'); + } +} diff --git a/controllers/front/validation.php b/controllers/front/validation.php new file mode 100644 index 0000000..178eaf0 --- /dev/null +++ b/controllers/front/validation.php @@ -0,0 +1,153 @@ +display_header = false; + $this->display_footer = false; + } + + /** + * + * @see FrontController::initContent() + */ + public function initContent() + { + // $cart = $this->context->cart; + require_once dirname(__FILE__) . '/../../lib/Connect2PayClient.php'; + + // init api + $c2pClient = new PayXpert\Connect2Pay\Connect2PayClient( + $this->module->getPayXpertUrl(), + Configuration::get('PAYXPERT_ORIGINATOR'), + html_entity_decode(Configuration::get('PAYXPERT_PASSWORD')) + ); + + if ($c2pClient->handleCallbackStatus()) { + $responseStatus = "KO"; + $responseMessage = "Callback validation failed"; + + $status = $c2pClient->getStatus(); + + // get the Error code + $errorCode = $status->getErrorCode(); + $errorMessage = $status->getErrorMessage(); + + $transaction = $status->getLastTransactionAttempt(); + + if ($transaction !== null) { + $transactionId = $transaction->getTransactionID(); + + $orderId = $status->getOrderID(); + $amount = number_format($transaction->getAmount() / 100, 2, '.', ''); + $callbackData = $status->getCtrlCustomData(); + + $severity = 1; + + $message = "PayXpert payment module: "; + $message .= "Received a new transaction status callback from " . $_SERVER["REMOTE_ADDR"] . ". "; + $message .= "Error code: " . $errorCode . " "; + $message .= "Error message: " . $errorMessage . " "; + $message .= "Transaction ID: " . $transactionId . " "; + $message .= "Order ID: " . $orderId . " "; + + $customer = null; + if (version_compare(_PS_VERSION_, '1.5', '>=')) { + Context::getContext()->cart = new Cart((int) $orderId); + $customer = new Customer((int) (Context::getContext()->cart->id_customer)); + } + + // For Prestashop >= 1.7, multi payment types is possible + switch ($transaction->getPaymentType()) { + case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_TYPE_BANKTRANSFER: + $paymentMean = $this->module->l('Bank Transfer'); + break; + default: + $paymentMean = $this->module->l('Credit Card'); + break; + } + + $paymentMean .= ' (PayXpert)'; + + if (!$customer) { + $message .= "Customer not found for order " . $orderId; + error_log($message); + $severity = 3; + } else { + if (!PayXpert::checkCallbackAuthenticityData($callbackData, Context::getContext()->cart->id, $customer->secure_key)) { + $message .= "Invalid callback received for order " . $orderId . ". Validation failed."; + error_log($message); + $severity = 3; + } else { + switch ($errorCode) { + case "000": + // Payment OK + $this->module->validateOrder( + (int) $orderId, + Configuration::get('PS_OS_PAYMENT'), + $amount, + $paymentMean, + $errorMessage, + array(), + null, + false + ); + break; + default: + $this->module->validateOrder( + (int) $orderId, + Configuration::get('PS_OS_ERROR'), + $amount, + $paymentMean, + $errorMessage, + array(), + null, + false + ); + $severity = 2; + break; + } + $responseStatus = "OK"; + $responseMessage = "Payment status recorded"; + } + } + } + + $this->module->addLog($message, $severity, $errorCode); + + // Send a response to mark this transaction as notified + $response = array("status" => $responseStatus, "message" => $responseMessage); + header("Content-type: application/json"); + echo json_encode($response); + exit(); + } else { + $this->module->addLog("PayXpert payment module:\n Callback received an incorrect status from " . $_SERVER["REMOTE_ADDR"], 2); + } + } +} diff --git a/modules/payxpert/controllers/index.php b/controllers/index.php similarity index 100% rename from modules/payxpert/controllers/index.php rename to controllers/index.php diff --git a/modules/payxpert/en.php b/en.php similarity index 100% rename from modules/payxpert/en.php rename to en.php diff --git a/modules/payxpert/fr.php b/fr.php similarity index 100% rename from modules/payxpert/fr.php rename to fr.php diff --git a/modules/payxpert/images/index.php b/index.php similarity index 100% rename from modules/payxpert/images/index.php rename to index.php diff --git a/modules/payxpert/lib/Connect2PayClient.php b/lib/Connect2PayClient.php similarity index 100% rename from modules/payxpert/lib/Connect2PayClient.php rename to lib/Connect2PayClient.php diff --git a/modules/payxpert/views/templates/index.php b/lib/index.php similarity index 100% rename from modules/payxpert/views/templates/index.php rename to lib/index.php diff --git a/logo.gif b/logo.gif new file mode 100644 index 0000000000000000000000000000000000000000..4a5899870223a78e05ac1c0ec9e7105b66ded245 GIT binary patch literal 1310 zcmV+(1>yRMP)ZOKenC7{`C-+%uhNOWP?7j{;)SRv--`QC5frg6~1 z&S9*L2mYGEpfFNedt>d5|54It5TF5RKnpN{z(oqcfQP+u>-KVyDEl1NP74z0nFO?eo(3bAS?Pq&;y;5K0QxFK8iapkttytoEKL2!-$vhN2+$Jhz!0OVJEd9hlNQn!=!!n_fc$R)+=hif}Nrl?%>r;^=nl6N133Ocj|)OcydWg35M8t{pqwyI-8|3P-s>!^ zn@3-Am=8DXBpRvZ@U=fUf467K5Uo)W41!VDD=ADV$kSbliIMaOo$(&FENNr?qGwn> zXCWVL+|E<8>L)P~5^#9iPQKXma(N~!ZIyu#xVSnS=%LC{Y+AB(oI4yeD`WHMPbK)R zue+=}WZrj`foSi!L|-BvfJkOiNZ|z_USGC~gIl)KHGH4%J1>>hgc7*p!YoJ_MKm#% zO|kFvA-1)y!_|hN(FD6!yvWI}D`YhoG^tFQ%Y(g$Ac>bqR&O5JWpafiUuYz`0%iO{ zqk}>t{jo!BsFrVc>?PzVh8`t}hHDtfjPb^aZy0rTMFmVrbbx3&OdvoAO)f*ssh$PE ztg0|!NASq?ri_k>OxQ%^`#9(SN;NT>N%Hx*qqsUpHGFraom3`Od7iL`%pAnFmNh8p z1OT=+uk=f~R}lzh2TT%3CGLngRXjVdd7P~ytaYXRgtK~A^L~LrU{`X#2;b4ceC`sy zjlnaTXrzJJ)eRi|`xk!h{*zQD&D+nv!j-{p66q8|SbI~rd+=rQsdzd}ERD7B&br++ zR!8~r+!4OM_+tp8IX17_DWqNGFE z3Gw^wj)0fWcn`fJL%i0ymT0(^tMMMYZxJSBp&|p{l@R92rZ#G;Y6DjKlY`@gnM@~X z|L-F8Rn>E9JG|Y+4pRkQ>K2I3!^6tq`$r^z) zvSg!cn^J#J3Pd#0NL$k?ZawJZ;IE%Czpjb1w=VE-EQvr(N>;9y!3c@KDcNlYA}j@B z#lqF>+3-G*P&JIu25~{YUl@812 zE}K@en%L+TYC>T&LQL>^!Tn3EuTrJLyRMP)ZOKenC7{`C-+%uhNOWP?7j{;)SRv--`QC5frg6~1 z&S9*L2mYGEpfFNedt>d5|54It5TF5RKnpN{z(oqcfQP+u>-KVyDEl1NP74z0nFO?eo(3bAS?Pq&;y;5K0QxFK8iapkttytoEKL2!-$vhN2+$Jhz!0OVJEd9hlNQn!=!!n_fc$R)+=hif}Nrl?%>r;^=nl6N133Ocj|)OcydWg35M8t{pqwyI-8|3P-s>!^ zn@3-Am=8DXBpRvZ@U=fUf467K5Uo)W41!VDD=ADV$kSbliIMaOo$(&FENNr?qGwn> zXCWVL+|E<8>L)P~5^#9iPQKXma(N~!ZIyu#xVSnS=%LC{Y+AB(oI4yeD`WHMPbK)R zue+=}WZrj`foSi!L|-BvfJkOiNZ|z_USGC~gIl)KHGH4%J1>>hgc7*p!YoJ_MKm#% zO|kFvA-1)y!_|hN(FD6!yvWI}D`YhoG^tFQ%Y(g$Ac>bqR&O5JWpafiUuYz`0%iO{ zqk}>t{jo!BsFrVc>?PzVh8`t}hHDtfjPb^aZy0rTMFmVrbbx3&OdvoAO)f*ssh$PE ztg0|!NASq?ri_k>OxQ%^`#9(SN;NT>N%Hx*qqsUpHGFraom3`Od7iL`%pAnFmNh8p z1OT=+uk=f~R}lzh2TT%3CGLngRXjVdd7P~ytaYXRgtK~A^L~LrU{`X#2;b4ceC`sy zjlnaTXrzJJ)eRi|`xk!h{*zQD&D+nv!j-{p66q8|SbI~rd+=rQsdzd}ERD7B&br++ zR!8~r+!4OM_+tp8IX17_DWqNGFE z3Gw^wj)0fWcn`fJL%i0ymT0(^tMMMYZxJSBp&|p{l@R92rZ#G;Y6DjKlY`@gnM@~X z|L-F8Rn>E9JG|Y+4pRkQ>K2I3!^6tq`$r^z) zvSg!cn^J#J3Pd#0NL$k?ZawJZ;IE%Czpjb1w=VE-EQvr(N>;9y!3c@KDcNlYA}j@B z#lqF>+3-G*P&JIu25~{YUl@812 zE}K@en%L+TYC>T&LQL>^!Tn3EuTrJLcontext->controller->addCSS(($this->module->getPath()) . 'css/iframe.css', 'all'); - $cart = $this->context->cart; - - $params = array(); - - // These should be filled only with Prestashop >= 1.7 - $paymentType = Tools::getValue('payment_type', null); - $paymentProvider = Tools::getValue('payment_provider', null); - - if (version_compare(_PS_VERSION_, '1.7', '>=')) { - if ($paymentType !== null && PayXpert\Connect2Pay\C2PValidate::isPayment($paymentType)) { - - $payment = $this->module->getPaymentClient($cart, $paymentType, $paymentProvider); - - if ($payment->preparePayment() == false) { - $message = "PayXpert : can't prepare transaction - " . $payment->getClientErrorMessage(); - $this->module->addLog($message, 3); - header('Location: ' . $this->module->getPageLinkCompat('order', true, NULL, "step=3")); - } - - $src = $payment->getCustomerRedirectURL(); - } - } - - $this->context->smarty->assign( - array(/* */ - 'src' => $src, /* */ - 'this_link_back' => $this->module->getPageLinkCompat('order', true, NULL, "step=3") - ) /* */ - ); - - $this->setTemplate('module:payxpert/views/templates/hook/iframe.tpl'); - } -} \ No newline at end of file diff --git a/modules/payxpert/controllers/front/payment.php b/modules/payxpert/controllers/front/payment.php deleted file mode 100644 index e2ab92e..0000000 --- a/modules/payxpert/controllers/front/payment.php +++ /dev/null @@ -1,101 +0,0 @@ -context->cart; - - // Default value for Prestashop < 1.7 - $template = 'payment_execution.tpl'; - - $params = array(); - - // These should be filled only with Prestashop >= 1.7 - $paymentType = Tools::getValue('payment_type', null); - $paymentProvider = Tools::getValue('payment_provider', null); - - if (version_compare(_PS_VERSION_, '1.7', '>=')) { - if ($paymentType !== null && PayXpert\Connect2Pay\C2PValidate::isPayment($paymentType)) { - $params['payment_type'] = $paymentType; - - if ($paymentProvider !== null && PayXpert\Connect2Pay\C2PValidate::isProvider($paymentProvider)) { - $params['payment_provider'] = $paymentProvider; - } - - switch ($paymentType) { - case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_TYPE_BANKTRANSFER: - $template = 'module:' . $this->module->name . '/views/templates/front/payment_execution_bank_transfer.tpl'; - - if (isset($params['payment_provider'])) { - switch ($params['payment_provider']) { - case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_PROVIDER_SOFORT: - $paymentLogo = 'sofort'; - break; - case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_PROVIDER_PRZELEWY24: - $paymentLogo = 'przelewy24'; - break; - case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_PROVIDER_IDEALKP: - $paymentLogo = 'ideal'; - break; - } - } - break; - default: - // Default is Credit Card - $template = 'module:' . $this->module->name . '/views/templates/front/payment_execution_credit_card.tpl'; - $paymentLogo = 'creditcard'; - break; - } - - $this->context->smarty->assign("payment_logo", $paymentLogo); - } - } - - $this->context->smarty->assign( - array(/* */ - 'nbProducts' => $cart->nbProducts(), /* */ - 'cust_currency' => intval($cart->id_currency), /* */ - 'total' => $cart->getOrderTotal(true, Cart::BOTH), /* */ - 'isoCode' => $this->context->language->iso_code, /* */ - 'this_path' => $this->module->getPathUri(), /* */ - 'this_link' => $this->module->getModuleLinkCompat('payxpert', 'redirect', $params), /* */ - 'this_link_back' => $this->module->getPageLinkCompat('order', true, NULL, "step=3") /* */ - ) /* */ - ); - - $this->setTemplate($template); - } -} \ No newline at end of file diff --git a/modules/payxpert/controllers/front/redirect.php b/modules/payxpert/controllers/front/redirect.php deleted file mode 100644 index acf0e7f..0000000 --- a/modules/payxpert/controllers/front/redirect.php +++ /dev/null @@ -1,67 +0,0 @@ -context->cart)) { - $this->context->cart = new Cart(); - } - - $cart = $this->context->cart; - - // These should be filled only with Prestashop >= 1.7 - $paymentType = Tools::getValue('payment_type', null); - $paymentProvider = Tools::getValue('payment_provider', null); - - $errorMessage = $this->module->redirect($cart, $paymentType, $paymentProvider); - - $this->display_column_left = false; - parent::initContent(); - - $this->context->smarty->assign( - array(/* */ - 'errorMessage' => $errorMessage, /* */ - 'this_path' => $this->module->getPathUri(), /* */ - 'this_path_ssl' => Configuration::get('PS_SSL_ENABLED') ? 'https' : 'http' . '://' . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . - 'modules/payxpert/', /* */ - 'this_link_back' => $this->module->getPageLinkCompat('order', true, NULL, "step=3") /* */ - ) /* */ - ); - - if (version_compare(_PS_VERSION_, '1.7', '>=')) { - $this->setTemplate('module:' . $this->module->name . '/views/templates/front/payment_error17.tpl'); - } else { - $this->setTemplate('payment_error.tpl'); - } - } -} diff --git a/modules/payxpert/controllers/front/return.php b/modules/payxpert/controllers/front/return.php deleted file mode 100644 index 1c02fa0..0000000 --- a/modules/payxpert/controllers/front/return.php +++ /dev/null @@ -1,56 +0,0 @@ -context->cart)) { - $this->context->cart = new Cart(); - } - - $url = $this->module->getPageLinkCompat('order-confirmation'); - - $cart = $this->context->cart; - $customer = new Customer((int) ($cart->id_customer)); - $ctrlURLPrefix = Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://'; - - $url .= '?id_cart=' . (int) ($cart->id) . '&id_module=' . (int) ($this->module->id) . '&key=' . $customer->secure_key; - - $this->context->smarty->assign( - array(/* */ - 'url' => $url - ) /* */ - ); - - $this->setTemplate('module:' . $this->module->name . '/views/templates/hook/return.tpl'); - } -} diff --git a/modules/payxpert/controllers/front/validation.php b/modules/payxpert/controllers/front/validation.php deleted file mode 100644 index 956f67c..0000000 --- a/modules/payxpert/controllers/front/validation.php +++ /dev/null @@ -1,131 +0,0 @@ -display_header = false; - $this->display_footer = false; - } - - /** - * - * @see FrontController::initContent() - */ - public function initContent() { - // $cart = $this->context->cart; - require_once dirname(__FILE__) . '/../../lib/Connect2PayClient.php'; - - // init api - $c2pClient = new PayXpert\Connect2Pay\Connect2PayClient($this->module->getPayXpertUrl(), Configuration::get('PAYXPERT_ORIGINATOR'), - html_entity_decode(Configuration::get('PAYXPERT_PASSWORD'))); - - if ($c2pClient->handleCallbackStatus()) { - $responseStatus = "KO"; - $responseMessage = "Callback validation failed"; - - $status = $c2pClient->getStatus(); - - // get the Error code - $errorCode = $status->getErrorCode(); - $errorMessage = $status->getErrorMessage(); - - $transaction = $status->getLastTransactionAttempt(); - - if ($transaction !== null) { - $transactionId = $transaction->getTransactionID(); - - $orderId = $status->getOrderID(); - $amount = number_format($transaction->getAmount() / 100, 2, '.', ''); - $callbackData = $status->getCtrlCustomData(); - - $severity = 1; - - $message = "PayXpert payment module: "; - $message .= "Received a new transaction status callback from " . $_SERVER["REMOTE_ADDR"] . ". "; - $message .= "Error code: " . $errorCode . " "; - $message .= "Error message: " . $errorMessage . " "; - $message .= "Transaction ID: " . $transactionId . " "; - $message .= "Order ID: " . $orderId . " "; - - $customer = null; - if (version_compare(_PS_VERSION_, '1.5', '>=')) { - Context::getContext()->cart = new Cart((int) $orderId); - $customer = new Customer((int) (Context::getContext()->cart->id_customer)); - } - - // For Prestashop >= 1.7, multi payment types is possible - switch ($transaction->getPaymentType()) { - case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_TYPE_BANKTRANSFER: - $paymentMean = $this->module->l('Bank Transfer'); - break; - default: - $paymentMean = $this->module->l('Credit Card'); - break; - } - $paymentMean .= ' (PayXpert)'; - - if (!$customer) { - $message .= "Customer not found for order " . $orderId; - error_log($message); - $severity = 3; - } else { - if (!PayXpert::checkCallbackAuthenticityData($callbackData, Context::getContext()->cart->id, $customer->secure_key)) { - $message .= "Invalid callback received for order " . $orderId . ". Validation failed."; - error_log($message); - $severity = 3; - } else { - switch ($errorCode) { - case "000": - // Payment OK - $this->module->validateOrder((int) $orderId, Configuration::get('PS_OS_PAYMENT'), $amount, $paymentMean, $errorMessage, - array(), NULL, false); - break; - default: - $this->module->validateOrder((int) $orderId, Configuration::get('PS_OS_ERROR'), $amount, $paymentMean, $errorMessage, - array(), NULL, false); - $severity = 2; - break; - } - $responseStatus = "OK"; - $responseMessage = "Payment status recorded"; - } - } - } - - $this->module->addLog($message, $severity, $errorCode); - - // Send a response to mark this transaction as notified - $response = array("status" => $responseStatus, "message" => $responseMessage); - header("Content-type: application/json"); - echo json_encode($response); - exit(); - } else { - $this->module->addLog("PayXpert payment module:\n Callback received an incorrect status from " . $_SERVER["REMOTE_ADDR"], 2); - } - } -} diff --git a/modules/payxpert/logo.gif b/modules/payxpert/logo.gif deleted file mode 100644 index 69a9bbb824049944ac79a2ae5c490168ca948c96..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 591 zcmV-V0loR6&TIT%6y@_n5VMw^Yr%i z_Q}f1t-i|f^Yz5e*V@_Fd!fB8E-%Z+!?niLqrK77-{!H#)!*LS_4M?+!@T|e{qOPf z%*@KHx4*&8*SWW~r@6?YywCLV@b&QR)zs3gsicLXy7~F}a+R;k%gM3A&wrPy#mUFu z-P-Bu>i78g_4W0+$<%F|yt&5FTv0u@=;Yqd*xl;u?99!~j;p-z@bTf~;x{!i{QUc? zzs%^~*6{7;c%{M4&dpw4UiSC+=+1goTEOh=UtciG*kqATy16auyvtX;~v8hj4F9aVTMVd20ZLHYx}! zcTRZ{5qNfkXATr}brpF^W_WWYH(+{K3?U{Sc};D2csXMNSOa5P%m7U|>LEgb08xMS>g=azaBO06RnDSxf)` diff --git a/modules/payxpert/logo.png b/modules/payxpert/logo.png deleted file mode 100644 index b56962efe3d8b6b24e47d7d581200737044a522b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2472 zcmV;Z30L-sP)Qb$_pnS89y+s^ zZPVwx$Nk@;YaHT^Y1UdCv-U&NuK$4(eXm(g9cA4_cT*T&=twRF{A0{UZ1b;)S1+B%dxNEI7*y~uxtkx%k57Df!iT^ctxu=b+^xav%7mv zpW~Gwg=5QkLHw;@7^ud48 z;5SUmzDqMK#KHmU1QQ_Nd-kW}Kv}CI8VYV&vS|MLoB@20 z9EIO5BOwF1DvxB@hDYF$H#o#X{{D{U_zN@J+t*IFY}D=AO{bH?FYej9KjZiL-C`~} z0mfXVT;W?=65Hm_?YcRcDI%2`MN?D;?}$jLHRR}AF>N>%1xs3^Sas>bNFo+p%Niew zMF|HL4?nv3iEZ0oxN%xz+=cSLCh%dh^>nuF?CfY?I+!jXo0-7;1_xEUiXlaSYRhy@ z1?>%9T(__ri)J^|%`~7dbX;D*a*U|G*h#t*3Iqc4WZCa(%{dDGO9HGrT2+Vd?_~2~FgXs7UcxlVfui$xJ7a;W z!HPK%Ts40d;tgS{l`4{g$YoO4*8d{S!e|_&4SFZSGwW>d5 zxe0tk2g=0sNI1CZvP*i`D~5xi;WRzEj<_V?bgqJo;lZVCFj2^}plQbTID6oO-@ z7}(K|XSQv}d&f`0!`G4gV90&u*KfZS8#mmI_O45iK6B#HkyQHk!H`%z$A$Vo5>P7| zk*#T4Z};q*)44KInJIV$4~n{tv3w0JksxkcHUo=05~LmsXFny!;f(|PvE_Hq;q^Z= zcpaRb7(=C^;@WGj!hIWlj1||d25Jh%M}|({=PrlW^@NT}U)WU^AS3VH9%{*uG;69Roay{`~BE(@7?(BcfO5C zLj>a!ITTAO$hr`V$Dmh9KzIjoAPC8)KB=nZRjdmFN9`o@c=C91^!89RPJ-frS~Ve3 zJC}FHkeC)BoWt-~8eZ8sfTxMwhYlYloH;izOW@X9)?ocTcVTW%4@T1yD5Z0l+1iG- z*&+sy97dr~q@XfvnjD%gNRof$y<%EaavpQ7RU2#pjl}Rj*!s9VRCW7&@IoqNNp~Pymc#X3a#6S+`Y# zSEBJFyJl~8Ccj+c*ml2QlUXoE(rE0+<)(Ur4UPBPAafyh2>F9}aO+EW{*QZ6R*E#! z8phHoG&eQj;m04t*KX+p^O_Swqlh&o(Am{W`vS)}Vgk(exg(6^uvd>E;1^Gf@ zhi%zEa?Pkh3&aK4rT0dMFU+HnUURh6LhQ}sz`mDo`cwvGHAijd@q_Q*Nyi78$Oo#c z9F9Nb17e8H!p2|z8uzUGDh$oR;IR{!)zL-c6mYknYPCuRHG=HqSt@|X^yvxeB+pEY zx>jMqA0zd9!0Ywo1vdM159`!<*dcuB%0<}q<}nzmjmB`$WjD=dzFJXN+Tad}gohrR zgXF0+I7^4j+wX?O8xh{b64lc?PWX@W|XmtLld@1<5B6$l=;(}T~?3SjNkT^K%F zgdBTQnsQoEnpCcqKHOHc)^1C z;6_GM@N#4{l=ZtOhw+yaDGW^%$Z$kD1Q2=e<9vbpD`ZmNx~fZG+SBG69zRRsB_a}O zAPuoe2{jTOYPPCAK#4!X$jSn-%Gs2$ab$ms2j3sX;gKxHi61_J-zXV6%GKJjbY?Q!JG1fiL{l?aws{U`V!NW2pP)5tlO#!F zl23HuVGC-NIKxpgUauE^Nk%vlf-Ij~|Ji+v6T*cZz@e6B%bKfJ%jYzsBQ9f*qT&ouugL9P6Pn7+?2^nPNvI|&-? zjqKsfWql;OehTb4Prm>7%ZQH7^JnM7i-}2$RY{}-nu^{=*QS*0{?F5cY5{Uoqh;2t{I5@-I~dd99GXtbKm$jE}bBSfuc$x`Qej&OG& mWR-Hname = 'payxpert'; - $this->version = '1.1.0'; - - $this->tab = 'payments_gateways'; - - $this->author = 'PayXpert'; - $this->need_instance = 1; - - $this->controllers = array('payment', 'validation'); - $this->is_eu_compatible = 1; - - if (version_compare(_PS_VERSION_, '1.5', '>=')) { - $this->ps_versions_compliancy = array('min' => '1.4.0.0', 'max' => _PS_VERSION_); - } - - if (version_compare(_PS_VERSION_, '1.6', '>=')) { - $this->bootstrap = true; - } - - parent::__construct(); - - $this->displayName = 'PayXpert Payment Solutions'; - $this->description = $this->l("Accept payments today with PayXpert"); - $this->confirmUninstall = $this->l('Are you sure about removing these details?'); - - if (!count(Currency::checkPaymentCurrencies($this->id))) { - $this->warning = $this->l('No currency has been set for this module.'); - } - - /* For 1.4.3 and less compatibility */ - $updateConfig = array('PS_OS_CHEQUE' => 1, 'PS_OS_PAYMENT' => 2, 'PS_OS_PREPARATION' => 3, 'PS_OS_SHIPPING' => 4, - 'PS_OS_DELIVERED' => 5, 'PS_OS_CANCELED' => 6, 'PS_OS_REFUND' => 7, 'PS_OS_ERROR' => 8, 'PS_OS_OUTOFSTOCK' => 9, - 'PS_OS_BANKWIRE' => 10, 'PS_OS_PAYPAL' => 11, 'PS_OS_WS_PAYMENT' => 12); - - foreach ($updateConfig as $u => $v) { - if (!Configuration::get($u) || (int) Configuration::get($u) < 1) { - if (defined('_' . $u . '_') && (int) constant('_' . $u . '_') > 0) { - Configuration::updateValue($u, constant('_' . $u . '_')); - } else { - Configuration::updateValue($u, $v); - } - } - } - } - - /** - * Install method - */ - public function install() { - // call parents - if (!parent::install()) { - $errorMessage = Tools::displayError($this->l('PayXpert installation : install failed.')); - $this->addLog($errorMessage, 3, '000002'); - return false; - } - - // Add hook methods - $hookResult = $this->registerHook('paymentReturn'); - if (version_compare(_PS_VERSION_, '1.7', '<')) { - $hookResult = $hookResult && $this->registerHook('payment'); - } else { - $hookResult = $hookResult && $this->registerHook('paymentOptions'); - } - - if (!$hookResult) { - $errorMessage = Tools::displayError($this->l('PayXpert installation : hooks failed.')); - $this->addLog($errorMessage, 3, '000002'); - - return false; - } - - // Add configuration parameters - foreach ($this->getModuleParameters() as $parameter) { - if (!Configuration::updateValue($parameter, '')) { - $errorMessage = Tools::displayError($this->l('PayXpert installation : configuration failed.')); - $this->addLog($errorMessage, 3, '000002'); - - return false; - } - } - - $this->addLog($this->l('PayXpert installation : installation successful')); - - return true; - } - - /** - * Uninstall the module - * - * @return boolean - */ - public function uninstall() { - $result = parent::uninstall(); - - foreach ($this->getModuleParameters() as $parameter) { - $result = $result || Configuration::deleteByName($parameter); - } - - return $result; - } - - private function getModuleParameters() { - $moduleParameters = array( /* */ - 'PAYXPERT_ORIGINATOR', /* */ - 'PAYXPERT_PASSWORD', /* */ - 'PAYXPERT_URL', /* */ - 'PAYXPERT_MERCHANT_NOTIF', /* */ - 'PAYXPERT_MERCHANT_NOTIF_TO', /* */ - 'PAYXPERT_MERCHANT_NOTIF_LANG' /* */ - ); - - if (version_compare(_PS_VERSION_, '1.7', '>=')) { - $moduleParameters[] = 'PAYXPERT_PAYMENT_TYPE_CREDIT_CARD'; - $moduleParameters[] = 'PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_SOFORT'; - $moduleParameters[] = 'PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_PRZELEWY24'; - $moduleParameters[] = 'PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_IDEAL'; - $moduleParameters[] = 'PAYXPERT_IS_IFRAME'; - } - - return $moduleParameters; - } - - public function checkPaymentOption($params) { - // if module disabled, can't go through - if (!$this->active) { - return false; - } - - // Check if currency ok - if (!$this->checkCurrency($params['cart'])) { - return false; - } - - // Check if module is configured - if (Configuration::get('PAYXPERT_ORIGINATOR') == "" && Configuration::get('PAYXPERT_PASSWORD') == "") { - return false; - } - - return true; - } - - /** - * Hook payment options - * - * @since Prestashop 1.7 - * @param type $params - * @return type - */ - public function hookPaymentOptions($params) { - if (!$this->checkPaymentOption($params)) { - return; - } - - $controller = 'payment'; - - if ($this->isIframeMode()) { - $controller = 'iframe'; - } - - $this->smarty->assign($this->getTemplateVarInfos()); - - $payment_options = array(); - - $ccOption = $this->getCreditCardPaymentOption($controller); - if ($ccOption != null) { - $payment_options[] = $ccOption; - } - $sofortOption = $this->getBankTransferViaSofortPaymentOption($controller); - if ($sofortOption != null) { - $payment_options[] = $sofortOption; - } - $przelewy24Option = $this->getBankTransferViaPrzelewy24PaymentOption($controller); - if ($przelewy24Option != null) { - $payment_options[] = $przelewy24Option; - } - $idealOption = $this->getBankTransferViaIDealPaymentOption($controller); - if ($idealOption != null) { - $payment_options[] = $idealOption; - } - - return $payment_options; - } - - /** - * - * @since Prestashop 1.7 - */ - public function getCreditCardPaymentOption($controller) { - if (Configuration::get('PAYXPERT_PAYMENT_TYPE_CREDIT_CARD') == "true") { - $option = new PrestaShop\PrestaShop\Core\Payment\PaymentOption(); - $option->setCallToActionText($this->l('Pay by Credit Card')); - $option->setAction( - $this->context->link->getModuleLink($this->name, $controller, - array('payment_type' => PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_TYPE_CREDITCARD), true)); - - $this->context->smarty->assign('pxpCCLogo', - Media::getMediaPath(_PS_MODULE_DIR_ . $this->name . '/images/payment-types/creditcard.png')); - $option->setAdditionalInformation( - $this->context->smarty->fetch('module:payxpert/views/templates/front/payment_infos_credit_card.tpl')); - - return $option; - } - - return null; - } - - /** - * - * @since Prestashop 1.7 - */ - public function getBankTransferViaSofortPaymentOption($controller) { - if (Configuration::get('PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_SOFORT') == "true") { - $option = new PrestaShop\PrestaShop\Core\Payment\PaymentOption(); - $option->setCallToActionText($this->l('Pay by Bank Transfer via Sofort')); - $option->setAction( - $this->context->link->getModuleLink($this->name, $controller, - array('payment_type' => PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_TYPE_BANKTRANSFER, - 'payment_provider' => PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_PROVIDER_SOFORT), true)); - - $this->context->smarty->assign("pxpSofortLogo", - Media::getMediaPath(_PS_MODULE_DIR_ . $this->name . '/images/payment-types/sofort.png')); - $option->setAdditionalInformation( - $this->context->smarty->fetch('module:payxpert/views/templates/front/payment_infos_bank_transfer_sofort.tpl')); - - return $option; - } - - return null; - } - - /** - * - * @since Prestashop 1.7 - */ - public function getBankTransferViaPrzelewy24PaymentOption($controller) { - if (Configuration::get('PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_PRZELEWY24') == "true") { - $option = new PrestaShop\PrestaShop\Core\Payment\PaymentOption(); - $option->setCallToActionText($this->l('Pay by Bank Transfer via Przelewy24')); - $option->setAction( - $this->context->link->getModuleLink($this->name, $controller, - array('payment_type' => PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_TYPE_BANKTRANSFER, - 'payment_provider' => PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_PROVIDER_PRZELEWY24), true)); - - $this->context->smarty->assign("pxpPrzelewy24Logo", - Media::getMediaPath(_PS_MODULE_DIR_ . $this->name . '/images/payment-types/przelewy24.png')); - $option->setAdditionalInformation( - $this->context->smarty->fetch('module:payxpert/views/templates/front/payment_infos_bank_transfer_przelewy24.tpl')); - - return $option; - } - - return null; - } - - /** - * - * @since Prestashop 1.7 - */ - public function getBankTransferViaIDealPaymentOption($controller) { - if (Configuration::get('PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_IDEAL') == "true") { - $option = new PrestaShop\PrestaShop\Core\Payment\PaymentOption(); - $option->setCallToActionText($this->l('Pay by Bank Transfer via iDeal')); - $option->setAction( - $this->context->link->getModuleLink($this->name, $controller, - array('payment_type' => PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_TYPE_BANKTRANSFER, - 'payment_provider' => PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_PROVIDER_IDEALKP), true)); - - $this->context->smarty->assign("pxpIdealLogo", Media::getMediaPath(_PS_MODULE_DIR_ . $this->name . '/images/payment-types/ideal.png')); - $option->setAdditionalInformation( - $this->context->smarty->fetch('module:payxpert/views/templates/front/payment_infos_bank_transfer_ideal.tpl')); - - return $option; - } - - return null; - } - - public function getTemplateVarInfos() { - $cart = $this->context->cart; - - return array(/* */ - 'nbProducts' => $cart->nbProducts(), /* */ - 'cust_currency' => $cart->id_currency, /* */ - 'total' => $cart->getOrderTotal(true, Cart::BOTH), /* */ - 'isoCode' => $this->context->language->iso_code /* */ - ); - } - - /** - * Hook payment for Prestashop < 1.7 - * - * @param type $params - * @return type - */ - public function hookPayment($params) { - if (!$this->checkPaymentOption($params)) { - return; - } - $this->assignSmartyVariable('this_path', $this->_path); - $this->assignSmartyVariable('this_path_ssl', - (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://') . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . - __PS_BASE_URI__ . 'modules/payxpert/'); - $this->assignSmartyVariable('this_link', $this->getModuleLinkCompat('payxpert', 'payment')); - - if (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) { - $this->context->controller->addCSS($this->_path . 'css/payxpert.css'); - } - - return $this->display(__FILE__, 'views/templates/hook/payment.tpl'); - } - - /** - * Hook paymentReturn - * - * Displays order confirmation - * - * @param type $params - * @return type - */ - public function hookPaymentReturn($params) { - if (!$this->active) { - return; - } - - if (isset($params['objOrder'])) { - // For Prestashop < 1.7 - $order = $params['objOrder']; - } else { - $order = $params['order']; - } - - switch ($order->getCurrentState()) { - case _PS_OS_PAYMENT_: - case _PS_OS_OUTOFSTOCK_: - $this->assignSmartyVariable('status', 'ok'); - break; - - case _PS_OS_BANKWIRE_: - $this->assignSmartyVariable('status', 'pending'); - break; - - case _PS_OS_ERROR_: - default: - $this->assignSmartyVariable('status', 'failed'); - break; - } - - $this->assignSmartyVariable('this_link_contact', $this->getPageLinkCompat('contact', true)); - - return $this->display(__FILE__, 'views/templates/hook/orderconfirmation.tpl'); - } - - /** - * Init the payment - * - * In this method, we'll start to initialize the transaction - * And redirect the customer - * - * For Prestashop >= 1.5 - * - * @global type $cookie - * @param Cart $cart - * @return type - */ - public function redirect($cart, $paymentType = null, $paymentProvider = null) { - // if module disabled, can't go through - if (!$this->active) { - return "Module is not active"; - } - - // Check if currency ok - if (!$this->checkCurrency($cart)) { - return "Incorrect currency"; - } - - // Check if module is configured - if (Configuration::get('PAYXPERT_ORIGINATOR') == "" && Configuration::get('PAYXPERT_PASSWORD') == "") { - return "Module is not setup"; - } - - if ($paymentType == null || !PayXpert\Connect2Pay\C2PValidate::isPayment($paymentType)) { - $paymentType = PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_TYPE_CREDITCARD; - } - - if (!$this->checkPaymentTypeAndProvider($paymentType, $paymentProvider)) { - return "Payment type or provider is not enabled"; - } - - $payment = $this->getPaymentClient($cart, $paymentType, $paymentProvider); - - // prepare API - if ($payment->preparePayment() == false) { - $message = "PayXpert : can't prepare transaction - " . $payment->getClientErrorMessage(); - $this->addLog($message, 3); - return $message; - } - - header('Location: ' . $payment->getCustomerRedirectURL()); - exit(); - } - - /** - * Generates the Connect2Pay payment URL - * - * For Prestashop >= 1.5 - * - * @global type $cookie - * @param Cart $cart - * @return type - */ - public function getPaymentClient($cart, $paymentType = null, $paymentProvider = null) { - - // get all informations - $customer = new Customer((int) ($cart->id_customer)); - $currency = new Currency((int) ($cart->id_currency)); - $carrier = new Carrier((int) ($cart->id_carrier)); - $addr_delivery = new Address((int) ($cart->id_address_delivery)); - $addr_invoice = new Address((int) ($cart->id_address_invoice)); - - $invoice_state = new State((int) ($addr_invoice->id_state)); - $invoice_country = new Country((int) ($addr_invoice->id_country)); - - $delivery_state = new State((int) ($addr_delivery->id_state)); - $delivery_country = new Country((int) ($addr_delivery->id_country)); - - $invoice_phone = (!empty($addr_invoice->phone)) ? $addr_invoice->phone : $addr_invoice->phone_mobile; - $delivery_phone = (!empty($addr_delivery->phone)) ? $addr_delivery->phone : $addr_delivery->phone_mobile; - - // init api - $c2pClient = new PayXpert\Connect2Pay\Connect2PayClient($this->getPayXpertUrl(), Configuration::get('PAYXPERT_ORIGINATOR'), - html_entity_decode(Configuration::get('PAYXPERT_PASSWORD'))); - - // customer informations - $c2pClient->setShopperID($cart->id_customer); - $c2pClient->setShopperEmail($customer->email); - $c2pClient->setShopperFirstName(substr($customer->firstname, 0, 35)); - $c2pClient->setShopperLastName(substr($customer->lastname, 0, 35)); - $c2pClient->setShopperCompany(substr($addr_invoice->company, 0, 128)); - $c2pClient->setShopperAddress(substr(trim($addr_invoice->address1 . ' ' . $addr_invoice->address2), 0, 255)); - $c2pClient->setShopperZipcode(substr($addr_invoice->postcode, 0, 10)); - $c2pClient->setShopperCity(substr($addr_invoice->city, 0, 50)); - $c2pClient->setShopperState(substr($invoice_state->name, 0, 30)); - $c2pClient->setShopperCountryCode($invoice_country->iso_code); - $c2pClient->setShopperPhone(substr(trim($invoice_phone), 0, 20)); - - // Shipping information - $c2pClient->setShipToFirstName(substr($addr_delivery->firstname, 0, 35)); - $c2pClient->setShipToLastName(substr($addr_delivery->lastname, 0, 35)); - $c2pClient->setShipToCompany(substr($addr_delivery->company, 0, 128)); - $c2pClient->setShipToPhone(substr(trim($delivery_phone), 0, 20)); - $c2pClient->setShipToAddress(substr(trim($addr_delivery->address1 . " " . $addr_delivery->address2), 0, 255)); - $c2pClient->setShipToZipcode(substr($addr_delivery->postcode, 0, 10)); - $c2pClient->setShipToCity(substr($addr_delivery->city, 0, 50)); - $c2pClient->setShipToState(substr($delivery_state->name, 0, 30)); - $c2pClient->setShipToCountryCode($delivery_country->iso_code); - $c2pClient->setShippingName(substr($carrier->name, 0, 50)); - $c2pClient->setShippingType(PayXpert\Connect2Pay\Connect2PayClient::_SHIPPING_TYPE_PHYSICAL); - - // Order informations - $c2pClient->setOrderID(substr(pSQL($cart->id), 0, 100)); - $c2pClient->setOrderDescription(substr($this->l('Invoice:') . pSQL($cart->id), 0, 255)); - $c2pClient->setCustomerIP($_SERVER['REMOTE_ADDR']); - $c2pClient->setCurrency($currency->iso_code); - - $total = number_format($cart->getOrderTotal(true, 3) * 100, 0, '.', ''); - - $c2pClient->setAmount($total); - $c2pClient->setOrderCartContent($this->getProductsApi($cart)); - $c2pClient->setPaymentMode(PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_MODE_SINGLE); - $c2pClient->setPaymentType($paymentType); - if ($paymentProvider != null && PayXpert\Connect2Pay\C2PValidate::isProvider($paymentProvider)) { - $c2pClient->setProvider($paymentProvider); - } - $c2pClient->setCtrlCustomData(PayXpert::getCallbackAuthenticityData($c2pClient->getOrderID(), $customer->secure_key)); - - // Merchant notifications - if (Configuration::get('PAYXPERT_MERCHANT_NOTIF') === "true" && Configuration::get('PAYXPERT_MERCHANT_NOTIF_TO')) { - $c2pClient->setMerchantNotification(true); - $c2pClient->setMerchantNotificationTo(Configuration::get('PAYXPERT_MERCHANT_NOTIF_TO')); - if (Configuration::get('PAYXPERT_MERCHANT_NOTIF_LANG')) { - $c2pClient->setMerchantNotificationLang(Configuration::get('PAYXPERT_MERCHANT_NOTIF_LANG')); - } - } - - $ctrlURLPrefix = Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://'; - - if (version_compare(_PS_VERSION_, '1.5', '<')) { - $c2pClient->setCtrlCallbackURL($ctrlURLPrefix . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'modules/payxpert/validation.php'); - $c2pClient->setCtrlRedirectURL( - $ctrlURLPrefix . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'order-confirmation.php?id_cart=' . (int) ($cart->id) . '&id_module=' . - (int) ($this->id) . '&key=' . $customer->secure_key); - } else { - $c2pClient->setCtrlCallbackURL($this->context->link->getModuleLink('payxpert', 'validation')); - $c2pClient->setCtrlRedirectURL($this->getModuleLinkCompat('payxpert', 'return')); - } - - return $c2pClient; - } - - /** - * Return array of product to fill Api Product properties - * - * @param Cart $cart - * @return array - */ - protected function getProductsApi($cart) { - $products = array(); - - foreach ($cart->getProducts() as $product) { - $obj = new Product((int) $product['id_product']); - $products[] = array( /* */ - 'CartProductId' => $product['id_product'], /* */ - 'CartProductName' => $product['name'], /* */ - 'CartProductUnitPrice' => $product['price'], /* */ - 'CartProductQuantity' => $product['quantity'], /* */ - 'CartProductBrand' => $obj->manufacturer_name, /* */ - 'CartProductMPN' => $product['ean13'], /* */ - 'CartProductCategoryName' => $product['category'], /* */ - 'CartProductCategoryID' => $product['id_category_default'] /* */ - ); - } - - return $products; - } - - public function getContent() { - if (Tools::isSubmit('btnSubmit')) { - $this->_postValidation(); - - if (!count($this->_postErrors)) { - $this->_postProcess(); - } else { - foreach ($this->_postErrors as $err) { - $this->_html .= $this->displayError($err); - } - } - } else { - $this->_html .= '
'; - } - - $this->_html .= $this->display(__FILE__, '/views/templates/admin/infos.tpl'); - - if (version_compare(_PS_VERSION_, '1.6', '<')) { - /* Prestashop parameter names must not exceed 32 chars for v < 1.6 */ - $this->assignSmartyVariable('PAYXPERT_ORIGINATOR', - Tools::safeOutput(Tools::getValue('PAYXPERT_ORIGINATOR', Configuration::get('PAYXPERT_ORIGINATOR')))); - $this->assignSmartyVariable('PAYXPERT_URL', Tools::safeOutput(Tools::getValue('PAYXPERT_URL', Configuration::get('PAYXPERT_URL')))); - - $merchantNotifications = (Configuration::get('PAYXPERT_MERCHANT_NOTIF') == "true") ? "true" : "false"; - if (Tools::getValue('PAYXPERT_MERCHANT_NOTIF')) { - $merchantNotifications = (in_array(Tools::getValue('PAYXPERT_MERCHANT_NOTIF'), array("true", "1", "on"))) ? "true" : "false"; - } - $this->assignSmartyVariable('PAYXPERT_MERCHANT_NOTIF', $merchantNotifications); - $this->assignSmartyVariable('PAYXPERT_MERCHANT_NOTIF_TO', - Tools::safeOutput(Tools::getValue('PAYXPERT_MERCHANT_NOTIF_TO', Configuration::get('PAYXPERT_MERCHANT_NOTIF_TO')))); - $this->assignSmartyVariable('PAYXPERT_MERCHANT_NOTIF_LANG', - Tools::safeOutput(Tools::getValue('PAYXPERT_MERCHANT_NOTIF_LANG', Configuration::get('PAYXPERT_MERCHANT_NOTIF_LANG')))); - - $this->_html .= $this->display(__FILE__, '/views/templates/admin/config.tpl'); - } else { - $this->_html .= $this->renderForm(); - } - - return $this->_html; - } - - public function getConfigFieldsValues() { - // Handle checkboxes - $merchantNotif = Tools::getValue('PAYXPERT_MERCHANT_NOTIF', Configuration::get('PAYXPERT_MERCHANT_NOTIF')); - - $result = array( /* */ - 'PAYXPERT_ORIGINATOR' => Tools::getValue('PAYXPERT_ORIGINATOR', Configuration::get('PAYXPERT_ORIGINATOR')), /* */ - 'PAYXPERT_URL' => Tools::getValue('PAYXPERT_URL', Configuration::get('PAYXPERT_URL')), /* */ - 'PAYXPERT_MERCHANT_NOTIF' => ($merchantNotif === "true" || $merchantNotif == 1) ? 1 : 0, /* */ - 'PAYXPERT_MERCHANT_NOTIF_TO' => Tools::getValue('PAYXPERT_MERCHANT_NOTIF_TO', Configuration::get('PAYXPERT_MERCHANT_NOTIF_TO')), /* */ - 'PAYXPERT_MERCHANT_NOTIF_LANG' => Tools::getValue('PAYXPERT_MERCHANT_NOTIF_LANG', - Configuration::get('PAYXPERT_MERCHANT_NOTIF_LANG')), /* */ - ); - - if (version_compare(_PS_VERSION_, '1.7', '>=')) { - $creditCardPaymentType = Tools::getValue('PAYXPERT_PAYMENT_TYPE_CREDIT_CARD', Configuration::get('PAYXPERT_PAYMENT_TYPE_CREDIT_CARD')); - $sofortPaymentType = Tools::getValue('PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_SOFORT', - Configuration::get('PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_SOFORT')); - $przelewy24PaymentType = Tools::getValue('PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_PRZELEWY24', - Configuration::get('PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_PRZELEWY24')); - $idealPaymentType = Tools::getValue('PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_IDEAL', - Configuration::get('PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_IDEAL')); - $isIframe = Tools::getValue('PAYXPERT_IS_IFRAME', - Configuration::get('PAYXPERT_IS_IFRAME')); - - $result['PAYXPERT_PAYMENT_TYPE_CREDIT_CARD'] = ($creditCardPaymentType === "true" || $creditCardPaymentType == 1) ? 1 : 0; - $result['PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_SOFORT'] = ($sofortPaymentType === "true" || $sofortPaymentType == 1) ? 1 : 0; - $result['PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_PRZELEWY24'] = ($przelewy24PaymentType === "true" || $przelewy24PaymentType == 1) ? 1 : 0; - $result['PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_IDEAL'] = ($idealPaymentType === "true" || $idealPaymentType == 1) ? 1 : 0; - $result['PAYXPERT_IS_IFRAME'] = ($isIframe === "true" || $isIframe == 1) ? 1 : 0; - } - - return $result; - } - - public function renderForm() { - $fields_form = array( - 'form' => array( /* */ - 'legend' => array( /* */ - 'title' => $this->l('Settings'), /* */ - 'icon' => 'icon-gears' /* */ - ), /* */ - 'input' => array( /* */ - array( /* */ - 'type' => 'text', /* */ - 'name' => 'PAYXPERT_ORIGINATOR', /* */ - 'label' => $this->l('Originator ID'), /* */ - 'desc' => $this->l('The identifier of your Originator'), /* */ - 'required' => true /* */ - ), - array( /* */ - 'type' => 'password', /* */ - 'name' => 'PAYXPERT_PASSWORD', /* */ - 'label' => $this->l('Originator password'), /* */ - 'desc' => $this->l('The password associated with your Originator (leave empty to keep the current one)'), /* */ - 'hint' => $this->l('Leave empty to keep the current one'), /* */ - 'required' => false /* */ - ), - array( /* */ - 'type' => 'text', /* */ - 'name' => 'PAYXPERT_URL', /* */ - 'label' => $this->l('Payment Page URL'), /* */ - 'desc' => $this->l('Leave this field empty unless you have been given an URL'), /* */ - 'required' => false /* */ - ), - array( /* */ - 'type' => 'switch', /* */ - 'name' => 'PAYXPERT_MERCHANT_NOTIF', /* */ - 'label' => $this->l('Merchant notifications'), /* */ - 'desc' => $this->l('Whether or not to send a notification to the merchant for each processed payment'), /* */ - 'required' => false, /* */ - 'is_bool' => true, /* */ - 'values' => array( /* */ - array('id' => 'notif_on', 'value' => 1, 'label' => $this->l('Enabled')), /* */ - array('id' => 'notif_off', 'value' => 0, 'label' => $this->l('Disabled')) /* */ - ) /* */ - ), /* */ - array( /* */ - 'type' => 'text', /* */ - 'name' => 'PAYXPERT_MERCHANT_NOTIF_TO', /* */ - 'label' => $this->l('Merchant notifications recipient'), /* */ - 'desc' => $this->l('Recipient email address for merchant notifications'), /* */ - 'required' => false, /* */ - 'size' => 100 /* */ - ), /* */ - array( /* */ - 'type' => 'select', /* */ - 'name' => 'PAYXPERT_MERCHANT_NOTIF_LANG', /* */ - 'label' => $this->l('Merchant notifications lang'), /* */ - 'desc' => $this->l('Language to use for merchant notifications'), /* */ - 'required' => false, /* */ - 'options' => array( /* */ - 'query' => array( /* */ - array('id_option' => 'en', 'name' => $this->l('English')), /* */ - array('id_option' => 'fr', 'name' => $this->l('French')), /* */ - array('id_option' => 'es', 'name' => $this->l('Spanish')), /* */ - array('id_option' => 'it', 'name' => $this->l('Italian')) /* */ - ), /* */ - 'id' => 'id_option', /* */ - 'name' => 'name' /* */ - ) /* */ - ) /* */ - ), /* */ - 'submit' => array('title' => $this->l('Update settings')) /* */ - ) /* */ - ); - - if (version_compare(_PS_VERSION_, '1.7', '>=')) { - $fields_form['form']['input'][] = array( /* */ - 'type' => 'switch', /* */ - 'name' => 'PAYXPERT_PAYMENT_TYPE_CREDIT_CARD', /* */ - 'label' => $this->l('Credit Card'), /* */ - 'desc' => $this->l('Enable payment type: Credit Card'), /* */ - 'required' => false, /* */ - 'is_bool' => true, /* */ - 'values' => array(/* */ - array('id' => 'cc_on', 'value' => 1, 'label' => $this->l('Enabled')), /* */ - array('id' => 'cc_off', 'value' => 0, 'label' => $this->l('Disabled')) /* */ - ) /* */ - ); - $fields_form['form']['input'][] = array( /* */ - 'type' => 'switch', /* */ - 'name' => 'PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_SOFORT', /* */ - 'label' => $this->l('Bank Transfert via Sofort'), /* */ - 'desc' => $this->l('Enable payment type: Bank Transfer via Sofort'), /* */ - 'required' => false, /* */ - 'is_bool' => true, /* */ - 'values' => array(/* */ - array('id' => 'sofort_on', 'value' => 1, 'label' => $this->l('Enabled')), /* */ - array('id' => 'sofort_off', 'value' => 0, 'label' => $this->l('Disabled')) /* */ - ) /* */ - ); - $fields_form['form']['input'][] = array( /* */ - 'type' => 'switch', /* */ - 'name' => 'PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_PRZELEWY24', /* */ - 'label' => $this->l('Bank Transfert via Przelewy24'), /* */ - 'desc' => $this->l('Enable payment type: Bank Transfer via Przelewy24'), /* */ - 'required' => false, /* */ - 'is_bool' => true, /* */ - 'values' => array(/* */ - array('id' => 'przelewy24_on', 'value' => 1, 'label' => $this->l('Enabled')), /* */ - array('id' => 'przelewy24_off', 'value' => 0, 'label' => $this->l('Disabled')) /* */ - ) /* */ - ); - $fields_form['form']['input'][] = array( /* */ - 'type' => 'switch', /* */ - 'name' => 'PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_IDEAL', /* */ - 'label' => $this->l('Bank Transfert via iDeal'), /* */ - 'desc' => $this->l('Enable payment type: Bank Transfer via iDeal'), /* */ - 'required' => false, /* */ - 'is_bool' => true, /* */ - 'values' => array(/* */ - array('id' => 'ideal_on', 'value' => 1, 'label' => $this->l('Enabled')), /* */ - array('id' => 'ideal_off', 'value' => 0, 'label' => $this->l('Disabled')) /* */ - ) /* */ - ); - $fields_form['form']['input'][] = array( /* */ - 'type' => 'switch', /* */ - 'name' => 'PAYXPERT_IS_IFRAME', /* */ - 'label' => $this->l('Iframe mode'), /* */ - 'desc' => $this->l('Enable iframe mode'), /* */ - 'required' => false, /* */ - 'is_bool' => true, /* */ - 'values' => array(/* */ - array('id' => 'iframe_on', 'value' => 1, 'label' => $this->l('Enabled')), /* */ - array('id' => 'iframe_off', 'value' => 0, 'label' => $this->l('Disabled')) /* */ - ) /* */ - ); - } - - $helper = new HelperForm(); - $helper->show_toolbar = false; - $helper->table = $this->table; - $lang = new Language((int) Configuration::get('PS_LANG_DEFAULT')); - $helper->default_form_language = $lang->id; - $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get( - 'PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; - $this->fields_form = array(); - - $helper->identifier = $this->identifier; - $helper->submit_action = 'btnSubmit'; - $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&tab_module=' . - $this->tab . '&module_name=' . $this->name; - $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->tpl_vars = array( /* */ - 'fields_value' => $this->getConfigFieldsValues(), /* */ - 'languages' => $this->context->controller->getLanguages(), /* */ - 'id_language' => $this->context->language->id /* */ - ); - - return $helper->generateForm(array($fields_form)); - } - - private function _postValidation() { - if (Tools::isSubmit('btnSubmit')) { - if (!Tools::getValue('PAYXPERT_ORIGINATOR')) { - $this->_postErrors[] = $this->l('Originator is required.'); - } - - if (!Configuration::get('PAYXPERT_PASSWORD') && !Tools::getValue('PAYXPERT_PASSWORD')) { - $this->_postErrors[] = $this->l('Password is required.'); - } - - if (in_array(Tools::getValue('PAYXPERT_MERCHANT_NOTIF'), array("true", "1", "on")) && !Tools::getValue('PAYXPERT_MERCHANT_NOTIF_TO')) { - $this->_postErrors[] = $this->l('Merchant notifications recipient is required.'); - } - - if (Tools::getValue('PAYXPERT_MERCHANT_NOTIF_TO') && !Validate::isEmail(Tools::getValue('PAYXPERT_MERCHANT_NOTIF_TO'))) { - $this->_postErrors[] = $this->l('Merchant notifications recipient must be a valid email address.'); - } - - if (!in_array(Tools::getValue('PAYXPERT_MERCHANT_NOTIF_LANG'), array("en", "fr", "es", "it"))) { - $this->_postErrors[] = $this->l('Merchant notification lang is not valid.'); - } - } - } - - protected function _postProcess() { - if (Tools::isSubmit('btnSubmit')) { - Configuration::updateValue('PAYXPERT_ORIGINATOR', Tools::getValue('PAYXPERT_ORIGINATOR')); - - if (Tools::getValue('PAYXPERT_PASSWORD')) { - // Manually handle HTML special chars to avoid losing them - Configuration::updateValue('PAYXPERT_PASSWORD', htmlentities(Tools::getValue('PAYXPERT_PASSWORD'))); - } - - Configuration::updateValue('PAYXPERT_URL', Tools::getValue('PAYXPERT_URL')); - - Configuration::updateValue('PAYXPERT_MERCHANT_NOTIF_TO', Tools::getValue('PAYXPERT_MERCHANT_NOTIF_TO')); - - if (in_array(Tools::getValue('PAYXPERT_MERCHANT_NOTIF_LANG'), array("en", "fr", "es", "it"))) { - Configuration::updateValue('PAYXPERT_MERCHANT_NOTIF_LANG', Tools::getValue('PAYXPERT_MERCHANT_NOTIF_LANG')); - } - - // Handle checkboxes - $checkboxes = array( /* */ - 'PAYXPERT_MERCHANT_NOTIF' /* */ - ); - if (version_compare(_PS_VERSION_, '1.7', '>=')) { - $checkboxes[] = 'PAYXPERT_PAYMENT_TYPE_CREDIT_CARD'; - $checkboxes[] = 'PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_SOFORT'; - $checkboxes[] = 'PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_PRZELEWY24'; - $checkboxes[] = 'PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_IDEAL'; - $checkboxes[] = 'PAYXPERT_IS_IFRAME'; - } - - foreach ($checkboxes as $checkbox) { - if (in_array(Tools::getValue($checkbox), array("true", "1", "on"))) { - Configuration::updateValue($checkbox, "true"); - } else { - Configuration::updateValue($checkbox, "false"); - } - } - } - - if (version_compare(_PS_VERSION_, '1.6', '>=')) { - $this->_html .= $this->displayConfirmation($this->l('Configuration updated')); - } else { - $this->_html .= '
' . $this->l('Configuration updated') . '
'; - - return true; - } - } - - private function checkPaymentTypeAndProvider($paymentType, $paymentProvider) { - // For Prestashop >=1.7, check that the payment type is enabled - if (version_compare(_PS_VERSION_, '1.7.0', '>=') === true) { - switch ($paymentType) { - case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_TYPE_CREDITCARD: - return Configuration::get('PAYXPERT_PAYMENT_TYPE_CREDIT_CARD') === "true"; - case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_TYPE_BANKTRANSFER: - if ($paymentProvider !== null) { - switch ($paymentProvider) { - case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_PROVIDER_SOFORT: - return Configuration::get('PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_SOFORT') === "true"; - case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_PROVIDER_PRZELEWY24: - return Configuration::get('PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_PRZELEWY24') === "true"; - case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_PROVIDER_IDEALKP: - return Configuration::get('PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_IDEAL') === "true"; - } - } - break; - } - } else { - return true; - } - - return false; - } - - private function checkCurrency($cart) { - $currency_order = new Currency((int) ($cart->id_currency)); - $currencies_module = $this->getCurrency((int) $cart->id_currency); - - if (is_array($currencies_module)) { - foreach ($currencies_module as $currency_module) { - if ($currency_order->id == $currency_module['id_currency']) { - return true; - } - } - } - - return false; - } - - /** - * Get PayXpert Url depending of the env - * - * @return string Url - */ - public function getPayXpertUrl() { - $url = Configuration::get('PAYXPERT_URL'); - - if (strlen(trim($url)) <= 0) { - $url = 'https://connect2.payxpert.com/'; - } - - return $url; - } - - /** - * Get the iframe config value - * - * @return boolean - */ - public function isIframeMode() { - $is_iframe = Configuration::get('PAYXPERT_IS_IFRAME'); - - return $is_iframe === 'true' ? true : false; - } - - /** - * Returns the modules path - * - * @return string - */ - public function getPath() { - return $this->_path; - } - - /* Theses functions are used to support all versions of Prestashop */ - public function assignSmartyVariable($name, $value) { - - // Check if context smarty variable is available - if (isset($this->context->smarty)) { - return $this->context->smarty->assign($name, $value); - } else { - // Use the global variable - global $smarty; - - return $smarty->assign($name, $value); - } - } - - public function getModuleLinkCompat($module, $controller = 'default', $params = null) { - if (class_exists('Context')) { - if (!$params) { - $params = array(); - } - - return Context::getContext()->link->getModuleLink($module, $controller, $params); - } else { - if ($controller == 'default') { - if ($params) { - $params = "?" . $params; - } - - return Configuration::get('PS_SSL_ENABLED') ? 'https' : 'http' . '://' . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . $module . '.php' . - $params; - } else { - return Configuration::get('PS_SSL_ENABLED') ? 'https' : 'http' . '://' . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . - 'modules/payxpert/' . $controller . '.php'; - } - } - } - - public function getPageLinkCompat($controller, $ssl = null, $id_lang = null, $request = null, $request_url_encode = false, $id_shop = null) { - if (class_exists('Context')) { - return Context::getContext()->link->getPageLink($controller, $ssl, $id_lang, $request, $request_url_encode, $id_shop); - } else { - if ($controller == 'contact') { - return Configuration::get('PS_SSL_ENABLED') ? 'https' : 'http' . '://' . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'contact-form.php'; - } else { - $params = (isset($params)) ? "?" . $params : ""; - - return Configuration::get('PS_SSL_ENABLED') ? 'https' : 'http' . '://' . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . $controller . - '.php' . $params; - } - } - } - - public function addLog($message, $severity = 1, $errorCode = null, $objectType = null, $objectId = null, $allowDuplicate = true) { - if (class_exists('PrestaShopLogger')) { - PrestaShopLogger::addLog($message, $severity, $errorCode, $objectType, $objectId, $allowDuplicate); - } else if (class_exists('Logger')) { - Logger::addLog($message, $severity, $errorCode, $objectType, $objectId, $allowDuplicate); - } else { - error_log($message . "(" . $errorCode . ")"); - } - } - - /* Callback authenticity check methods */ - public static function getCallbackAuthenticityData($orderId, $secure_key) { - return sha1($orderId . $secure_key . html_entity_decode(Configuration::get('PAYXPERT_PASSWORD'))); - } - - public static function checkCallbackAuthenticityData($callbackData, $orderId, $secure_key) { - return (strcasecmp($callbackData, PayXpert::getCallbackAuthenticityData($orderId, $secure_key)) === 0); - } - - /* Theses functions are only used for Prestashop prior to version 1.5 */ - public function execPayment($cart) { - global $cookie; - - $this->assignSmartyVariable('nbProducts', $cart->nbProducts()); - $this->assignSmartyVariable('cust_currency', $cart->id_currency); - $this->assignSmartyVariable('currencies', $this->getCurrency()); - $this->assignSmartyVariable('total', $cart->getOrderTotal(true, 3)); - $this->assignSmartyVariable('isoCode', Language::getIsoById(intval($cookie->id_lang))); - $this->assignSmartyVariable('this_path', $this->_path); - $this->assignSmartyVariable('this_link', $this->getModuleLinkCompat('payxpert', 'redirect')); - $this->assignSmartyVariable('this_link_back', $this->getPageLinkCompat('order', true, NULL, "step=3")); - - return $this->display(__FILE__, '/views/templates/front/payment_execution.tpl'); - } - - public function displayErrorPage($message) { - $this->assignSmartyVariable('errorMessage', $message); - $this->assignSmartyVariable('this_link_back', $this->getPageLinkCompat('order', true, NULL, "step=3")); - - return $this->display(__FILE__, '/views/templates/front/payment_error.tpl'); - } -} \ No newline at end of file diff --git a/modules/payxpert/validation.php b/modules/payxpert/validation.php deleted file mode 100644 index bd3e4c6..0000000 --- a/modules/payxpert/validation.php +++ /dev/null @@ -1,107 +0,0 @@ -getPayXpertUrl(), Configuration::get('PAYXPERT_ORIGINATOR'), - html_entity_decode(Configuration::get('PAYXPERT_PASSWORD'))); - -if ($c2pClient->handleCallbackStatus()) { - - $status = $c2pClient->getStatus(); - - // get the Error code - $errorCode = $status->getErrorCode(); - $errorMessage = $status->getErrorMessage(); - - $transaction = $status->getLastTransactionAttempt(); - - if ($transaction !== null) { - $transactionId = $transaction->getTransactionID(); - - $orderId = $status->getOrderID(); - $amount = number_format($status->getAmount() / 100, 2, '.', ''); - $callbackData = $status->getCtrlCustomData(); - - $message = "PayXpert payment module: "; - - // load the customer cart and perform some checks - $cart = new Cart((int) ($orderId)); - if (!$cart->id) { - $message .= "Cart is empty: " . $orderId; - error_log($message); - } - - $responseStatus = "KO"; - $responseMessage = "Callback validation failed"; - $customer = new Customer((int) ($cart->id_customer)); - - if (!$customer) { - $message .= "Customer is empty for order " . $orderId; - error_log($message); - } else { - if (!PayXpert::checkCallbackAuthenticityData($callbackData, $cart->id, $customer->secure_key)) { - $message .= "Invalid callback received for order " . $orderId . ". Validation failed."; - error_log($message); - } else { - $responseStatus = "OK"; - $responseMessage = "Status recorded"; - - $message .= "Error code: " . $errorCode . "
"; - $message .= "Error message: " . $errorMessage . "
"; - $message .= "Transaction ID: " . $transactionId . "
"; - $message .= "Order ID: " . $orderId . "
"; - - error_log(str_replace("
", " ", $message)); - - // To avoid issue with conversion rate get the amount from the order - $amount = $cart->getOrderTotal(true, 3); - - $paymentMean = $payxpert->l('Credit Card') . ' (PayXpert)'; - - switch ($errorCode) { - case "000": - /* Payment OK */ - $payxpert->validateOrder((int) $orderId, _PS_OS_PAYMENT_, $amount, $paymentMean, $message); - break; - default: - $payxpert->validateOrder((int) $orderId, _PS_OS_ERROR_, $amount, $paymentMean, $message); - break; - } - } - } - } - - // Send a response to mark this transaction as notified - $response = array("status" => $responseStatus, "message" => $responseMessage); - header("Content-type: application/json"); - echo json_encode($response); -} diff --git a/modules/payxpert/views/templates/admin/infos.tpl b/modules/payxpert/views/templates/admin/infos.tpl deleted file mode 100644 index 417d1ad..0000000 --- a/modules/payxpert/views/templates/admin/infos.tpl +++ /dev/null @@ -1,26 +0,0 @@ -{* - Copyright 2013-2017 PayXpert - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - @author Alexandre Chatiron -*} -{if $smarty.const._PS_VERSION_ >= 1.6} -
-{/if} - -

{l s='This module allows you to accept secure payments.' mod='payxpert'}

-





-{if $smarty.const._PS_VERSION_ >= 1.6} -
-{/if} \ No newline at end of file diff --git a/modules/payxpert/views/templates/front/payment_infos_bank_transfer_ideal.tpl b/modules/payxpert/views/templates/front/payment_infos_bank_transfer_ideal.tpl deleted file mode 100644 index 37f2f9c..0000000 --- a/modules/payxpert/views/templates/front/payment_infos_bank_transfer_ideal.tpl +++ /dev/null @@ -1,3 +0,0 @@ -
-

iDeal{l s='Use your bank account information with the iDeal provider to pay your order' mod='payxpert'}

-
\ No newline at end of file diff --git a/modules/payxpert/views/templates/front/payment_infos_bank_transfer_przelewy24.tpl b/modules/payxpert/views/templates/front/payment_infos_bank_transfer_przelewy24.tpl deleted file mode 100644 index 6539034..0000000 --- a/modules/payxpert/views/templates/front/payment_infos_bank_transfer_przelewy24.tpl +++ /dev/null @@ -1,3 +0,0 @@ -
-

Przelewy24{l s='Use your bank account information with the Przelewy24 provider to pay your order' mod='payxpert'}

-
\ No newline at end of file diff --git a/modules/payxpert/views/templates/front/payment_infos_bank_transfer_sofort.tpl b/modules/payxpert/views/templates/front/payment_infos_bank_transfer_sofort.tpl deleted file mode 100644 index b07ab79..0000000 --- a/modules/payxpert/views/templates/front/payment_infos_bank_transfer_sofort.tpl +++ /dev/null @@ -1,3 +0,0 @@ -
-

Sofort{l s='Use your bank account information with the Sofort provider to pay your order' mod='payxpert'}

-
\ No newline at end of file diff --git a/modules/payxpert/views/templates/front/payment_infos_credit_card.tpl b/modules/payxpert/views/templates/front/payment_infos_credit_card.tpl deleted file mode 100644 index b971ee3..0000000 --- a/modules/payxpert/views/templates/front/payment_infos_credit_card.tpl +++ /dev/null @@ -1,3 +0,0 @@ -
-

Credit Card{l s='Use your credit card information in a secured form to pay your order' mod='payxpert'}

-
\ No newline at end of file diff --git a/modules/payxpert/payment.php b/payment.php similarity index 77% rename from modules/payxpert/payment.php rename to payment.php index 8206a57..8b49a74 100644 --- a/modules/payxpert/payment.php +++ b/payment.php @@ -1,6 +1,6 @@ context->cookie; +} + +if (!isset($cart)) { + $cart = $this->context->cart; +} + if (!$cookie->isLogged()) { - Tools::redirect('authentication.php?back=order.php'); + Tools::redirect('authentication.php?back=order.php'); } $payxpert = new PayXpert(); echo $payxpert->execPayment($cart); -require_once(dirname(__FILE__) . '/../../footer.php'); \ No newline at end of file +require_once(dirname(__FILE__) . '/../../footer.php'); diff --git a/payxpert.php b/payxpert.php new file mode 100644 index 0000000..75df3dd --- /dev/null +++ b/payxpert.php @@ -0,0 +1,1176 @@ +name = 'payxpert'; + $this->version = '1.1.1'; + $this->module_key = '36f0012c50e666c56801493e0ad709eb'; + + $this->tab = 'payments_gateways'; + + $this->author = 'PayXpert'; + $this->need_instance = 1; + + $this->controllers = array('payment', 'validation'); + $this->is_eu_compatible = 1; + + if (version_compare(_PS_VERSION_, '1.5', '>=')) { + $this->ps_versions_compliancy = array('min' => '1.4.0.0', 'max' => _PS_VERSION_); + } + + if (version_compare(_PS_VERSION_, '1.6', '>=')) { + $this->bootstrap = true; + } + + parent::__construct(); + + $this->displayName = 'PayXpert Payment Solutions'; + $this->description = $this->l("Accept payments today with PayXpert"); + $this->confirmUninstall = $this->l('Are you sure about removing these details?'); + + if (!count(Currency::checkPaymentCurrencies($this->id))) { + $this->warning = $this->l('No currency has been set for this module.'); + } + + /* For 1.4.3 and less compatibility */ + $updateConfig = array('PS_OS_CHEQUE' => 1, 'PS_OS_PAYMENT' => 2, 'PS_OS_PREPARATION' => 3, 'PS_OS_SHIPPING' => 4, + 'PS_OS_DELIVERED' => 5, 'PS_OS_CANCELED' => 6, 'PS_OS_REFUND' => 7, 'PS_OS_ERROR' => 8, 'PS_OS_OUTOFSTOCK' => 9, + 'PS_OS_BANKWIRE' => 10, 'PS_OS_PAYPAL' => 11, 'PS_OS_WS_PAYMENT' => 12); + + foreach ($updateConfig as $u => $v) { + if (!Configuration::get($u) || (int) Configuration::get($u) < 1) { + if (defined('_' . $u . '_') && (int) constant('_' . $u . '_') > 0) { + Configuration::updateValue($u, constant('_' . $u . '_')); + } else { + Configuration::updateValue($u, $v); + } + } + } + } + + /** + * Install method + */ + public function install() + { + // call parents + if (!parent::install()) { + $errorMessage = Tools::displayError($this->l('PayXpert installation : install failed.')); + $this->addLog($errorMessage, 3, '000002'); + return false; + } + + // Add hook methods + $hookResult = $this->registerHook('paymentReturn'); + if (version_compare(_PS_VERSION_, '1.7', '<')) { + $hookResult = $hookResult && $this->registerHook('payment'); + } else { + $hookResult = $hookResult && $this->registerHook('paymentOptions'); + } + + if (!$hookResult) { + $errorMessage = Tools::displayError($this->l('PayXpert installation : hooks failed.')); + $this->addLog($errorMessage, 3, '000002'); + + return false; + } + + // Add configuration parameters + foreach ($this->getModuleParameters() as $parameter) { + if (!Configuration::updateValue($parameter, '')) { + $errorMessage = Tools::displayError($this->l('PayXpert installation : configuration failed.')); + $this->addLog($errorMessage, 3, '000002'); + + return false; + } + } + + $this->addLog($this->l('PayXpert installation : installation successful')); + + return true; + } + + /** + * Uninstall the module + * + * @return boolean + */ + public function uninstall() + { + $result = parent::uninstall(); + + foreach ($this->getModuleParameters() as $parameter) { + $result = $result || Configuration::deleteByName($parameter); + } + + return $result; + } + + private function getModuleParameters() + { + $moduleParameters = array( /* */ + 'PAYXPERT_ORIGINATOR', /* */ + 'PAYXPERT_PASSWORD', /* */ + 'PAYXPERT_URL', /* */ + 'PAYXPERT_MERCHANT_NOTIF', /* */ + 'PAYXPERT_MERCHANT_NOTIF_TO', /* */ + 'PAYXPERT_MERCHANT_NOTIF_LANG' /* */ + ); + + if (version_compare(_PS_VERSION_, '1.7', '>=')) { + $moduleParameters[] = 'PAYXPERT_PAYMENT_TYPE_CREDIT_CARD'; + $moduleParameters[] = 'PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_SOFORT'; + $moduleParameters[] = 'PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_PRZELEWY24'; + $moduleParameters[] = 'PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_IDEAL'; + $moduleParameters[] = 'PAYXPERT_IS_IFRAME'; + } + + return $moduleParameters; + } + + public function checkPaymentOption($params) + { + // if module disabled, can't go through + if (!$this->active) { + return false; + } + + // Check if currency ok + if (!$this->checkCurrency($params['cart'])) { + return false; + } + + // Check if module is configured + if (Configuration::get('PAYXPERT_ORIGINATOR') == "" && Configuration::get('PAYXPERT_PASSWORD') == "") { + return false; + } + + return true; + } + + /** + * Hook payment options + * + * @since Prestashop 1.7 + * @param type $params + * @return type + */ + public function hookPaymentOptions($params) + { + if (!$this->checkPaymentOption($params)) { + return; + } + + $controller = 'payment'; + + if ($this->isIframeMode()) { + $controller = 'iframe'; + } + + $this->smarty->assign($this->getTemplateVarInfos()); + + $payment_options = array(); + + $ccOption = $this->getCreditCardPaymentOption($controller); + if ($ccOption != null) { + $payment_options[] = $ccOption; + } + $sofortOption = $this->getBankTransferViaSofortPaymentOption($controller); + if ($sofortOption != null) { + $payment_options[] = $sofortOption; + } + $przelewy24Option = $this->getBankTransferViaPrzelewy24PaymentOption($controller); + if ($przelewy24Option != null) { + $payment_options[] = $przelewy24Option; + } + $idealOption = $this->getBankTransferViaIDealPaymentOption($controller); + if ($idealOption != null) { + $payment_options[] = $idealOption; + } + + return $payment_options; + } + + /** + * + * @since Prestashop 1.7 + */ + public function getCreditCardPaymentOption($controller) + { + if (Configuration::get('PAYXPERT_PAYMENT_TYPE_CREDIT_CARD') == "true") { + $option = new PrestaShop\PrestaShop\Core\Payment\PaymentOption(); + $option->setModuleName($this->name); + $option->setCallToActionText($this->l('Pay by Credit Card')); + $option->setAction( + $this->context->link->getModuleLink( + $this->name, + $controller, + array('payment_type' => PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_TYPE_CREDITCARD), + true + ) + ); + + $this->context->smarty->assign( + 'pxpCCLogo', + Media::getMediaPath(_PS_MODULE_DIR_ . $this->name . '/views/img/payment-types/creditcard.png') + ); + + $option->setAdditionalInformation($this->context->smarty->fetch('module:payxpert/views/templates/front/payment_infos_credit_card.tpl')); + + return $option; + } + + return null; + } + + /** + * + * @since Prestashop 1.7 + */ + public function getBankTransferViaSofortPaymentOption($controller) + { + if (Configuration::get('PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_SOFORT') == "true") { + $option = new PrestaShop\PrestaShop\Core\Payment\PaymentOption(); + $option->setModuleName($this->name); + $option->setCallToActionText($this->l('Pay by Bank Transfer via Sofort')); + $option->setAction( + $this->context->link->getModuleLink( + $this->name, + $controller, + array( + 'payment_type' => PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_TYPE_BANKTRANSFER, + 'payment_provider' => PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_PROVIDER_SOFORT + ), + true + ) + ); + + $this->context->smarty->assign( + "pxpSofortLogo", + Media::getMediaPath(_PS_MODULE_DIR_ . $this->name . '/views/img/payment-types/sofort.png') + ); + + $option->setAdditionalInformation($this->context->smarty->fetch('module:payxpert/views/templates/front/payment_infos_bank_transfer_sofort.tpl')); + + return $option; + } + + return null; + } + + /** + * + * @since Prestashop 1.7 + */ + public function getBankTransferViaPrzelewy24PaymentOption($controller) + { + if (Configuration::get('PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_PRZELEWY24') == "true") { + $option = new PrestaShop\PrestaShop\Core\Payment\PaymentOption(); + $option->setModuleName($this->name); + $option->setCallToActionText($this->l('Pay by Bank Transfer via Przelewy24')); + $option->setAction( + $this->context->link->getModuleLink( + $this->name, + $controller, + array( + 'payment_type' => PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_TYPE_BANKTRANSFER, + 'payment_provider' => PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_PROVIDER_PRZELEWY24 + ), + true + ) + ); + + $this->context->smarty->assign( + "pxpPrzelewy24Logo", + Media::getMediaPath(_PS_MODULE_DIR_ . $this->name . '/views/img/payment-types/przelewy24.png') + ); + + $option->setAdditionalInformation($this->context->smarty->fetch('module:payxpert/views/templates/front/payment_infos_bank_transfer_przelewy24.tpl')); + + return $option; + } + + return null; + } + + /** + * + * @since Prestashop 1.7 + */ + public function getBankTransferViaIDealPaymentOption($controller) + { + if (Configuration::get('PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_IDEAL') == "true") { + $option = new PrestaShop\PrestaShop\Core\Payment\PaymentOption(); + $option->setModuleName($this->name); + $option->setCallToActionText($this->l('Pay by Bank Transfer via iDeal')); + $option->setAction( + $this->context->link->getModuleLink( + $this->name, + $controller, + array( + 'payment_type' => PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_TYPE_BANKTRANSFER, + 'payment_provider' => PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_PROVIDER_IDEALKP + ), + true + ) + ); + + $this->context->smarty->assign( + "pxpIdealLogo", + Media::getMediaPath(_PS_MODULE_DIR_ . $this->name . '/views/img/payment-types/ideal.png') + ); + + $option->setAdditionalInformation($this->context->smarty->fetch('module:payxpert/views/templates/front/payment_infos_bank_transfer_ideal.tpl')); + + return $option; + } + + return null; + } + + public function getTemplateVarInfos() + { + $cart = $this->context->cart; + + return array(/* */ + 'nbProducts' => $cart->nbProducts(), /* */ + 'cust_currency' => $cart->id_currency, /* */ + 'total' => $cart->getOrderTotal(true, Cart::BOTH), /* */ + 'isoCode' => $this->context->language->iso_code /* */ + ); + } + + /** + * Hook payment for Prestashop < 1.7 + * + * @param type $params + * @return type + */ + public function hookPayment($params) + { + if (!$this->checkPaymentOption($params)) { + return; + } + $this->assignSmartyVariable( + 'this_path', + $this->_path + ); + + $this->assignSmartyVariable( + 'this_path_ssl', + (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://') . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . + __PS_BASE_URI__ . 'modules/payxpert/' + ); + + $this->assignSmartyVariable( + 'this_link', + $this->getModuleLinkCompat( + 'payxpert', + 'payment' + ) + ); + + if (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) { + $this->context->controller->addCSS($this->_path . 'views/css/payxpert.css'); + } + + return $this->display(__FILE__, 'views/templates/hook/payment.tpl'); + } + + /** + * Hook paymentReturn + * + * Displays order confirmation + * + * @param type $params + * @return type + */ + public function hookPaymentReturn($params) + { + if (!$this->active) { + return; + } + + if (isset($params['objOrder'])) { + // For Prestashop < 1.7 + $order = $params['objOrder']; + } else { + $order = $params['order']; + } + + switch ($order->getCurrentState()) { + case _PS_OS_PAYMENT_: + // Ok + case _PS_OS_OUTOFSTOCK_: + $this->assignSmartyVariable('status', 'ok'); + break; + + case _PS_OS_BANKWIRE_: + $this->assignSmartyVariable('status', 'pending'); + break; + + case _PS_OS_ERROR_: + // Error + default: + $this->assignSmartyVariable('status', 'failed'); + break; + } + + $this->assignSmartyVariable('this_link_contact', $this->getPageLinkCompat('contact', true)); + + return $this->display(__FILE__, 'views/templates/hook/orderconfirmation.tpl'); + } + + /** + * Init the payment + * + * In this method, we'll start to initialize the transaction + * And redirect the customer + * + * For Prestashop >= 1.5 + * + * @global type $cookie + * @param Cart $cart + * @return type + */ + public function redirect($cart, $paymentType = null, $paymentProvider = null) + { + // if module disabled, can't go through + if (!$this->active) { + return "Module is not active"; + } + + // Check if currency ok + if (!$this->checkCurrency($cart)) { + return "Incorrect currency"; + } + + // Check if module is configured + if (Configuration::get('PAYXPERT_ORIGINATOR') == "" && Configuration::get('PAYXPERT_PASSWORD') == "") { + return "Module is not setup"; + } + + if ($paymentType == null || !PayXpert\Connect2Pay\C2PValidate::isPayment($paymentType)) { + $paymentType = PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_TYPE_CREDITCARD; + } + + if (!$this->checkPaymentTypeAndProvider($paymentType, $paymentProvider)) { + return "Payment type or provider is not enabled"; + } + + $payment = $this->getPaymentClient($cart, $paymentType, $paymentProvider); + + // prepare API + if ($payment->preparePayment() == false) { + $message = "PayXpert : can't prepare transaction - " . $payment->getClientErrorMessage(); + $this->addLog($message, 3); + return $message; + } + + Tools::redirect($payment->getCustomerRedirectURL()); + exit(); + } + + /** + * Generates the Connect2Pay payment URL + * + * For Prestashop >= 1.5 + * + * @global type $cookie + * @param Cart $cart + * @return type + */ + public function getPaymentClient($cart, $paymentType = null, $paymentProvider = null) + { + // get all informations + $customer = new Customer((int) ($cart->id_customer)); + $currency = new Currency((int) ($cart->id_currency)); + $carrier = new Carrier((int) ($cart->id_carrier)); + $addr_delivery = new Address((int) ($cart->id_address_delivery)); + $addr_invoice = new Address((int) ($cart->id_address_invoice)); + + $invoice_state = new State((int) ($addr_invoice->id_state)); + $invoice_country = new Country((int) ($addr_invoice->id_country)); + + $delivery_state = new State((int) ($addr_delivery->id_state)); + $delivery_country = new Country((int) ($addr_delivery->id_country)); + + $invoice_phone = (!empty($addr_invoice->phone)) ? $addr_invoice->phone : $addr_invoice->phone_mobile; + $delivery_phone = (!empty($addr_delivery->phone)) ? $addr_delivery->phone : $addr_delivery->phone_mobile; + + // init api + $c2pClient = new PayXpert\Connect2Pay\Connect2PayClient( + $this->getPayXpertUrl(), + Configuration::get('PAYXPERT_ORIGINATOR'), + html_entity_decode(Configuration::get('PAYXPERT_PASSWORD')) + ); + + // customer informations + $c2pClient->setShopperID($cart->id_customer); + $c2pClient->setShopperEmail($customer->email); + $c2pClient->setShopperFirstName(Tools::substr($customer->firstname, 0, 35)); + $c2pClient->setShopperLastName(Tools::substr($customer->lastname, 0, 35)); + $c2pClient->setShopperCompany(Tools::substr($addr_invoice->company, 0, 128)); + $c2pClient->setShopperAddress(Tools::substr(trim($addr_invoice->address1 . ' ' . $addr_invoice->address2), 0, 255)); + $c2pClient->setShopperZipcode(Tools::substr($addr_invoice->postcode, 0, 10)); + $c2pClient->setShopperCity(Tools::substr($addr_invoice->city, 0, 50)); + $c2pClient->setShopperState(Tools::substr($invoice_state->name, 0, 30)); + $c2pClient->setShopperCountryCode($invoice_country->iso_code); + $c2pClient->setShopperPhone(Tools::substr(trim($invoice_phone), 0, 20)); + + // Shipping information + $c2pClient->setShipToFirstName(Tools::substr($addr_delivery->firstname, 0, 35)); + $c2pClient->setShipToLastName(Tools::substr($addr_delivery->lastname, 0, 35)); + $c2pClient->setShipToCompany(Tools::substr($addr_delivery->company, 0, 128)); + $c2pClient->setShipToPhone(Tools::substr(trim($delivery_phone), 0, 20)); + $c2pClient->setShipToAddress(Tools::substr(trim($addr_delivery->address1 . " " . $addr_delivery->address2), 0, 255)); + $c2pClient->setShipToZipcode(Tools::substr($addr_delivery->postcode, 0, 10)); + $c2pClient->setShipToCity(Tools::substr($addr_delivery->city, 0, 50)); + $c2pClient->setShipToState(Tools::substr($delivery_state->name, 0, 30)); + $c2pClient->setShipToCountryCode($delivery_country->iso_code); + $c2pClient->setShippingName(Tools::substr($carrier->name, 0, 50)); + $c2pClient->setShippingType(PayXpert\Connect2Pay\Connect2PayClient::_SHIPPING_TYPE_PHYSICAL); + + // Order informations + $c2pClient->setOrderID(Tools::substr(pSQL($cart->id), 0, 100)); + $c2pClient->setOrderDescription(Tools::substr($this->l('Invoice:') . pSQL($cart->id), 0, 255)); + $c2pClient->setCustomerIP($_SERVER['REMOTE_ADDR']); + $c2pClient->setCurrency($currency->iso_code); + + $total = number_format($cart->getOrderTotal(true, 3) * 100, 0, '.', ''); + + $c2pClient->setAmount($total); + $c2pClient->setOrderCartContent($this->getProductsApi($cart)); + $c2pClient->setPaymentMode(PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_MODE_SINGLE); + $c2pClient->setPaymentType($paymentType); + if ($paymentProvider != null && PayXpert\Connect2Pay\C2PValidate::isProvider($paymentProvider)) { + $c2pClient->setProvider($paymentProvider); + } + $c2pClient->setCtrlCustomData(PayXpert::getCallbackAuthenticityData($c2pClient->getOrderID(), $customer->secure_key)); + + // Merchant notifications + if (Configuration::get('PAYXPERT_MERCHANT_NOTIF') === "true" && Configuration::get('PAYXPERT_MERCHANT_NOTIF_TO')) { + $c2pClient->setMerchantNotification(true); + $c2pClient->setMerchantNotificationTo(Configuration::get('PAYXPERT_MERCHANT_NOTIF_TO')); + if (Configuration::get('PAYXPERT_MERCHANT_NOTIF_LANG')) { + $c2pClient->setMerchantNotificationLang(Configuration::get('PAYXPERT_MERCHANT_NOTIF_LANG')); + } + } + + $ctrlURLPrefix = Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://'; + + if (version_compare(_PS_VERSION_, '1.5', '<')) { + $c2pClient->setCtrlCallbackURL($ctrlURLPrefix . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'modules/payxpert/validation.php'); + $c2pClient->setCtrlRedirectURL($ctrlURLPrefix . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'order-confirmation.php?id_cart=' . (int) ($cart->id) . '&id_module=' . (int) ($this->id) . '&key=' . $customer->secure_key); + } else { + $c2pClient->setCtrlCallbackURL($this->context->link->getModuleLink('payxpert', 'validation')); + $c2pClient->setCtrlRedirectURL($this->getModuleLinkCompat('payxpert', 'return')); + } + + return $c2pClient; + } + + /** + * Return array of product to fill Api Product properties + * + * @param Cart $cart + * @return array + */ + protected function getProductsApi($cart) + { + $products = array(); + + foreach ($cart->getProducts() as $product) { + $obj = new Product((int) $product['id_product']); + $products[] = array( /* */ + 'CartProductId' => $product['id_product'], /* */ + 'CartProductName' => $product['name'], /* */ + 'CartProductUnitPrice' => $product['price'], /* */ + 'CartProductQuantity' => $product['quantity'], /* */ + 'CartProductBrand' => $obj->manufacturer_name, /* */ + 'CartProductMPN' => $product['ean13'], /* */ + 'CartProductCategoryName' => $product['category'], /* */ + 'CartProductCategoryID' => $product['id_category_default'] /* */ + ); + } + + return $products; + } + + public function getContent() + { + if (Tools::isSubmit('btnSubmit')) { + $this->_postValidation(); + + if (!count($this->_postErrors)) { + $this->_postProcess(); + } else { + foreach ($this->_postErrors as $err) { + $this->_html .= $this->displayError($err); + } + } + } else { + $this->_html .= '
'; + } + + $this->_html .= $this->display(__FILE__, '/views/templates/admin/infos.tpl'); + + if (version_compare(_PS_VERSION_, '1.6', '<')) { + /* Prestashop parameter names must not exceed 32 chars for v < 1.6 */ + $this->assignSmartyVariable( + 'PAYXPERT_ORIGINATOR', + Tools::safeOutput(Tools::getValue( + 'PAYXPERT_ORIGINATOR', + Configuration::get('PAYXPERT_ORIGINATOR') + )) + ); + + $this->assignSmartyVariable( + 'PAYXPERT_URL', + Tools::safeOutput(Tools::getValue( + 'PAYXPERT_URL', + Configuration::get('PAYXPERT_URL') + )) + ); + + $merchantNotifications = (Configuration::get('PAYXPERT_MERCHANT_NOTIF') == "true") ? "true" : "false"; + if (Tools::getValue('PAYXPERT_MERCHANT_NOTIF')) { + $merchantNotifications = (in_array(Tools::getValue('PAYXPERT_MERCHANT_NOTIF'), array("true", "1", "on"))) ? "true" : "false"; + } + + $this->assignSmartyVariable( + 'PAYXPERT_MERCHANT_NOTIF', + $merchantNotifications + ); + + $this->assignSmartyVariable( + 'PAYXPERT_MERCHANT_NOTIF_TO', + Tools::safeOutput(Tools::getValue( + 'PAYXPERT_MERCHANT_NOTIF_TO', + Configuration::get('PAYXPERT_MERCHANT_NOTIF_TO') + )) + ); + + $this->assignSmartyVariable( + 'PAYXPERT_MERCHANT_NOTIF_LANG', + Tools::safeOutput(Tools::getValue( + 'PAYXPERT_MERCHANT_NOTIF_LANG', + Configuration::get('PAYXPERT_MERCHANT_NOTIF_LANG') + )) + ); + + $this->_html .= $this->display( + __FILE__, + '/views/templates/admin/config.tpl' + ); + } else { + $this->_html .= $this->renderForm(); + } + + return $this->_html; + } + + public function getConfigFieldsValues() + { + // Handle checkboxes + $merchantNotif = Tools::getValue('PAYXPERT_MERCHANT_NOTIF', Configuration::get('PAYXPERT_MERCHANT_NOTIF')); + + $result = array( /* */ + 'PAYXPERT_ORIGINATOR' => Tools::getValue('PAYXPERT_ORIGINATOR', Configuration::get('PAYXPERT_ORIGINATOR')), /* */ + 'PAYXPERT_URL' => Tools::getValue('PAYXPERT_URL', Configuration::get('PAYXPERT_URL')), /* */ + 'PAYXPERT_MERCHANT_NOTIF' => ($merchantNotif === "true" || $merchantNotif == 1) ? 1 : 0, /* */ + 'PAYXPERT_MERCHANT_NOTIF_TO' => Tools::getValue( + 'PAYXPERT_MERCHANT_NOTIF_TO', + Configuration::get('PAYXPERT_MERCHANT_NOTIF_TO') + ), + 'PAYXPERT_MERCHANT_NOTIF_LANG' => Tools::getValue( + 'PAYXPERT_MERCHANT_NOTIF_LANG', + Configuration::get('PAYXPERT_MERCHANT_NOTIF_LANG') + ), + ); + + if (version_compare(_PS_VERSION_, '1.7', '>=')) { + $creditCardPaymentType = Tools::getValue( + 'PAYXPERT_PAYMENT_TYPE_CREDIT_CARD', + Configuration::get('PAYXPERT_PAYMENT_TYPE_CREDIT_CARD') + ); + + $sofortPaymentType = Tools::getValue( + 'PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_SOFORT', + Configuration::get('PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_SOFORT') + ); + + $przelewy24PaymentType = Tools::getValue( + 'PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_PRZELEWY24', + Configuration::get('PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_PRZELEWY24') + ); + + $idealPaymentType = Tools::getValue( + 'PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_IDEAL', + Configuration::get('PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_IDEAL') + ); + + $isIframe = Tools::getValue( + 'PAYXPERT_IS_IFRAME', + Configuration::get('PAYXPERT_IS_IFRAME') + ); + + $result['PAYXPERT_PAYMENT_TYPE_CREDIT_CARD'] = ($creditCardPaymentType === "true" || $creditCardPaymentType == 1) ? 1 : 0; + $result['PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_SOFORT'] = ($sofortPaymentType === "true" || $sofortPaymentType == 1) ? 1 : 0; + $result['PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_PRZELEWY24'] = ($przelewy24PaymentType === "true" || $przelewy24PaymentType == 1) ? 1 : 0; + $result['PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_IDEAL'] = ($idealPaymentType === "true" || $idealPaymentType == 1) ? 1 : 0; + $result['PAYXPERT_IS_IFRAME'] = ($isIframe === "true" || $isIframe == 1) ? 1 : 0; + } + + return $result; + } + + public function renderForm() + { + $fields_form = array( + 'form' => array( /* */ + 'legend' => array( /* */ + 'title' => $this->l('Settings'), /* */ + 'icon' => 'icon-gears' /* */ + ), /* */ + 'input' => array( /* */ + array( /* */ + 'type' => 'text', /* */ + 'name' => 'PAYXPERT_ORIGINATOR', /* */ + 'label' => $this->l('Originator ID'), /* */ + 'desc' => $this->l('The identifier of your Originator'), /* */ + 'required' => true /* */ + ), + array( /* */ + 'type' => 'password', /* */ + 'name' => 'PAYXPERT_PASSWORD', /* */ + 'label' => $this->l('Originator password'), /* */ + 'desc' => $this->l('The password associated with your Originator (leave empty to keep the current one)'), /* */ + 'hint' => $this->l('Leave empty to keep the current one'), /* */ + 'required' => false /* */ + ), + array( /* */ + 'type' => 'text', /* */ + 'name' => 'PAYXPERT_URL', /* */ + 'label' => $this->l('Payment Page URL'), /* */ + 'desc' => $this->l('Leave this field empty unless you have been given an URL'), /* */ + 'required' => false /* */ + ), + array( /* */ + 'type' => 'switch', /* */ + 'name' => 'PAYXPERT_MERCHANT_NOTIF', /* */ + 'label' => $this->l('Merchant notifications'), /* */ + 'desc' => $this->l('Whether or not to send a notification to the merchant for each processed payment'), /* */ + 'required' => false, /* */ + 'is_bool' => true, /* */ + 'values' => array( /* */ + array('id' => 'notif_on', 'value' => 1, 'label' => $this->l('Enabled')), /* */ + array('id' => 'notif_off', 'value' => 0, 'label' => $this->l('Disabled')) /* */ + ) /* */ + ), /* */ + array( /* */ + 'type' => 'text', /* */ + 'name' => 'PAYXPERT_MERCHANT_NOTIF_TO', /* */ + 'label' => $this->l('Merchant notifications recipient'), /* */ + 'desc' => $this->l('Recipient email address for merchant notifications'), /* */ + 'required' => false, /* */ + 'size' => 100 /* */ + ), /* */ + array( /* */ + 'type' => 'select', /* */ + 'name' => 'PAYXPERT_MERCHANT_NOTIF_LANG', /* */ + 'label' => $this->l('Merchant notifications lang'), /* */ + 'desc' => $this->l('Language to use for merchant notifications'), /* */ + 'required' => false, /* */ + 'options' => array( /* */ + 'query' => array( /* */ + array('id_option' => 'en', 'name' => $this->l('English')), /* */ + array('id_option' => 'fr', 'name' => $this->l('French')), /* */ + array('id_option' => 'es', 'name' => $this->l('Spanish')), /* */ + array('id_option' => 'it', 'name' => $this->l('Italian')) /* */ + ), /* */ + 'id' => 'id_option', /* */ + 'name' => 'name' /* */ + ) /* */ + ) /* */ + ), /* */ + 'submit' => array('title' => $this->l('Update settings')) /* */ + ) /* */ + ); + + if (version_compare(_PS_VERSION_, '1.7', '>=')) { + $fields_form['form']['input'][] = array( /* */ + 'type' => 'switch', /* */ + 'name' => 'PAYXPERT_PAYMENT_TYPE_CREDIT_CARD', /* */ + 'label' => $this->l('Credit Card'), /* */ + 'desc' => $this->l('Enable payment type: Credit Card'), /* */ + 'required' => false, /* */ + 'is_bool' => true, /* */ + 'values' => array(/* */ + array('id' => 'cc_on', 'value' => 1, 'label' => $this->l('Enabled')), /* */ + array('id' => 'cc_off', 'value' => 0, 'label' => $this->l('Disabled')) /* */ + ) /* */ + ); + $fields_form['form']['input'][] = array( /* */ + 'type' => 'switch', /* */ + 'name' => 'PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_SOFORT', /* */ + 'label' => $this->l('Bank Transfert via Sofort'), /* */ + 'desc' => $this->l('Enable payment type: Bank Transfer via Sofort'), /* */ + 'required' => false, /* */ + 'is_bool' => true, /* */ + 'values' => array(/* */ + array('id' => 'sofort_on', 'value' => 1, 'label' => $this->l('Enabled')), /* */ + array('id' => 'sofort_off', 'value' => 0, 'label' => $this->l('Disabled')) /* */ + ) /* */ + ); + $fields_form['form']['input'][] = array( /* */ + 'type' => 'switch', /* */ + 'name' => 'PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_PRZELEWY24', /* */ + 'label' => $this->l('Bank Transfert via Przelewy24'), /* */ + 'desc' => $this->l('Enable payment type: Bank Transfer via Przelewy24'), /* */ + 'required' => false, /* */ + 'is_bool' => true, /* */ + 'values' => array(/* */ + array('id' => 'przelewy24_on', 'value' => 1, 'label' => $this->l('Enabled')), /* */ + array('id' => 'przelewy24_off', 'value' => 0, 'label' => $this->l('Disabled')) /* */ + ) /* */ + ); + $fields_form['form']['input'][] = array( /* */ + 'type' => 'switch', /* */ + 'name' => 'PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_IDEAL', /* */ + 'label' => $this->l('Bank Transfert via iDeal'), /* */ + 'desc' => $this->l('Enable payment type: Bank Transfer via iDeal'), /* */ + 'required' => false, /* */ + 'is_bool' => true, /* */ + 'values' => array(/* */ + array('id' => 'ideal_on', 'value' => 1, 'label' => $this->l('Enabled')), /* */ + array('id' => 'ideal_off', 'value' => 0, 'label' => $this->l('Disabled')) /* */ + ) /* */ + ); + $fields_form['form']['input'][] = array( /* */ + 'type' => 'switch', /* */ + 'name' => 'PAYXPERT_IS_IFRAME', /* */ + 'label' => $this->l('Iframe mode'), /* */ + 'desc' => $this->l('Enable iframe mode'), /* */ + 'required' => false, /* */ + 'is_bool' => true, /* */ + 'values' => array(/* */ + array('id' => 'iframe_on', 'value' => 1, 'label' => $this->l('Enabled')), /* */ + array('id' => 'iframe_off', 'value' => 0, 'label' => $this->l('Disabled')) /* */ + ) /* */ + ); + } + + $helper = new HelperForm(); + $helper->show_toolbar = false; + $helper->table = $this->table; + $lang = new Language((int) Configuration::get('PS_LANG_DEFAULT')); + $helper->default_form_language = $lang->id; + $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; + $this->fields_form = array(); + + $helper->identifier = $this->identifier; + $helper->submit_action = 'btnSubmit'; + $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&tab_module=' . + $this->tab . '&module_name=' . $this->name; + $helper->token = Tools::getAdminTokenLite('AdminModules'); + $helper->tpl_vars = array( /* */ + 'fields_value' => $this->getConfigFieldsValues(), /* */ + 'languages' => $this->context->controller->getLanguages(), /* */ + 'id_language' => $this->context->language->id /* */ + ); + + return $helper->generateForm(array($fields_form)); + } + + private function _postValidation() + { + if (Tools::isSubmit('btnSubmit')) { + if (!Tools::getValue('PAYXPERT_ORIGINATOR')) { + $this->_postErrors[] = $this->l('Originator is required.'); + } + + if (!Configuration::get('PAYXPERT_PASSWORD') && !Tools::getValue('PAYXPERT_PASSWORD')) { + $this->_postErrors[] = $this->l('Password is required.'); + } + + if (in_array(Tools::getValue('PAYXPERT_MERCHANT_NOTIF'), array("true", "1", "on")) && !Tools::getValue('PAYXPERT_MERCHANT_NOTIF_TO')) { + $this->_postErrors[] = $this->l('Merchant notifications recipient is required.'); + } + + if (Tools::getValue('PAYXPERT_MERCHANT_NOTIF_TO') && !Validate::isEmail(Tools::getValue('PAYXPERT_MERCHANT_NOTIF_TO'))) { + $this->_postErrors[] = $this->l('Merchant notifications recipient must be a valid email address.'); + } + + if (!in_array(Tools::getValue('PAYXPERT_MERCHANT_NOTIF_LANG'), array("en", "fr", "es", "it"))) { + $this->_postErrors[] = $this->l('Merchant notification lang is not valid.'); + } + } + } + + protected function _postProcess() + { + if (Tools::isSubmit('btnSubmit')) { + Configuration::updateValue('PAYXPERT_ORIGINATOR', Tools::getValue('PAYXPERT_ORIGINATOR')); + + if (Tools::getValue('PAYXPERT_PASSWORD')) { + // Manually handle HTML special chars to avoid losing them + Configuration::updateValue('PAYXPERT_PASSWORD', htmlentities(Tools::getValue('PAYXPERT_PASSWORD'))); + } + + Configuration::updateValue('PAYXPERT_URL', Tools::getValue('PAYXPERT_URL')); + + Configuration::updateValue('PAYXPERT_MERCHANT_NOTIF_TO', Tools::getValue('PAYXPERT_MERCHANT_NOTIF_TO')); + + if (in_array(Tools::getValue('PAYXPERT_MERCHANT_NOTIF_LANG'), array("en", "fr", "es", "it"))) { + Configuration::updateValue('PAYXPERT_MERCHANT_NOTIF_LANG', Tools::getValue('PAYXPERT_MERCHANT_NOTIF_LANG')); + } + + // Handle checkboxes + $checkboxes = array( /* */ + 'PAYXPERT_MERCHANT_NOTIF' /* */ + ); + if (version_compare(_PS_VERSION_, '1.7', '>=')) { + $checkboxes[] = 'PAYXPERT_PAYMENT_TYPE_CREDIT_CARD'; + $checkboxes[] = 'PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_SOFORT'; + $checkboxes[] = 'PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_PRZELEWY24'; + $checkboxes[] = 'PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_IDEAL'; + $checkboxes[] = 'PAYXPERT_IS_IFRAME'; + } + + foreach ($checkboxes as $checkbox) { + if (in_array(Tools::getValue($checkbox), array("true", "1", "on"))) { + Configuration::updateValue($checkbox, "true"); + } else { + Configuration::updateValue($checkbox, "false"); + } + } + } + + if (version_compare(_PS_VERSION_, '1.6', '>=')) { + $this->_html .= $this->displayConfirmation($this->l('Configuration updated')); + } else { + $this->_html .= ' ' . $this->l('Configuration updated') . ''; + + return true; + } + } + + private function checkPaymentTypeAndProvider($paymentType, $paymentProvider) + { + // For Prestashop >=1.7, check that the payment type is enabled + if (version_compare(_PS_VERSION_, '1.7.0', '>=') === true) { + switch ($paymentType) { + case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_TYPE_CREDITCARD: + return Configuration::get('PAYXPERT_PAYMENT_TYPE_CREDIT_CARD') === "true"; + case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_TYPE_BANKTRANSFER: + if ($paymentProvider !== null) { + switch ($paymentProvider) { + case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_PROVIDER_SOFORT: + return Configuration::get('PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_SOFORT') === "true"; + case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_PROVIDER_PRZELEWY24: + return Configuration::get('PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_PRZELEWY24') === "true"; + case PayXpert\Connect2Pay\Connect2PayClient::_PAYMENT_PROVIDER_IDEALKP: + return Configuration::get('PAYXPERT_PAYMENT_TYPE_BANK_TRANSFERT_IDEAL') === "true"; + } + } + break; + } + } else { + return true; + } + + return false; + } + + private function checkCurrency($cart) + { + $currency_order = new Currency((int) ($cart->id_currency)); + $currencies_module = $this->getCurrency((int) $cart->id_currency); + + if (is_array($currencies_module)) { + foreach ($currencies_module as $currency_module) { + if ($currency_order->id == $currency_module['id_currency']) { + return true; + } + } + } + + return false; + } + + /** + * Get PayXpert Url depending of the env + * + * @return string Url + */ + public function getPayXpertUrl() + { + $url = Configuration::get('PAYXPERT_URL'); + + if (Tools::strlen(trim($url)) <= 0) { + $url = 'https://connect2.payxpert.com/'; + } + + return $url; + } + + /** + * Get the iframe config value + * + * @return boolean + */ + public function isIframeMode() + { + $is_iframe = Configuration::get('PAYXPERT_IS_IFRAME'); + + return $is_iframe === 'true' ? true : false; + } + + /** + * Returns the modules path + * + * @return string + */ + public function getPath() + { + return $this->_path; + } + + /* Theses functions are used to support all versions of Prestashop */ + public function assignSmartyVariable($name, $value) + { + // Check if context smarty variable is available + if (isset($this->context->smarty)) { + return $this->context->smarty->assign($name, $value); + } else { + // Use the global variable + if (!isset($smarty)) { + $smarty = $this->context->smarty; + } + + return $smarty->assign($name, $value); + } + } + + public function getModuleLinkCompat($module, $controller = 'default', $params = null) + { + if (class_exists('Context')) { + if (!$params) { + $params = array(); + } + + return Context::getContext()->link->getModuleLink($module, $controller, $params); + } else { + if ($controller == 'default') { + if ($params) { + $params = "?" . $params; + } + + return Configuration::get('PS_SSL_ENABLED') ? 'https' : 'http' . '://' . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . $module . '.php' . + $params; + } else { + return Configuration::get('PS_SSL_ENABLED') ? 'https' : 'http' . '://' . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . + 'modules/payxpert/' . $controller . '.php'; + } + } + } + + public function getPageLinkCompat($controller, $ssl = null, $id_lang = null, $request = null, $request_url_encode = false, $id_shop = null) + { + if (class_exists('Context')) { + return Context::getContext()->link->getPageLink($controller, $ssl, $id_lang, $request, $request_url_encode, $id_shop); + } else { + if ($controller == 'contact') { + return Configuration::get('PS_SSL_ENABLED') ? 'https' : 'http' . '://' . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'contact-form.php'; + } else { + $params = (isset($params)) ? "?" . $params : ""; + + return Configuration::get('PS_SSL_ENABLED') ? 'https' : 'http' . '://' . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . $controller . + '.php' . $params; + } + } + } + + public function addLog($message, $severity = 1, $errorCode = null, $objectType = null, $objectId = null, $allowDuplicate = true) + { + if (class_exists('PrestaShopLogger')) { + PrestaShopLogger::addLog($message, $severity, $errorCode, $objectType, $objectId, $allowDuplicate); + } else if (class_exists('Logger')) { + Logger::addLog($message, $severity, $errorCode, $objectType, $objectId, $allowDuplicate); + } else { + error_log($message . "(" . $errorCode . ")"); + } + } + + /* Callback authenticity check methods */ + public static function getCallbackAuthenticityData($orderId, $secure_key) + { + return sha1($orderId . $secure_key . html_entity_decode(Configuration::get('PAYXPERT_PASSWORD'))); + } + + public static function checkCallbackAuthenticityData($callbackData, $orderId, $secure_key) + { + return (strcasecmp($callbackData, PayXpert::getCallbackAuthenticityData($orderId, $secure_key)) === 0); + } + + /* Theses functions are only used for Prestashop prior to version 1.5 */ + public function execPayment($cart) + { + if (!isset($cookie)) { + $cookie = $this->context->cookie; + } + + $this->assignSmartyVariable('nbProducts', $cart->nbProducts()); + $this->assignSmartyVariable('cust_currency', $cart->id_currency); + $this->assignSmartyVariable('currencies', $this->getCurrency()); + $this->assignSmartyVariable('total', $cart->getOrderTotal(true, 3)); + $this->assignSmartyVariable('isoCode', Language::getIsoById((int)($cookie->id_lang))); + $this->assignSmartyVariable('this_path', $this->_path); + $this->assignSmartyVariable('this_link', $this->getModuleLinkCompat('payxpert', 'redirect')); + $this->assignSmartyVariable('this_link_back', $this->getPageLinkCompat('order', true, null, "step=3")); + + return $this->display(__FILE__, '/views/templates/front/payment_execution.tpl'); + } + + public function displayErrorPage($message) + { + $this->assignSmartyVariable('errorMessage', $message); + $this->assignSmartyVariable('this_link_back', $this->getPageLinkCompat('order', true, null, "step=3")); + + return $this->display(__FILE__, '/views/templates/front/payment_error.tpl'); + } +} diff --git a/modules/payxpert/redirect.php b/redirect.php similarity index 86% rename from modules/payxpert/redirect.php rename to redirect.php index 78a4f87..29590ef 100644 --- a/modules/payxpert/redirect.php +++ b/redirect.php @@ -1,6 +1,6 @@ context->cookie; +} + +if (!isset($cart)) { + $cart = $this->context->cart; +} + if (!$cookie->isLogged()) { Tools::redirect('authentication.php?back=order.php'); } diff --git a/validation.php b/validation.php new file mode 100644 index 0000000..b8602ba --- /dev/null +++ b/validation.php @@ -0,0 +1,107 @@ +getPayXpertUrl(), + Configuration::get('PAYXPERT_ORIGINATOR'), + html_entity_decode(Configuration::get('PAYXPERT_PASSWORD')) +); + +if ($c2pClient->handleCallbackStatus()) { + $status = $c2pClient->getStatus(); + + // get the Error code + $errorCode = $status->getErrorCode(); + $errorMessage = $status->getErrorMessage(); + + $transaction = $status->getLastTransactionAttempt(); + + if ($transaction !== null) { + $transactionId = $transaction->getTransactionID(); + + $orderId = $status->getOrderID(); + $amount = number_format($status->getAmount() / 100, 2, '.', ''); + $callbackData = $status->getCtrlCustomData(); + + $message = "PayXpert payment module: "; + + // load the customer cart and perform some checks + $cart = new Cart((int) ($orderId)); + if (!$cart->id) { + $message .= "Cart is empty: " . $orderId; + error_log($message); + } + + $responseStatus = "KO"; + $responseMessage = "Callback validation failed"; + $customer = new Customer((int) ($cart->id_customer)); + + if (!$customer) { + $message .= "Customer is empty for order " . $orderId; + error_log($message); + } else { + if (!PayXpert::checkCallbackAuthenticityData($callbackData, $cart->id, $customer->secure_key)) { + $message .= "Invalid callback received for order " . $orderId . ". Validation failed."; + error_log($message); + } else { + $responseStatus = "OK"; + $responseMessage = "Status recorded"; + + $message .= "Error code: " . $errorCode . "
"; + $message .= "Error message: " . $errorMessage . "
"; + $message .= "Transaction ID: " . $transactionId . "
"; + $message .= "Order ID: " . $orderId . "
"; + + error_log(str_replace("
", " ", $message)); + + $paymentMean = $payxpert->l('Credit Card') . ' (PayXpert)'; + + switch ($errorCode) { + case "000": + /* Payment OK */ + $payxpert->validateOrder((int) $orderId, _PS_OS_PAYMENT_, $amount, $paymentMean, $message); + break; + default: + $payxpert->validateOrder((int) $orderId, _PS_OS_ERROR_, $amount, $paymentMean, $message); + break; + } + } + } + } + + // Send a response to mark this transaction as notified + $response = array("status" => $responseStatus, "message" => $responseMessage); + header("Content-type: application/json"); + echo json_encode($response); +} diff --git a/modules/payxpert/css/iframe.css b/views/css/iframe.css similarity index 95% rename from modules/payxpert/css/iframe.css rename to views/css/iframe.css index f5df611..64a068c 100644 --- a/modules/payxpert/css/iframe.css +++ b/views/css/iframe.css @@ -11,7 +11,7 @@ } .fluidIframe iframe { - border: none; + border: none; position: absolute; top: 0; left: 0; diff --git a/modules/payxpert/css/index.php b/views/css/index.php similarity index 100% rename from modules/payxpert/css/index.php rename to views/css/index.php diff --git a/modules/payxpert/css/payxpert.css b/views/css/payxpert.css similarity index 76% rename from modules/payxpert/css/payxpert.css rename to views/css/payxpert.css index aa3867e..2552ed7 100644 --- a/modules/payxpert/css/payxpert.css +++ b/views/css/payxpert.css @@ -13,5 +13,5 @@ p.payment_module a.creditcard::after{ } p.payment_module a.creditcard { - background: url(../images/payment-types/creditcard_icon.png) 15px 12px no-repeat #fbfbfb; + background: url(../img/payment-types/creditcard_icon.png) 15px 12px no-repeat #fbfbfb; } \ No newline at end of file diff --git a/modules/payxpert/images/baian.png b/views/img/baian.png similarity index 100% rename from modules/payxpert/images/baian.png rename to views/img/baian.png diff --git a/modules/payxpert/images/fullpass.png b/views/img/fullpass.png similarity index 100% rename from modules/payxpert/images/fullpass.png rename to views/img/fullpass.png diff --git a/modules/payxpert/index.php b/views/img/index.php similarity index 100% rename from modules/payxpert/index.php rename to views/img/index.php diff --git a/modules/payxpert/images/logo-baian.gif b/views/img/logo-baian.gif similarity index 100% rename from modules/payxpert/images/logo-baian.gif rename to views/img/logo-baian.gif diff --git a/modules/payxpert/images/logo-baian.png b/views/img/logo-baian.png similarity index 100% rename from modules/payxpert/images/logo-baian.png rename to views/img/logo-baian.png diff --git a/modules/payxpert/images/logo-fullpass.gif b/views/img/logo-fullpass.gif similarity index 100% rename from modules/payxpert/images/logo-fullpass.gif rename to views/img/logo-fullpass.gif diff --git a/modules/payxpert/images/logo-fullpass.png b/views/img/logo-fullpass.png similarity index 100% rename from modules/payxpert/images/logo-fullpass.png rename to views/img/logo-fullpass.png diff --git a/modules/payxpert/images/logo-payxpert.gif b/views/img/logo-payxpert.gif similarity index 100% rename from modules/payxpert/images/logo-payxpert.gif rename to views/img/logo-payxpert.gif diff --git a/modules/payxpert/images/logo-payxpert.png b/views/img/logo-payxpert.png similarity index 100% rename from modules/payxpert/images/logo-payxpert.png rename to views/img/logo-payxpert.png diff --git a/modules/payxpert/images/logo-payzone.gif b/views/img/logo-payzone.gif similarity index 100% rename from modules/payxpert/images/logo-payzone.gif rename to views/img/logo-payzone.gif diff --git a/modules/payxpert/images/logo-payzone.png b/views/img/logo-payzone.png similarity index 100% rename from modules/payxpert/images/logo-payzone.png rename to views/img/logo-payzone.png diff --git a/modules/payxpert/images/payment-types/creditcard.png b/views/img/payment-types/creditcard.png similarity index 100% rename from modules/payxpert/images/payment-types/creditcard.png rename to views/img/payment-types/creditcard.png diff --git a/modules/payxpert/images/payment-types/creditcard_icon.png b/views/img/payment-types/creditcard_icon.png similarity index 100% rename from modules/payxpert/images/payment-types/creditcard_icon.png rename to views/img/payment-types/creditcard_icon.png diff --git a/modules/payxpert/images/payment-types/ideal.png b/views/img/payment-types/ideal.png similarity index 100% rename from modules/payxpert/images/payment-types/ideal.png rename to views/img/payment-types/ideal.png diff --git a/modules/payxpert/views/templates/admin/index.php b/views/img/payment-types/index.php similarity index 100% rename from modules/payxpert/views/templates/admin/index.php rename to views/img/payment-types/index.php diff --git a/modules/payxpert/images/payment-types/przelewy24.png b/views/img/payment-types/przelewy24.png similarity index 100% rename from modules/payxpert/images/payment-types/przelewy24.png rename to views/img/payment-types/przelewy24.png diff --git a/modules/payxpert/images/payment-types/sofort.png b/views/img/payment-types/sofort.png similarity index 100% rename from modules/payxpert/images/payment-types/sofort.png rename to views/img/payment-types/sofort.png diff --git a/modules/payxpert/images/payxpert.png b/views/img/payxpert.png similarity index 100% rename from modules/payxpert/images/payxpert.png rename to views/img/payxpert.png diff --git a/modules/payxpert/images/payzone.png b/views/img/payzone.png similarity index 100% rename from modules/payxpert/images/payzone.png rename to views/img/payzone.png diff --git a/modules/payxpert/views/index.php b/views/index.php similarity index 100% rename from modules/payxpert/views/index.php rename to views/index.php diff --git a/modules/payxpert/views/templates/admin/config.tpl b/views/templates/admin/config.tpl similarity index 94% rename from modules/payxpert/views/templates/admin/config.tpl rename to views/templates/admin/config.tpl index f3d99ea..ff99a23 100644 --- a/modules/payxpert/views/templates/admin/config.tpl +++ b/views/templates/admin/config.tpl @@ -1,5 +1,5 @@ {* -* Copyright 2013-2017 PayXpert +* Copyright 2013-2018 PayXpert * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,6 @@ * limitations under the License. * * @author Regis Vidal -* *}
@@ -23,7 +22,7 @@
 
- +

{l s='The identifier of your Originator' mod='payxpert'}

 
@@ -37,7 +36,7 @@
- +

{l s='Leave this field empty unless you have been given an URL"' mod='payxpert'}

 
@@ -52,7 +51,7 @@
- +

{l s='Recipient email address for merchant notifications' mod='payxpert'}

 
diff --git a/views/templates/admin/index.php b/views/templates/admin/index.php new file mode 100644 index 0000000..a230e5a --- /dev/null +++ b/views/templates/admin/index.php @@ -0,0 +1,35 @@ + +* @copyright 2007-2013 PrestaShop SA +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; \ No newline at end of file diff --git a/views/templates/admin/infos.tpl b/views/templates/admin/infos.tpl new file mode 100644 index 0000000..b464461 --- /dev/null +++ b/views/templates/admin/infos.tpl @@ -0,0 +1,26 @@ +{* +* Copyright 2013-2018 PayXpert +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* @author Alexandre Chatiron +*} +{if $smarty.const._PS_VERSION_ >= 1.6} +
+{/if} + +

{l s='This module allows you to accept secure payments.' mod='payxpert'}

+





+{if $smarty.const._PS_VERSION_ >= 1.6} +
+{/if} \ No newline at end of file diff --git a/modules/payxpert/views/templates/front/index.php b/views/templates/front/index.php similarity index 100% rename from modules/payxpert/views/templates/front/index.php rename to views/templates/front/index.php diff --git a/modules/payxpert/views/templates/front/payment_error.tpl b/views/templates/front/payment_error.tpl similarity index 93% rename from modules/payxpert/views/templates/front/payment_error.tpl rename to views/templates/front/payment_error.tpl index ce2df2e..9794379 100644 --- a/modules/payxpert/views/templates/front/payment_error.tpl +++ b/views/templates/front/payment_error.tpl @@ -1,5 +1,5 @@ {* -* Copyright 2013-2017 PayXpert +* Copyright 2013-2018 PayXpert * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -11,7 +11,7 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and -* limitations under the License. +* limitations under the License. * * @author Regis Vidal * @@ -37,7 +37,7 @@

Error

{/if} -

{$errorMessage}

+

{$errorMessage|escape:'htmlall':'UTF-8'}

{if $smarty.const._PS_VERSION_ >= 1.6}

diff --git a/modules/payxpert/views/templates/front/payment_error17.tpl b/views/templates/front/payment_error17.tpl similarity index 93% rename from modules/payxpert/views/templates/front/payment_error17.tpl rename to views/templates/front/payment_error17.tpl index c786fa1..29a0638 100644 --- a/modules/payxpert/views/templates/front/payment_error17.tpl +++ b/views/templates/front/payment_error17.tpl @@ -1,5 +1,5 @@ {* -* Copyright 2013-2017 PayXpert +* Copyright 2013-2018 PayXpert * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@

Error

-

{$errorMessage}

+

{$errorMessage|escape:'htmlall':'UTF-8'}

diff --git a/modules/payxpert/views/templates/front/payment_execution.tpl b/views/templates/front/payment_execution.tpl similarity index 91% rename from modules/payxpert/views/templates/front/payment_execution.tpl rename to views/templates/front/payment_execution.tpl index 75f85bd..d664aae 100644 --- a/modules/payxpert/views/templates/front/payment_execution.tpl +++ b/views/templates/front/payment_execution.tpl @@ -1,5 +1,5 @@ {* -* Copyright 2013-2017 PayXpert +* Copyright 2013-2018 PayXpert * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. * * @author Regis Vidal -* @copyright 2013-2017 PayXpert +* @copyright 2013-2018 PayXpert * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 (the "License") *} @@ -41,14 +41,14 @@

{/if} - {l s='Credit Card' mod='payxpert'} + {l s='Credit Card' mod='payxpert'} {l s='You have chosen to pay by Credit Card.' mod='payxpert'} {l s='Here is a short summary of your order:' mod='payxpert'} {if $smarty.const._PS_VERSION_ >= 1.6}{/if}

- {l s='The total amount of your order is' mod='payxpert'} - {Tools::displayPrice($total, $currency, false)} + {Tools::displayPrice($total, $currency, false)|escape:'htmlall':'UTF-8'} {if $use_taxes == 1} {l s='(tax incl.)' mod='payxpert'} {/if} diff --git a/modules/payxpert/views/templates/front/payment_execution_bank_transfer.tpl b/views/templates/front/payment_execution_bank_transfer.tpl similarity index 90% rename from modules/payxpert/views/templates/front/payment_execution_bank_transfer.tpl rename to views/templates/front/payment_execution_bank_transfer.tpl index c06f378..e304360 100644 --- a/modules/payxpert/views/templates/front/payment_execution_bank_transfer.tpl +++ b/views/templates/front/payment_execution_bank_transfer.tpl @@ -1,5 +1,5 @@ {* -* Copyright 2013-2017 PayXpert +* Copyright 2013-2018 PayXpert * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. * * @author Regis Vidal -* @copyright 2013-2017 PayXpert +* @copyright 2013-2018 PayXpert * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 (the "License") *} @@ -31,14 +31,14 @@

{assign var='current_step' value='payment'}
- {l s='Bank Transfer' mod='payxpert'} + {l s='Bank Transfer' mod='payxpert'}
{l s='You have chosen to pay by Bank Transfer.' mod='payxpert'}

- {capture name='amount'}{Tools::displayPrice($total, $cust_currency)}{/capture} + {capture name='amount'}{Tools::displayPrice($total, $cust_currency)|escape:'htmlall':'UTF-8'}{/capture} {assign var='order_amount' value=$smarty.capture.amount} {l s='The total amount of your order is %s.' sprintf=[$order_amount|escape:'html':'UTF-8'] mod='payxpert'}
diff --git a/modules/payxpert/views/templates/front/payment_execution_credit_card.tpl b/views/templates/front/payment_execution_credit_card.tpl similarity index 90% rename from modules/payxpert/views/templates/front/payment_execution_credit_card.tpl rename to views/templates/front/payment_execution_credit_card.tpl index 794eedb..723dbca 100644 --- a/modules/payxpert/views/templates/front/payment_execution_credit_card.tpl +++ b/views/templates/front/payment_execution_credit_card.tpl @@ -1,5 +1,5 @@ {* -* Copyright 2013-2017 PayXpert +* Copyright 2013-2018 PayXpert * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. * * @author Regis Vidal -* @copyright 2013-2017 PayXpert +* @copyright 2013-2018 PayXpert * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 (the "License") *} @@ -31,14 +31,14 @@

{assign var='current_step' value='payment'}
- {l s='Credit Card' mod='payxpert'} + {l s='Credit Card' mod='payxpert'}
{l s='You have chosen to pay by Credit Card.' mod='payxpert'}

- {capture name='amount'}{Tools::displayPrice($total, $cust_currency)}{/capture} + {capture name='amount'}{Tools::displayPrice($total, $cust_currency)|escape:'htmlall':'UTF-8'}{/capture} {assign var='order_amount' value=$smarty.capture.amount} {l s='The total amount of your order is %s.' sprintf=[$order_amount|escape:'html':'UTF-8'] mod='payxpert'}
diff --git a/views/templates/front/payment_infos_bank_transfer_ideal.tpl b/views/templates/front/payment_infos_bank_transfer_ideal.tpl new file mode 100644 index 0000000..90f02e5 --- /dev/null +++ b/views/templates/front/payment_infos_bank_transfer_ideal.tpl @@ -0,0 +1,21 @@ +{* +* Copyright 2013-2018 PayXpert +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* @author Regis Vidal +* +*} +

+

iDeal{l s='Use your bank account information with the iDeal provider to pay your order' mod='payxpert'}

+
\ No newline at end of file diff --git a/views/templates/front/payment_infos_bank_transfer_przelewy24.tpl b/views/templates/front/payment_infos_bank_transfer_przelewy24.tpl new file mode 100644 index 0000000..7219ad6 --- /dev/null +++ b/views/templates/front/payment_infos_bank_transfer_przelewy24.tpl @@ -0,0 +1,21 @@ +{* +* Copyright 2013-2018 PayXpert +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* @author Regis Vidal +* +*} +
+

Przelewy24{l s='Use your bank account information with the Przelewy24 provider to pay your order' mod='payxpert'}

+
\ No newline at end of file diff --git a/views/templates/front/payment_infos_bank_transfer_sofort.tpl b/views/templates/front/payment_infos_bank_transfer_sofort.tpl new file mode 100644 index 0000000..8b661cc --- /dev/null +++ b/views/templates/front/payment_infos_bank_transfer_sofort.tpl @@ -0,0 +1,21 @@ +{* +* Copyright 2013-2018 PayXpert +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* @author Regis Vidal +* +*} +
+

Sofort{l s='Use your bank account information with the Sofort provider to pay your order' mod='payxpert'}

+
\ No newline at end of file diff --git a/views/templates/front/payment_infos_credit_card.tpl b/views/templates/front/payment_infos_credit_card.tpl new file mode 100644 index 0000000..b37a658 --- /dev/null +++ b/views/templates/front/payment_infos_credit_card.tpl @@ -0,0 +1,21 @@ +{* +* Copyright 2013-2018 PayXpert +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* @author Regis Vidal +* +*} +
+

Credit Card{l s='Use your credit card information in a secured form to pay your order' mod='payxpert'}

+
\ No newline at end of file diff --git a/modules/payxpert/views/templates/hook/iframe.tpl b/views/templates/hook/iframe.tpl similarity index 85% rename from modules/payxpert/views/templates/hook/iframe.tpl rename to views/templates/hook/iframe.tpl index a27fbf7..2cec57a 100644 --- a/modules/payxpert/views/templates/hook/iframe.tpl +++ b/views/templates/hook/iframe.tpl @@ -1,5 +1,5 @@ {* -* Copyright 2013-2017 PayXpert +* Copyright 2013-2018 PayXpert * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,6 @@ {block name="content"} {l s='Other payment methods' mod='payxpert'}
- +
{/block} \ No newline at end of file diff --git a/modules/payxpert/views/templates/hook/index.php b/views/templates/hook/index.php similarity index 100% rename from modules/payxpert/views/templates/hook/index.php rename to views/templates/hook/index.php diff --git a/modules/payxpert/views/templates/hook/orderconfirmation.tpl b/views/templates/hook/orderconfirmation.tpl similarity index 82% rename from modules/payxpert/views/templates/hook/orderconfirmation.tpl rename to views/templates/hook/orderconfirmation.tpl index e6ae09b..a7e21b9 100644 --- a/modules/payxpert/views/templates/hook/orderconfirmation.tpl +++ b/views/templates/hook/orderconfirmation.tpl @@ -1,5 +1,5 @@ {* -* Copyright 2013-2017 PayXpert +* Copyright 2013-2018 PayXpert * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,24 +14,24 @@ * limitations under the License. * * @author Regis Vidal -* @copyright 2013-2017 PayXpert +* @copyright 2013-2018 PayXpert * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 (the "License") *} {if $status == 'ok'}

{l s='Your order has been completed.' mod='payxpert'}

{l s='It will be shipped as soon as possible.' mod='payxpert'} -

{l s='For any questions or for further information, please contact our' mod='payxpert'} {l s='customer support' mod='payxpert'}. +

{l s='For any questions or for further information, please contact our' mod='payxpert'} {l s='customer support' mod='payxpert'}.

{else} {if $status == 'pending'}

{l s='Your order is still pending.' mod='payxpert'}

{l s='Your order will be shipped as soon as we receive your payment.' mod='payxpert'} -

{l s='For any questions or for further information, please contact our' mod='payxpert'} {l s='customer support' mod='payxpert'}. +

{l s='For any questions or for further information, please contact our' mod='payxpert'} {l s='customer support' mod='payxpert'}.

{else}

{l s='We noticed a problem with your order. If you think this is an error, you can contact our' mod='payxpert'} - {l s='customer support' mod='payxpert'}. + {l s='customer support' mod='payxpert'}.

{/if} {/if} \ No newline at end of file diff --git a/modules/payxpert/views/templates/hook/payment.tpl b/views/templates/hook/payment.tpl similarity index 82% rename from modules/payxpert/views/templates/hook/payment.tpl rename to views/templates/hook/payment.tpl index 1d5e112..a85c6ab 100644 --- a/modules/payxpert/views/templates/hook/payment.tpl +++ b/views/templates/hook/payment.tpl @@ -1,5 +1,5 @@ {* -* Copyright 2013-2014 PayXpert +* Copyright 2013-2018 PayXpert * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. * * @author Regis Vidal -* @copyright 2013-2017 PayXpert +* @copyright 2013-2018 PayXpert * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 (the "License") *} @@ -25,7 +25,7 @@

{if $smarty.const._PS_VERSION_ < 1.6} - {l s='Pay by Credit Card' mod='payxpert'} + {l s='Pay by Credit Card' mod='payxpert'} {/if} {l s='Pay by Credit Card' mod='payxpert'} diff --git a/modules/payxpert/views/templates/hook/return.tpl b/views/templates/hook/return.tpl similarity index 82% rename from modules/payxpert/views/templates/hook/return.tpl rename to views/templates/hook/return.tpl index 5c1f907..fdfd4c5 100644 --- a/modules/payxpert/views/templates/hook/return.tpl +++ b/views/templates/hook/return.tpl @@ -1,5 +1,5 @@ {* -* Copyright 2013-2017 PayXpert +* Copyright 2013-2018 PayXpert * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,4 +17,4 @@ * *} - \ No newline at end of file + \ No newline at end of file diff --git a/views/templates/index.php b/views/templates/index.php new file mode 100644 index 0000000..54b3024 --- /dev/null +++ b/views/templates/index.php @@ -0,0 +1,36 @@ + +* @copyright 2007-2013 PrestaShop SA + +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../../../../'); +exit; \ No newline at end of file