From 3a6ce02ebcc7183a605c0fa3062dbe7054365b33 Mon Sep 17 00:00:00 2001 From: Sebastian Bossert Date: Mon, 4 Feb 2019 15:25:01 +0100 Subject: [PATCH] Release 1.0.8 --- README.md | 4 +- docs/en/documentation.html | 4 +- .../postfinancecheckout/transaction.tpl | 4 +- .../library/postfinancecheckout/helper.php | 52 ++++++++++++++----- ...anceCheckoutXFeeProCompatibility.ocmod.xml | 19 +++++++ .../postfinancecheckout/version_helper.php | 4 ++ 6 files changed, 68 insertions(+), 19 deletions(-) create mode 100644 upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutXFeeProCompatibility.ocmod.xml diff --git a/README.md b/README.md index 3573eb2..7efd034 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@ This repository contains the OpenCart PostFinance Checkout payment module that ## Documentation -* [English](https://plugin-documentation.postfinance-checkout.ch/pfpayments/opencart-2.1/1.0.7/docs/en/documentation.html) +* [English](https://plugin-documentation.postfinance-checkout.ch/pfpayments/opencart-2.1/1.0.8/docs/en/documentation.html) ## License -Please see the [license file](https://github.com/pfpayments/opencart-2.1/blob/1.0.7/LICENSE) for more information. \ No newline at end of file +Please see the [license file](https://github.com/pfpayments/opencart-2.1/blob/1.0.8/LICENSE) for more information. \ No newline at end of file diff --git a/docs/en/documentation.html b/docs/en/documentation.html index 604e69b..be65a61 100644 --- a/docs/en/documentation.html +++ b/docs/en/documentation.html @@ -21,7 +21,7 @@

Documentation

  • - + Source
  • @@ -48,7 +48,7 @@

    1. -

      Download the extension.

      +

      Download the extension.

    2. Extract the files and upload the content of the Upload directory into the root directory of your store using FTP/SSH.

      diff --git a/upload/admin/view/template/extension/postfinancecheckout/transaction.tpl b/upload/admin/view/template/extension/postfinancecheckout/transaction.tpl index fb4067b..e9067dc 100644 --- a/upload/admin/view/template/extension/postfinancecheckout/transaction.tpl +++ b/upload/admin/view/template/extension/postfinancecheckout/transaction.tpl @@ -64,12 +64,12 @@ > - - diff --git a/upload/system/library/postfinancecheckout/helper.php b/upload/system/library/postfinancecheckout/helper.php index 5eb3299..95a8b76 100644 --- a/upload/system/library/postfinancecheckout/helper.php +++ b/upload/system/library/postfinancecheckout/helper.php @@ -37,15 +37,21 @@ private function __construct(Registry $registry){ /** * Create a customer identifier to verify that the session. - * Either a concat of given values for guest or the user id (hashed). - * If not enough guest information exists to create an identifier null is returned. + * Either the customer id, + * a concat of given values for guest (hashed), + * the user id, + * a hash of the current cart key, + * a hash of the current token, + * or the current order id. + * + * If not enough information exists to create an identifier null is returned. * * @return string | null */ public function getCustomerSessionIdentifier(){ $customer = $this->getCustomer(); if (isset($customer['customer_id']) && $this->registry->get('customer')->isLogged()) { - return $customer['customer_id']; + return "customer_" . $customer['customer_id']; } $id = ''; if (isset($customer['firstname'])) { @@ -60,7 +66,24 @@ public function getCustomerSessionIdentifier(){ if (isset($customer['telephone'])) { $id .= $customer['telephone']; } - return empty($id) ? null : hash('sha512', $id); + if($id) { + return "guest_" . hash('sha512', $id); + } + $data = $this->registry->get('session')->data; + if(isset($data['user_id'])) { + return "user_" . $data['user_id']; + } + if(isset($data['cart']) && is_array($data['cart']) && count($data['cart'] == 1)) { + $cartKeys = array_keys($data['cart']); + return "cart_" .hash('sha512', $cartKeys[0]); + } + if(isset($data['token'])) { + return "token_" . hash('sha512', $data['token']); + } + if(isset($data['order_id'])) { + return "order_" . $data['order_id']; + } + return null; } /** @@ -236,8 +259,9 @@ public function getCustomer(){ else if (isset($data['guest'])) { return $data['guest']; } + $this->log("Unable to retrieve customer from session."); $this->log($data); - throw new Exception('Could not extract customer data.'); + return array(); } /** @@ -386,7 +410,7 @@ public function getSuccessUrl(){ public function getFailedUrl($order_id){ return str_replace('&', '&', PostFinanceCheckoutVersionHelper::createUrl($this->getCatalogUrl(), 'checkout/checkout', array( - 'order_id' => $order_id + 'order_id' => $order_id ), $this->registry->get('config')->get('config_secure'))); } @@ -499,25 +523,27 @@ public function rewrite($url){ public function isAdmin(){ return defined('HTTPS_CATALOG') && defined('HTTP_CATALOG'); } - + /** - * Get the starting value of LIMIT for db queries. Used for paginated requests. - * + * Get the starting value of LIMIT for db queries. + * Used for paginated requests. + * * @param int $page * @return int */ - public function getLimitStart($page) { + public function getLimitStart($page){ $limit = $this->registry->get('config')->get('config_limit_admin'); return ($page - 1) * $limit; } - + /** - * Get the end value of LIMIT for db queries. Used for paginated requests. + * Get the end value of LIMIT for db queries. + * Used for paginated requests. * * @param int $page * @return int */ - public function getLimitEnd($page) { + public function getLimitEnd($page){ $limit = $this->registry->get('config')->get('config_limit_admin'); return $page * $limit; } diff --git a/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutXFeeProCompatibility.ocmod.xml b/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutXFeeProCompatibility.ocmod.xml new file mode 100644 index 0000000..01e2f34 --- /dev/null +++ b/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutXFeeProCompatibility.ocmod.xml @@ -0,0 +1,19 @@ + + + PostFinanceCheckoutXFeeProCompatibility + postfinancecheckout compatibility: patch for X-fee Pro. + + 1.0.0 + Customweb GmbH + http://github.com/postfinancecheckout-payment/opencart + + + + + + + diff --git a/upload/system/library/postfinancecheckout/version_helper.php b/upload/system/library/postfinancecheckout/version_helper.php index f8a351b..d426433 100644 --- a/upload/system/library/postfinancecheckout/version_helper.php +++ b/upload/system/library/postfinancecheckout/version_helper.php @@ -28,6 +28,10 @@ public static function getModifications(){ 'file' => 'PostFinanceCheckoutQuickCheckoutCompatibility.ocmod.xml', 'default_status' => 0 ), + 'PostFinanceCheckoutXFeeProCompatibility' => array( + 'file' => 'PostFinanceCheckoutXFeeProCompatibility.ocmod.xml', + 'default_status' => 0 + ), 'PostFinanceCheckoutPreventConfirmationEmail' => array( 'file' => 'PostFinanceCheckoutPreventConfirmationEmail.ocmod.xml', 'default_status' => 0