From a337958b0477b1140581011514b78d9223264676 Mon Sep 17 00:00:00 2001 From: Sebastian Bossert Date: Wed, 30 Jan 2019 08:56:33 +0100 Subject: [PATCH] Release 1.0.7 --- README.md | 4 +- docs/en/assets/base.css | 8 + docs/en/documentation.html | 4 +- .../extension/payment/postfinancecheckout.php | 10 +- .../postfinancecheckout/transaction.php | 213 ++++++++++++++++++ .../extension/payment/postfinancecheckout.php | 20 ++ .../extension/postfinancecheckout/setup.php | 2 + .../postfinancecheckout/transaction.php | 63 ++++++ .../extension/payment/postfinancecheckout.tpl | 1 + .../postfinancecheckout/transaction.tpl | 157 +++++++++++++ .../extension/postfinancecheckout/event.php | 6 +- .../extension/payment/postfinancecheckout.php | 2 +- .../extension/postfinancecheckout/order.php | 8 +- .../library/postfinancecheckout/autoload.php | 8 +- .../controller/abstract_event.php | 8 +- .../controller/abstract_pdf.php | 14 +- .../dynamic/catalog/controller.php | 4 +- .../entity/abstract_entity.php | 114 +++++++++- .../postfinancecheckout/entity/refund_job.php | 4 +- .../library/postfinancecheckout/helper.php | 42 +++- ...ostFinanceCheckoutAdministration.ocmod.xml | 72 ++++++ .../PostFinanceCheckoutAlerts.ocmod.xml | 43 ++++ .../PostFinanceCheckoutCore.ocmod.xml | 154 +++++++++++++ .../PostFinanceCheckoutEvents.ocmod.xml | 49 ++++ .../PostFinanceCheckoutFrontendPdf.ocmod.xml | 36 +++ ...CheckoutPreventConfirmationEmail.ocmod.xml | 18 ++ ...eckoutQuickCheckoutCompatibility.ocmod.xml | 19 ++ ...stFinanceCheckoutTransactionView.ocmod.xml | 25 ++ .../modification/WalleeCore.ocmod.xml | 19 +- .../postfinancecheckout/provider/currency.php | 8 +- .../provider/label_description_group.php | 8 +- .../provider/label_descriptor.php | 8 +- .../postfinancecheckout/provider/language.php | 10 +- .../provider/payment_connector.php | 8 +- .../provider/payment_method.php | 8 +- .../service/abstract_job.php | 4 +- .../service/abstract_service.php | 14 +- .../service/completion.php | 4 +- .../postfinancecheckout/service/line_item.php | 20 +- .../service/manual_task.php | 4 +- .../service/method_configuration.php | 20 +- .../postfinancecheckout/service/refund.php | 10 +- .../postfinancecheckout/service/token.php | 26 +-- .../service/transaction.php | 117 ++++++---- .../postfinancecheckout/service/void_job.php | 4 +- .../postfinancecheckout/service/webhook.php | 108 ++++----- .../postfinancecheckout/version_helper.php | 6 +- .../webhook/delivery_indication.php | 12 +- .../webhook/transaction.php | 47 ++-- .../webhook/transaction_completion.php | 18 +- .../webhook/transaction_refund.php | 22 +- .../webhook/transaction_void.php | 18 +- 52 files changed, 1337 insertions(+), 294 deletions(-) create mode 100644 upload/admin/controller/extension/postfinancecheckout/transaction.php create mode 100644 upload/admin/model/extension/postfinancecheckout/transaction.php create mode 100644 upload/admin/view/template/extension/postfinancecheckout/transaction.tpl create mode 100644 upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutAdministration.ocmod.xml create mode 100644 upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutAlerts.ocmod.xml create mode 100644 upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutCore.ocmod.xml create mode 100644 upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutEvents.ocmod.xml create mode 100644 upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutFrontendPdf.ocmod.xml create mode 100644 upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutPreventConfirmationEmail.ocmod.xml create mode 100644 upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutQuickCheckoutCompatibility.ocmod.xml create mode 100644 upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutTransactionView.ocmod.xml diff --git a/README.md b/README.md index 4e6d60e..b9f414d 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.3/1.0.6/docs/en/documentation.html) +* [English](https://plugin-documentation.postfinance-checkout.ch/pfpayments/opencart-2.3/1.0.7/docs/en/documentation.html) ## License -Please see the [license file](https://github.com/pfpayments/opencart-2.3/blob/1.0.6/LICENSE) for more information. \ No newline at end of file +Please see the [license file](https://github.com/pfpayments/opencart-2.3/blob/1.0.7/LICENSE) for more information. \ No newline at end of file diff --git a/docs/en/assets/base.css b/docs/en/assets/base.css index ab080d1..dae4727 100644 --- a/docs/en/assets/base.css +++ b/docs/en/assets/base.css @@ -399,6 +399,14 @@ table td[class*="col-"],table th[class*="col-"] { font-size: 0.875rem; } +.table-of-contents > .nav > li > .nav > li > .nav > li > a { + padding-left: 2rem; +} + +.table-of-contents > .nav > li > .nav > li > .nav > li > a .item-title { + font-size: 0.75rem; +} + .table-of-contents > .nav > li.active > .nav { display: block; } diff --git a/docs/en/documentation.html b/docs/en/documentation.html index 5cf46ed..429638a 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/controller/extension/payment/postfinancecheckout.php b/upload/admin/controller/extension/payment/postfinancecheckout.php index e0c175c..33a0373 100644 --- a/upload/admin/controller/extension/payment/postfinancecheckout.php +++ b/upload/admin/controller/extension/payment/postfinancecheckout.php @@ -228,7 +228,11 @@ private function getSettingsPageTranslatedVariables(){ $data['entry_space_view_id'] = $this->language->get("entry_space_view_id"); $data['help_space_view_id'] = $this->language->get("help_space_view_id"); - $data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); + $orderStatuses = $this->model_localisation_order_status->getOrderStatuses(); + array_unshift($orderStatuses, array('order_status_id' => 0, 'name' => $this->language->get('text_none'))); + $data['order_statuses'] = $orderStatuses; + $data['description_none_status'] = $this->language->get('description_none_status'); + $data['postfinancecheckout_statuses'] = $this->getOrderStatusTemplateVariables(); $data['title_debug'] = $this->language->get('title_debug'); @@ -414,8 +418,8 @@ private function getSettingsDefaults(){ "postfinancecheckout_space_id" => null, "postfinancecheckout_space_view_id" => null, - "postfinancecheckout_processing_status_id" => 1, - "postfinancecheckout_failed_status_id" => 10, + "postfinancecheckout_processing_status_id" => 0, + "postfinancecheckout_failed_status_id" => 0, "postfinancecheckout_voided_status_id" => 16, "postfinancecheckout_decline_status_id" => 8, "postfinancecheckout_fulfill_status_id" => 5, diff --git a/upload/admin/controller/extension/postfinancecheckout/transaction.php b/upload/admin/controller/extension/postfinancecheckout/transaction.php new file mode 100644 index 0000000..0793606 --- /dev/null +++ b/upload/admin/controller/extension/postfinancecheckout/transaction.php @@ -0,0 +1,213 @@ +load->language('extension/payment/postfinancecheckout'); + + $this->document->setTitle($this->language->get('heading_transaction_list')); + + $this->load->model('extension/postfinancecheckout/transaction'); + + $this->getList(); + } + + protected function getList(){ + $filters = $this->getFilters(); + $breadcrumbs = $this->getBreadcrumbs(); + $transactions = $this->model_extension_postfinancecheckout_transaction->loadList($filters); + $transactionCount = $this->model_extension_postfinancecheckout_transaction->countRows(); + + $use_space_view = false; + $space_view = null; + foreach ($transactions as $transaction) { + if (!$space_view) { + $space_view = $transaction['space_view_id']; + } + else if ($space_view != $transaction['space_view_id']) { + $use_space_view = true; + break; + } + } + + $data = array_merge($this->loadLanguageVariables(), $this->getSortLinks($filters)); + $data['use_space_view'] = $use_space_view; + $data['breadcrumbs'] = $breadcrumbs; + $data['transactions'] = $transactions; + $data['filters'] = $filters; + $data['pagination'] = $this->getPagination($filters, $transactionCount)->render(); + $data['results'] = $this->getResultsText($transactionCount, $filters['page']); + + $filters['page'] = 1; // reset to page one on search. leave other filters. + $data['filterAction'] = PostFinanceCheckoutVersionHelper::createUrl($this->url, 'extension/postfinancecheckout/transaction', + $this->getQueryString($filters), true); + + $data['order_statuses'] = $this->model_extension_postfinancecheckout_transaction->getOrderStatuses(); + + $data['header'] = $this->load->controller('common/header'); + $data['column_left'] = $this->load->controller('common/column_left'); + $data['footer'] = $this->load->controller('common/footer'); + + $this->response->setOutput($this->loadView('extension/postfinancecheckout/transaction', $data)); + } + + protected function getRequiredPermission(){ + return 'extension/postfinancecheckout/transaction'; + } + + private function getFilters(){ + $filters = array( + 'id' => null, + 'order_id' => null, + 'transaction_id' => null, + 'space_id' => null, + 'space_view_id' => null, + 'state' => null, + 'payment_method_id' => null, + 'authorization_amount' => null, + 'created_at' => null, + 'updated_at' => null, + 'sort' => $this->getSort(), + 'page' => $this->getPage(), + 'order' => $this->getOrder() + ); + foreach ($filters as $filterName => $filter) { + if (isset($this->request->post['filters'][$filterName])) { + $filters[$filterName] = $this->request->post['filters'][$filterName]; + } + elseif (isset($this->request->get['filters'][$filterName])) { + $filters[$filterName] = $this->request->get['filters'][$filterName]; + } + } + return $filters; + } + + private function getQueryString(array $filters){ + $url = ''; + foreach ($filters as $name => $value) { + if ($value) { + $url .= '&filters[' . $name . ']=' . $value; + } + } + $url .= '&token=' . $this->session->data['token']; + return $url; + } + + private function getSortLinks($filters){ + $sortable = array( + 'id', + 'order_id', + 'transaction_id', + 'space_id', + 'space_view_id', + 'state', + 'payment_method_id', + 'authorization_amount', + 'created_at', + 'updated_at' + ); + $filters['sort'] = null; + $filters['order'] = $this->getNewOrder($filters); + $query = $this->getQueryString($filters); + $sortUrl = PostFinanceCheckoutVersionHelper::createUrl($this->url, 'extension/postfinancecheckout/transaction', $query, true); + $links = array(); + foreach ($sortable as $key) { + $links['sort_' . $key] = $sortUrl . '&filters[sort]=' . $key; + } + return $links; + } + + private function getNewOrder(array $filters){ + if (isset($filters['order']) && $filters['order'] == 'DESC') { + return 'ASC'; + } + return 'DESC'; + } + + private function getPagination(array $filters, $transactionCount){ + $pagination = new Pagination(); + $pagination->total = $transactionCount; + $pagination->page = $filters['page']; + $pagination->limit = $this->config->get('config_limit_admin'); + $filters['page'] = '{page}'; + $pagination->url = PostFinanceCheckoutVersionHelper::createUrl($this->url, 'extension/postfinancecheckout/transaction', + $this->getQueryString($filters), true); + return $pagination; + } + + private function getResultsText($transactionCount, $page){ + $limit = $this->config->get('config_limit_admin'); + return sprintf($this->language->get('text_pagination'), ($transactionCount) ? (($page - 1) * $limit) + 1 : 0, + ((($page - 1) * $limit) > ($transactionCount - $limit)) ? $transactionCount : ((($page - 1) * $limit) + $limit), $transactionCount, + ceil($transactionCount / $limit)); + } + + private function getOrder(){ + if (isset($this->request->get['filters']['order'])) { + return $this->request->get['filters']['order']; + } + return 'DESC'; + } + + private function getPage(){ + if (isset($this->request->get['filters']['page'])) { + return $this->request->get['filters']['page']; + } + return 1; + } + + private function getSort(){ + if (isset($this->request->get['filters']['sort'])) { + return $this->request->get['filters']['sort']; + } + return 'id'; + } + + private function getBreadcrumbs(){ + return array( + array( + 'text' => $this->language->get('text_home'), + 'href' => PostFinanceCheckoutVersionHelper::createUrl($this->url, 'sale/order', + array( + 'token' => $this->session->data['token'] + ), true) + ), + array( + 'text' => $this->language->get('heading_transaction_list'), + 'href' => PostFinanceCheckoutVersionHelper::createUrl($this->url, 'extension/postfinancecheckout/transaction', + array( + 'token' => $this->session->data['token'] + ), true) + ) + ); + } + + private function loadLanguageVariables(){ + //TODO * NOTE: Filter works by id, e.g. searching by 'credit card' doesn't work. + $required = array( + 'heading_transaction_list', + 'text_transaction_list', + 'text_no_results', + 'column_id', + 'column_order_id', + 'column_transaction_id', + 'column_space_view_id', + 'column_space_id', + 'column_state', + 'column_payment_method', + 'column_authorization_amount', + 'column_created', + 'column_updated', + 'column_actions', + 'description_payment_method', + 'button_view', + 'button_filter' + ); + $translations = array(); + foreach ($required as $key) { + $translations[$key] = $this->language->get($key); + } + return $translations; + } +} \ No newline at end of file diff --git a/upload/admin/language/en-gb/extension/payment/postfinancecheckout.php b/upload/admin/language/en-gb/extension/payment/postfinancecheckout.php index 516c253..ba7b644 100644 --- a/upload/admin/language/en-gb/extension/payment/postfinancecheckout.php +++ b/upload/admin/language/en-gb/extension/payment/postfinancecheckout.php @@ -54,6 +54,7 @@ $_['description_decline_status'] = "Status the order enters when the transaction is in the PostFinance Checkout declined status."; $_['entry_refund_status'] = "Refund status"; $_['description_refund_status'] = "Status the order enters when the transaction has been fully refunded."; +$_['description_none_status'] = "Standard OpenCart behaviour specificies that an order confirmation email is sent when an order is moved from the 'None' state into any other state. For this reason you may want to treat 'Processing' and 'Failed' as 'None' so no emails are sent."; // Modifications $_['title_modifications'] = "Modifications"; @@ -94,6 +95,25 @@ $_['error_user_id_unset'] = "User ID must not be empty."; $_['error_user_id_numeric'] = "User ID must be numeric."; +/** + * =========================================================================================== + * Transaction list + * =========================================================================================== + */ +$_['heading_transaction_list'] = "PostFinanceCheckout Transactions"; +$_['text_transaction_list'] = "Transactions"; +$_['column_id'] = "ID"; +$_['column_order_id'] = "Order ID"; +$_['column_transaction_id'] = "Transaction ID"; +$_['column_space_id'] = "Space ID"; +$_['column_space_view_id'] = "Space View ID"; +$_['column_state'] = "State"; +$_['column_payment_method'] = "Payment Method"; +$_['description_payment_method'] = "Here you may search using the payment method ID - e.g. searching for 'Credit Card' will not return any results."; +$_['column_created'] = "Created"; +$_['column_updated'] = "Created"; +$_['column_authorization_amount'] = "Amount"; + /** * =========================================================================================== * Alerts diff --git a/upload/admin/model/extension/postfinancecheckout/setup.php b/upload/admin/model/extension/postfinancecheckout/setup.php index 3ae1111..d1a1c95 100644 --- a/upload/admin/model/extension/postfinancecheckout/setup.php +++ b/upload/admin/model/extension/postfinancecheckout/setup.php @@ -73,6 +73,7 @@ private function addPermissions(){ $this->model_user_user_group->addPermission($this->user->getGroupId(), 'access', 'extension/postfinancecheckout/update'); $this->model_user_user_group->addPermission($this->user->getGroupId(), 'access', 'extension/postfinancecheckout/pdf'); $this->model_user_user_group->addPermission($this->user->getGroupId(), 'access', 'extension/postfinancecheckout/alert'); + $this->model_user_user_group->addPermission($this->user->getGroupId(), 'access', 'extension/postfinancecheckout/transaction'); } private function removePermissions(){ @@ -84,5 +85,6 @@ private function removePermissions(){ $this->model_user_user_group->removePermission($this->user->getGroupId(), 'access', 'extension/postfinancecheckout/update'); $this->model_user_user_group->removePermission($this->user->getGroupId(), 'access', 'extension/postfinancecheckout/pdf'); $this->model_user_user_group->removePermission($this->user->getGroupId(), 'access', 'extension/postfinancecheckout/alert'); + $this->model_user_user_group->addPermission($this->user->getGroupId(), 'access', 'extension/postfinancecheckout/transaction'); } } \ No newline at end of file diff --git a/upload/admin/model/extension/postfinancecheckout/transaction.php b/upload/admin/model/extension/postfinancecheckout/transaction.php new file mode 100644 index 0000000..b3e124e --- /dev/null +++ b/upload/admin/model/extension/postfinancecheckout/transaction.php @@ -0,0 +1,63 @@ +registry, $filters); + /* @var $transactionInfoList TransactionInfo[] */ + $transactions = array(); + foreach ($transactionInfoList as $transactionInfo) { + $paymentMethod = PaymentMethod::instance($this->registry)->find($transactionInfo->getPaymentMethodId()); + if ($paymentMethod) { + $paymentMethodName = PostFinanceCheckoutHelper::instance($this->registry)->translate($paymentMethod->getName()) . " (" . $transactionInfo->getPaymentMethodId() . ")"; + } + else { + $paymentMethodName = $transactionInfo->getPaymentMethodId(); + } + $transactions[] = array( + 'id' => $transactionInfo->getId(), + 'order_id' => $transactionInfo->getOrderId(), + 'transaction_id' => $transactionInfo->getTransactionId(), + 'space_id' => $transactionInfo->getSpaceId(), + 'space_view_id' => $transactionInfo->getSpaceViewId(), + 'state' => $transactionInfo->getState(), + 'authorization_amount' => $transactionInfo->getAuthorizationAmount(), + 'created_at' => $transactionInfo->getCreatedAt()->format(self::DATE_FORMAT), + 'updated_at' => $transactionInfo->getUpdatedAt()->format(self::DATE_FORMAT), + 'payment_method' => $paymentMethodName, + 'view' => PostFinanceCheckoutVersionHelper::createUrl($this->url, 'sale/order/info', + array( + 'token' => $this->session->data['token'], + 'order_id' => $transactionInfo->getOrderId() + ), true) + ); + } + return $transactions; + } + + public function getOrderStatuses() { + return array( + '', + PostFinanceCheckout\Sdk\Model\TransactionState::AUTHORIZED, + PostFinanceCheckout\Sdk\Model\TransactionState::COMPLETED, + PostFinanceCheckout\Sdk\Model\TransactionState::CONFIRMED, + PostFinanceCheckout\Sdk\Model\TransactionState::CREATE, + PostFinanceCheckout\Sdk\Model\TransactionState::DECLINE, + PostFinanceCheckout\Sdk\Model\TransactionState::FULFILL, + PostFinanceCheckout\Sdk\Model\TransactionState::FAILED, + PostFinanceCheckout\Sdk\Model\TransactionState::PENDING, + PostFinanceCheckout\Sdk\Model\TransactionState::PROCESSING, + PostFinanceCheckout\Sdk\Model\TransactionState::AUTHORIZED, + PostFinanceCheckout\Sdk\Model\TransactionState::VOIDED, + ); + } + + public function countRows() { + return TransactionInfo::countRows($this->registry); + } +} \ No newline at end of file diff --git a/upload/admin/view/template/extension/payment/postfinancecheckout.tpl b/upload/admin/view/template/extension/payment/postfinancecheckout.tpl index a9d1754..828d6ad 100644 --- a/upload/admin/view/template/extension/payment/postfinancecheckout.tpl +++ b/upload/admin/view/template/extension/payment/postfinancecheckout.tpl @@ -157,6 +157,7 @@
      +

      diff --git a/upload/admin/view/template/extension/postfinancecheckout/transaction.tpl b/upload/admin/view/template/extension/postfinancecheckout/transaction.tpl new file mode 100644 index 0000000..fb4067b --- /dev/null +++ b/upload/admin/view/template/extension/postfinancecheckout/transaction.tpl @@ -0,0 +1,157 @@ + +
      + +
      +
      +
      +

      +
      +
      +
      +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      + + + + + + + + + + + + + + + + + + + + + + +
      + + + + + + + + + + + + + + + + + + + + + + +
      + +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      + diff --git a/upload/catalog/controller/extension/postfinancecheckout/event.php b/upload/catalog/controller/extension/postfinancecheckout/event.php index 9fd47f0..2d4b1b1 100644 --- a/upload/catalog/controller/extension/postfinancecheckout/event.php +++ b/upload/catalog/controller/extension/postfinancecheckout/event.php @@ -24,7 +24,7 @@ public function includeScripts(){ * @param array $parameters * @param object $output */ - private function includeCronScript(){ + public function includeCronScript(){ \PostFinanceCheckout\Entity\Cron::cleanUpHangingCrons($this->registry); \PostFinanceCheckout\Entity\Cron::insertNewPendingCron($this->registry); @@ -44,7 +44,7 @@ private function includeCronScript(){ * @param array $parameters * @param object $output */ - private function includeDeviceIdentifier(){ + public function includeDeviceIdentifier(){ $script = \PostFinanceCheckoutHelper::instance($this->registry)->getBaseUrl(); $script .= '/s/[spaceId]/payment/device.js?sessionIdentifier=[UniqueSessionIdentifier]'; @@ -128,7 +128,7 @@ public function update(){ $transaction_info = \PostFinanceCheckout\Entity\TransactionInfo::loadByOrderId($this->registry, $this->request->get['order_id']); - if ($transaction_info->getState() == \Wallee\Sdk\Model\TransactionState::AUTHORIZED) { + if ($transaction_info->getState() == \PostFinanceCheckout\Sdk\Model\TransactionState::AUTHORIZED) { \PostFinanceCheckout\Service\Transaction::instance($this->registry)->updateLineItemsFromOrder($this->request->get['order_id']); return; } diff --git a/upload/catalog/language/en-gb/extension/payment/postfinancecheckout.php b/upload/catalog/language/en-gb/extension/payment/postfinancecheckout.php index 031fea5..bf3f964 100644 --- a/upload/catalog/language/en-gb/extension/payment/postfinancecheckout.php +++ b/upload/catalog/language/en-gb/extension/payment/postfinancecheckout.php @@ -17,7 +17,7 @@ // Webhook messages $_['message_webhook_processing'] = 'Transaction is processing via webhook.'; -$_['message_webhook_connfirm'] = 'Transaction has been confirmed via webhook.'; +$_['message_webhook_confirm'] = 'Transaction has been confirmed via webhook.'; $_['message_webhook_authorize'] = 'Transaction has been authorized via webhook.'; $_['message_webhook_waiting'] = 'Transaction is waiting via webhook.'; $_['message_webhook_decline'] = 'Transaction has been declined via webhook.'; diff --git a/upload/catalog/model/extension/postfinancecheckout/order.php b/upload/catalog/model/extension/postfinancecheckout/order.php index 84a48d6..34ff028 100644 --- a/upload/catalog/model/extension/postfinancecheckout/order.php +++ b/upload/catalog/model/extension/postfinancecheckout/order.php @@ -17,15 +17,15 @@ public function getButtons($order_id){ $buttons = array(); - if ($this->config->get('postfinancecheckout_download_packaging') && $transaction_info->getState() == \Wallee\Sdk\Model\TransactionState::FULFILL) { + if ($this->config->get('postfinancecheckout_download_packaging') && $transaction_info->getState() == \PostFinanceCheckout\Sdk\Model\TransactionState::FULFILL) { $buttons[] = $this->getPackagingButton(); } if ($this->config->get('postfinancecheckout_download_invoice') && in_array($transaction_info->getState(), array( - \Wallee\Sdk\Model\TransactionState::FULFILL, - \Wallee\Sdk\Model\TransactionState::COMPLETED, - \Wallee\Sdk\Model\TransactionState::DECLINE + \PostFinanceCheckout\Sdk\Model\TransactionState::FULFILL, + \PostFinanceCheckout\Sdk\Model\TransactionState::COMPLETED, + \PostFinanceCheckout\Sdk\Model\TransactionState::DECLINE ))) { $buttons[] = $this->getInvoiceButton(); } diff --git a/upload/system/library/postfinancecheckout/autoload.php b/upload/system/library/postfinancecheckout/autoload.php index 8ee1002..2267f5a 100644 --- a/upload/system/library/postfinancecheckout/autoload.php +++ b/upload/system/library/postfinancecheckout/autoload.php @@ -6,10 +6,10 @@ * Includes the plugin classes as well as wallee sdk classes. * * After registering this autoload function with SPL, the following line - * would cause the function to attempt to load the \Wallee\Sdk\Baz\Qux class + * would cause the function to attempt to load the \PostFinanceCheckout\Sdk\Baz\Qux class * from /path/to/project/lib/Baz/Qux.php: * - * new \Wallee\Sdk\Baz\Qux; + * new \PostFinanceCheckout\Sdk\Baz\Qux; * * @param string $class the fully-qualified class name. */ @@ -17,7 +17,7 @@ function ($class){ $base_dir = DIR_SYSTEM . 'library/postfinancecheckout/'; - $sdkPrefix = 'Wallee\\Sdk\\'; + $sdkPrefix = 'PostFinanceCheckout\\Sdk\\'; $ocPrefix = 'PostFinanceCheckout\\'; @@ -32,7 +32,7 @@ function ($class){ // replace the namespace prefix with the base directory, replace namespace // separators with directory separators in the relative class name, append // with .php - $file = modification($base_dir . 'wallee-sdk/lib/' . str_replace('\\', '/', $relative_class) . '.php'); + $file = modification($base_dir . 'postfinancecheckout-sdk/lib/' . str_replace('\\', '/', $relative_class) . '.php'); // if the file exists, require it if(file_exists($file) ){ diff --git a/upload/system/library/postfinancecheckout/controller/abstract_event.php b/upload/system/library/postfinancecheckout/controller/abstract_event.php index 3b6e992..0c28f96 100644 --- a/upload/system/library/postfinancecheckout/controller/abstract_event.php +++ b/upload/system/library/postfinancecheckout/controller/abstract_event.php @@ -3,8 +3,10 @@ namespace PostFinanceCheckout\Controller; abstract class AbstractEvent extends AbstractController { - - protected function validateOrder(){ - // no order required + + protected function validate(){ + $this->language->load('extension/payment/postfinancecheckout'); + $this->validatePermission(); + // skip valdiating order. } } \ No newline at end of file diff --git a/upload/system/library/postfinancecheckout/controller/abstract_pdf.php b/upload/system/library/postfinancecheckout/controller/abstract_pdf.php index 6417001..e22924f 100644 --- a/upload/system/library/postfinancecheckout/controller/abstract_pdf.php +++ b/upload/system/library/postfinancecheckout/controller/abstract_pdf.php @@ -6,8 +6,8 @@ abstract class AbstractPdf extends AbstractController { protected function downloadPackingSlip($order_id){ $transaction_info = \PostFinanceCheckout\Entity\TransactionInfo::loadByOrderId($this->registry, $order_id); - if ($transaction_info->getId() != null && $transaction_info->getState() == \Wallee\Sdk\Model\TransactionState::FULFILL) { - $service = new \Wallee\Sdk\Service\TransactionService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); + if ($transaction_info->getId() != null && $transaction_info->getState() == \PostFinanceCheckout\Sdk\Model\TransactionState::FULFILL) { + $service = new \PostFinanceCheckout\Sdk\Service\TransactionService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); $document = $service->getPackingSlip($transaction_info->getSpaceId(), $transaction_info->getTransactionId()); $this->download($document); } @@ -17,11 +17,11 @@ protected function downloadInvoice($order_id){ $transaction_info = \PostFinanceCheckout\Entity\TransactionInfo::loadByOrderId($this->registry, $order_id); if ($transaction_info->getId() != null && in_array($transaction_info->getState(), array( - \Wallee\Sdk\Model\TransactionState::COMPLETED, - \Wallee\Sdk\Model\TransactionState::FULFILL, - \Wallee\Sdk\Model\TransactionState::DECLINE + \PostFinanceCheckout\Sdk\Model\TransactionState::COMPLETED, + \PostFinanceCheckout\Sdk\Model\TransactionState::FULFILL, + \PostFinanceCheckout\Sdk\Model\TransactionState::DECLINE ))) { - $service = new \Wallee\Sdk\Service\TransactionService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); + $service = new \PostFinanceCheckout\Sdk\Service\TransactionService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); $document = $service->getInvoiceDocument($transaction_info->getSpaceId(), $transaction_info->getTransactionId()); $this->download($document); } @@ -32,7 +32,7 @@ protected function downloadInvoice($order_id){ * * @param string $path */ - private function download(\Wallee\Sdk\Model\RenderedDocument $document){ + private function download(\PostFinanceCheckout\Sdk\Model\RenderedDocument $document){ header('Pragma: public'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-type: application/pdf'); diff --git a/upload/system/library/postfinancecheckout/dynamic/catalog/controller.php b/upload/system/library/postfinancecheckout/dynamic/catalog/controller.php index 87f9f70..3b064e8 100644 --- a/upload/system/library/postfinancecheckout/dynamic/catalog/controller.php +++ b/upload/system/library/postfinancecheckout/dynamic/catalog/controller.php @@ -49,9 +49,9 @@ public function confirm(){ private function confirmTransaction(){ $transaction = PostFinanceCheckout\Service\Transaction::instance($this->registry)->getTransaction(array(), false, array( - \Wallee\Sdk\Model\TransactionState::PENDING + \PostFinanceCheckout\Sdk\Model\TransactionState::PENDING )); - if ($transaction->getState() == \Wallee\Sdk\Model\TransactionState::PENDING) { + if ($transaction->getState() == \PostFinanceCheckout\Sdk\Model\TransactionState::PENDING) { \PostFinanceCheckoutHelper::instance($this->registry)->dbTransactionStart(); \PostFinanceCheckoutHelper::instance($this->registry)->dbTransactionLock($transaction->getLinkedSpaceId(), $transaction->getId()); PostFinanceCheckout\Service\Transaction::instance($this->registry)->update($this->session->data, true); diff --git a/upload/system/library/postfinancecheckout/entity/abstract_entity.php b/upload/system/library/postfinancecheckout/entity/abstract_entity.php index 80a09cc..8ef477c 100644 --- a/upload/system/library/postfinancecheckout/entity/abstract_entity.php +++ b/upload/system/library/postfinancecheckout/entity/abstract_entity.php @@ -4,13 +4,13 @@ /** * - * @method getId() - * @method getCreatedAt() - * @method getUpdatedAt() + * @method int getId() + * @method DateTime getCreatedAt() + * @method DateTime getUpdatedAt() * - * @method setId($id) - * @method setCreatedAt($createdAt) - * @method setUpdatedAt($updatedAt) + * @method void setId($id) + * @method void setCreatedAt($createdAt) + * @method void setUpdatedAt($updatedAt) * * Abstract implementation of a entity */ @@ -26,11 +26,11 @@ protected static function getBaseFields(){ ); } - protected static function getFieldDefinition() { + protected static function getFieldDefinition(){ throw new \Exception("Mock abstract, must be overwritten."); } - protected static function getTableName() { + protected static function getTableName(){ throw new \Exception("Mock abstract, must be overwritten."); } @@ -198,6 +198,12 @@ public static function loadById(\Registry $registry, $id){ return new static($registry); } + /** + * Load all entities. + * + * @param \Registry $registry + * @return \PostFinanceCheckout\Entity\AbstractEntity[] + */ public static function loadAll(\Registry $registry){ $db = $registry->get('db'); @@ -210,6 +216,98 @@ public static function loadAll(\Registry $registry){ return $result; } + /** + * Return true or false if the field is treated as a date. + * + * @param string $field + */ + protected static function isDateField($field){ + return in_array($field, array( + 'created_at', + 'updated_at' + )); + } + + private static function getDefaultFilter(array &$filters, $filterName, $default) { + if(isset($filters[$filterName])) { + $value = $filters[$filterName]; + unset($filters[$filterName]); + return $value; + } + return $default; + } + + private static function buildWhereClause($db, array $filters) { + $query = ''; + foreach ($filters as $field => $value) { + if($value){ + $field = $db->escape($field); + $value = "'" . $db->escape($value) . "'"; + if (self::isDateField($field)) { + $query .= "(DATE($field)=$value OR YEAR($field)=$value OR TIME($field)=$value OR $field=$value) AND"; + } + else { + $query .= "$field=$value AND "; + } + } + } + if($query) { + $query = "WHERE " . rtrim($query, " AND"); + } + return $query; + } + + /** + * Load entities which match the filters. + * Filters are applied as sql =. + * Special Filters: + * order: ASC or DESC. + * sort: ORDERBY. + * isDateField($field)=true: Compares dates + * start: Limit start + * limit: Limit end + * + * @param \Registry $registry + * @param array $filters (e.g. array(id=10) or (authorization_amount=10, STATE='FULFIL')) + * @return \PostFinanceCheckout\Entity\AbstractEntity[] + */ + public static function loadByFilters(\Registry $registry, array $filters){ + $db = $registry->get('db'); + $table = DB_PREFIX . static::getTableName(); + $orderBy = static::getDefaultFilter($filters, 'sort', 'id'); + $ordering = static::getDefaultFilter($filters, 'order', 'ASC'); + $page = 1; + if(isset($filters['page'])) { + $page = $filters['page']; + unset($filters['page']); + } + $start = \PostFinanceCheckoutHelper::instance($registry)->getLimitStart($page); + $end = \PostFinanceCheckoutHelper::instance($registry)->getLimitEnd($page); + + $query = "SELECT * FROM $table " . static::buildWhereClause($db, $filters) . " ORDER BY $orderBy $ordering LIMIT $start, $end;"; + + $db_result = $db->query($query); + $result = array(); + foreach ($db_result->rows as $row) { + $result[] = new static($registry, $row); + } + return $result; + } + + /** + * Returns the count of all entites. + * + * @param \Registry $registry + * @return int + */ + public static function countRows(\Registry $registry) { + $db = $registry->get('db'); + $table = DB_PREFIX . static::getTableName(); + $query = "SELECT COUNT(id) as count FROM $table;"; + $dbResult = $db->query($query); + return $dbResult->row['count']; + } + public function delete(\Registry $registry){ $db = $registry->get('db'); diff --git a/upload/system/library/postfinancecheckout/entity/refund_job.php b/upload/system/library/postfinancecheckout/entity/refund_job.php index 7abce44..3db37df 100644 --- a/upload/system/library/postfinancecheckout/entity/refund_job.php +++ b/upload/system/library/postfinancecheckout/entity/refund_job.php @@ -7,8 +7,8 @@ * * @method int getExternalId() * @method void setExternalId(int $id) - * @method \Wallee\Sdk\Model\LineItemReduction[] getReductionItems() - * @method void setReductionItems(\Wallee\Sdk\Model\LineItemReduction[] $reductions) + * @method \PostFinanceCheckout\Sdk\Model\LineItemReduction[] getReductionItems() + * @method void setReductionItems(\PostFinanceCheckout\Sdk\Model\LineItemReduction[] $reductions) * @method float getAmount() * @method void setAmount(float $amount) * @method void setFailureReason(map[string,string] $reasons) diff --git a/upload/system/library/postfinancecheckout/helper.php b/upload/system/library/postfinancecheckout/helper.php index ed1adc5..adfa03a 100644 --- a/upload/system/library/postfinancecheckout/helper.php +++ b/upload/system/library/postfinancecheckout/helper.php @@ -6,7 +6,7 @@ class PostFinanceCheckoutHelper { const FALLBACK_LANGUAGE = 'en-US'; /** * - * @var Wallee\Sdk\ApiClient + * @var PostFinanceCheckout\Sdk\ApiClient */ private $apiClient; /** @@ -152,7 +152,7 @@ public function hasRunningJobs(\PostFinanceCheckout\Entity\TransactionInfo $tran } public function isCompletionPossible(\PostFinanceCheckout\Entity\TransactionInfo $transaction_info){ - return $transaction_info->getState() == \Wallee\Sdk\Model\TransactionState::AUTHORIZED && + return $transaction_info->getState() == \PostFinanceCheckout\Sdk\Model\TransactionState::AUTHORIZED && (\PostFinanceCheckout\Entity\CompletionJob::countRunningForOrder($this->registry, $transaction_info->getOrderId()) == 0) && (\PostFinanceCheckout\Entity\VoidJob::countRunningForOrder($this->registry, $transaction_info->getOrderId()) == 0); } @@ -160,9 +160,9 @@ public function isCompletionPossible(\PostFinanceCheckout\Entity\TransactionInfo public function isRefundPossible(\PostFinanceCheckout\Entity\TransactionInfo $transaction_info){ if (!in_array($transaction_info->getState(), array( - \Wallee\Sdk\Model\TransactionState::COMPLETED, - \Wallee\Sdk\Model\TransactionState::FULFILL, - \Wallee\Sdk\Model\TransactionState::DECLINE + \PostFinanceCheckout\Sdk\Model\TransactionState::COMPLETED, + \PostFinanceCheckout\Sdk\Model\TransactionState::FULFILL, + \PostFinanceCheckout\Sdk\Model\TransactionState::DECLINE ))) { return false; } @@ -355,7 +355,7 @@ public function getCleanLanguageCode($language = null){ /** * - * @return Wallee\Sdk\ApiClient + * @return PostFinanceCheckout\Sdk\ApiClient */ public function getApiClient(){ if ($this->apiClient === null) { @@ -365,7 +365,7 @@ public function getApiClient(){ } public function refreshApiClient(){ - $this->apiClient = new Wallee\Sdk\ApiClient($this->registry->get('config')->get('postfinancecheckout_user_id'), + $this->apiClient = new PostFinanceCheckout\Sdk\ApiClient($this->registry->get('config')->get('postfinancecheckout_user_id'), $this->registry->get('config')->get('postfinancecheckout_application_key')); $this->apiClient->setBasePath(self::getBaseUrl() . "/api"); if ($this->registry->get('config')->get('wallee_log_level') >= self::LOG_DEBUG) { @@ -499,6 +499,28 @@ 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. + * + * @param int $page + * @return int + */ + 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. + * + * @param int $page + * @return int + */ + public function getLimitEnd($page) { + $limit = $this->registry->get('config')->get('config_limit_admin'); + return $page * $limit; + } public static function instance(Registry $registry){ if (self::$instance === null) { @@ -513,9 +535,9 @@ public static function getBaseUrl(){ public static function isEditableState($state){ $completable_states = array( - \Wallee\Sdk\Model\TransactionState::AUTHORIZED, - \Wallee\Sdk\Model\TransactionState::CONFIRMED, - \Wallee\Sdk\Model\TransactionState::PROCESSING + \PostFinanceCheckout\Sdk\Model\TransactionState::AUTHORIZED, + \PostFinanceCheckout\Sdk\Model\TransactionState::CONFIRMED, + \PostFinanceCheckout\Sdk\Model\TransactionState::PROCESSING ); return in_array($state, $completable_states); } diff --git a/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutAdministration.ocmod.xml b/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutAdministration.ocmod.xml new file mode 100644 index 0000000..9120b15 --- /dev/null +++ b/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutAdministration.ocmod.xml @@ -0,0 +1,72 @@ + + + PostFinanceCheckoutAdministration + postfinancecheckout administration: complete, refund and void from the OpenCart backend. + + 1.0.2 + Customweb GmbH + http://github.com/postfinancecheckout-payment/opencart + + + response->setOutput($this->load->view('sale/order_info.tpl', $data)); + ]]> + load->model('extension/postfinancecheckout/order'); + $data['postfinancecheckout_buttons'] = $this->model_extension_postfinancecheckout_order->getButtons((int)$this->request->get['order_id']); + $data['postfinancecheckout_failed_jobs'] = $this->model_extension_postfinancecheckout_order->getFailedJobs((int)$this->request->get['order_id']); + $data['postfinancecheckout_tab'] = $this->load->controller('payment/' . $order_info['payment_code'] . '/order'); + ]]> + + + + + +
    3. + ]]> + +
    4. + +]]>
      + + + + ]]> + +
      + +
      + +]]>
      +
      + + + ]]> + +]]> + + + + ]]> + '; +document.adminToken = ''; +setPostFinanceCheckoutButtons(); +var postfinancecheckout_failed_jobs = ; +window.setTimeout(function() { + for (var i = 0; i < postfinancecheckout_failed_jobs.length; i++) { + addPostFinanceCheckoutError(postfinancecheckout_failed_jobs[i]); + } +}, 500); +]]> + + + diff --git a/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutAlerts.ocmod.xml b/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutAlerts.ocmod.xml new file mode 100644 index 0000000..5b232ce --- /dev/null +++ b/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutAlerts.ocmod.xml @@ -0,0 +1,43 @@ + + + PostFinanceCheckoutAlerts + postfinancecheckout alerts: show open manual tasks and failed jobs. + 1.0.0 + Customweb GmbH + http://github.com/postfinancecheckout-payment/opencart + + + + load->model("extension/postfinancecheckout/alert"); + $data['postfinancecheckout_alerts_title'] = $this->model_extension_postfinancecheckout_alert->getAlertsTitle(); + $data['postfinancecheckout_alerts'] = $this->model_extension_postfinancecheckout_alert->getAlerts(); + $postfinancecheckout_alert_count = $this->model_extension_postfinancecheckout_alert->getAlertCount(); + ]]> + + + + + + + + + + ]]> + + + +
    5. + + ]]>
      +
      +
      +
      diff --git a/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutCore.ocmod.xml b/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutCore.ocmod.xml new file mode 100644 index 0000000..c35d810 --- /dev/null +++ b/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutCore.ocmod.xml @@ -0,0 +1,154 @@ + + + PostFinanceCheckoutCore + postfinancecheckout core: load payment methods. + + 1.0.1 + Customweb GmbH + http://github.com/postfinancecheckout-payment/opencart + + + session->data['error'])) { + ]]> + request->get['order_id']) && \PostFinanceCheckoutHelper::instance($this->registry)->isValidOrder($this->request->get['order_id']) + && \PostFinanceCheckout\Service\Transaction::instance($this->registry)->waitForStates($this->request->get['order_id'], array(\PostFinanceCheckout\Sdk\Model\TransactionState::FAILED), 5)) { + $transaction_info = \PostFinanceCheckout\Entity\TransactionInfo::loadByOrderId($this->registry, $this->request->get['order_id']); + $data['error_warning'] = $transaction_info->getFailureReason(); + } else + ]]> + + + + + model_extension_extension->uninstall('payment', $value); + ]]> + model_extension_extension->uninstall('payment', $value); + } + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + file) + ]]> + file)) + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutEvents.ocmod.xml b/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutEvents.ocmod.xml new file mode 100644 index 0000000..e3f5542 --- /dev/null +++ b/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutEvents.ocmod.xml @@ -0,0 +1,49 @@ + + + PostFinanceCheckoutEvents + postfinancecheckout events: handle events unavailable in Opencart 2.0.x and 2.1.x. + + 1.0.1 + Customweb GmbH + http://github.com/postfinancecheckout-payment/opencart + + + load->controller('common/cart'); + ]]> + load->controller('extension/postfinancecheckout/event/includeDeviceIdentifier'); + + \PostFinanceCheckoutHelper::instance($this->registry)->refreshWebhook(); + \PostFinanceCheckout\Entity\Cron::cleanUpHangingCrons($this->registry); + \PostFinanceCheckout\Entity\Cron::insertNewPendingCron($this->registry); + $postfinancecheckout_cron_token = \PostFinanceCheckout\Entity\Cron::getCurrentSecurityTokenForPendingCron($this->registry); + if($postfinancecheckout_cron_token) { + $data['postfinancecheckout_cron'] = \PostFinanceCheckoutVersionHelper::createUrl($this->url, 'extension/postfinancecheckout/cron', array('security_token' => $postfinancecheckout_cron_token), $this->config->get('config_secure')); + } + } catch (Exception $e) { \PostFinanceCheckoutHelper::instance($this->registry)->log($e->getMessage()); } + ]]> + + + + + + ]]> + + ]]> + + + + + + load->controller('extension/postfinancecheckout/event/createMethodConfigurationFiles'); + ]]> + + + diff --git a/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutFrontendPdf.ocmod.xml b/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutFrontendPdf.ocmod.xml new file mode 100644 index 0000000..9fa082b --- /dev/null +++ b/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutFrontendPdf.ocmod.xml @@ -0,0 +1,36 @@ + + + PostFinanceCheckoutFrontendPdf + postfinancecheckout customer pdf: Allow customers to download invoices and packing slips. + + 1.0.1 + Customweb GmbH + http://github.com/postfinancecheckout-payment/opencart + + + config->get('config_template') . '/template/account/order_info.tpl')) { + ]]> + load->model('extension/postfinancecheckout/order'); + $data['postfinancecheckout_buttons'] = $this->model_extension_postfinancecheckout_order->getButtons($order_info['order_id']); + ]]> + + + + + + ]]> + +
      + + + +
      + + ]]>
      +
      +
      +
      diff --git a/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutPreventConfirmationEmail.ocmod.xml b/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutPreventConfirmationEmail.ocmod.xml new file mode 100644 index 0000000..b2291ae --- /dev/null +++ b/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutPreventConfirmationEmail.ocmod.xml @@ -0,0 +1,18 @@ + + + PostFinanceCheckoutPreventConfirmationEmail + postfinancecheckout email: prevent confirmation email. + 1.0.1 + Customweb GmbH + http://github.com/postfinancecheckout-payment/opencart + + + + + + + diff --git a/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutQuickCheckoutCompatibility.ocmod.xml b/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutQuickCheckoutCompatibility.ocmod.xml new file mode 100644 index 0000000..0905b77 --- /dev/null +++ b/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutQuickCheckoutCompatibility.ocmod.xml @@ -0,0 +1,19 @@ + + + PostFinanceCheckoutQuickCheckoutCompatibility + postfinancecheckout compatibility: patch for Ajax Quick Checkout. + + 1.0.1 + Customweb GmbH + http://github.com/postfinancecheckout-payment/opencart + + + + + + + diff --git a/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutTransactionView.ocmod.xml b/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutTransactionView.ocmod.xml new file mode 100644 index 0000000..d95b2f9 --- /dev/null +++ b/upload/system/library/postfinancecheckout/modification/PostFinanceCheckoutTransactionView.ocmod.xml @@ -0,0 +1,25 @@ + + + PostFinanceCheckoutTransactionView + postfinancecheckout transaction view: List transactions in the opencart backend. + + 1.0.0 + Customweb GmbH + http://github.com/postfinancecheckout-payment/opencart + + + user->hasPermission('access', 'sale/recurring')) {]]> + user->hasPermission('access', 'extension/postfinancecheckout/transaction')) { + $this->language->load('extension/postfinancecheckout'); + $sale[] = array( + 'name' => $this->language->get('heading_transaction_list'), + 'href' => $this->url->link('extension/postfinancecheckout/transaction', 'token=' . $this->session->data['token'], true), + 'children' => array() + ); + $this->load->language('common/column_left'); + } + ]]> + + + diff --git a/upload/system/library/postfinancecheckout/modification/WalleeCore.ocmod.xml b/upload/system/library/postfinancecheckout/modification/WalleeCore.ocmod.xml index ec0db72..ed77e61 100644 --- a/upload/system/library/postfinancecheckout/modification/WalleeCore.ocmod.xml +++ b/upload/system/library/postfinancecheckout/modification/WalleeCore.ocmod.xml @@ -3,7 +3,7 @@ PostFinanceCheckoutCore postfinancecheckout core: load payment methods. - 1.0.0 + 1.0.1 Customweb GmbH http://github.com/postfinancecheckout-payment/opencart @@ -12,12 +12,11 @@ if (isset($this->session->data['error'])) { ]]> request->get['order_id'])) { - require_once modification(DIR_SYSTEM . 'library/postfinancecheckout/helper.php'); + require_once modification(DIR_SYSTEM . 'library/postfinancecheckout/helper.php'); + if (isset($this->request->get['order_id']) && \PostFinanceCheckoutHelper::instance($this->registry)->isValidOrder($this->request->get['order_id']) + && \PostFinanceCheckout\Service\Transaction::instance($this->registry)->waitForStates($this->request->get['order_id'], array(\PostFinanceCheckout\Sdk\Model\TransactionState::FAILED), 5)) { $transaction_info = \PostFinanceCheckout\Entity\TransactionInfo::loadByOrderId($this->registry, $this->request->get['order_id']); - if ($transaction_info->getId() != null) { - $data['error_warning'] = $transaction_info->getFailureReason(); - } + $data['error_warning'] = $transaction_info->getFailureReason(); } else ]]> @@ -62,6 +61,14 @@ ]]> + + + + diff --git a/upload/system/library/postfinancecheckout/provider/currency.php b/upload/system/library/postfinancecheckout/provider/currency.php index 40f814c..ecf838e 100644 --- a/upload/system/library/postfinancecheckout/provider/currency.php +++ b/upload/system/library/postfinancecheckout/provider/currency.php @@ -15,7 +15,7 @@ protected function __construct(\Registry $registry){ * Returns the currency by the given code. * * @param string $code - * @return \Wallee\Sdk\Model\RestCurrency + * @return \PostFinanceCheckout\Sdk\Model\RestCurrency */ public function find($code){ return parent::find($code); @@ -24,19 +24,19 @@ public function find($code){ /** * Returns a list of currencies. * - * @return \Wallee\Sdk\Model\RestCurrency[] + * @return \PostFinanceCheckout\Sdk\Model\RestCurrency[] */ public function getAll(){ return parent::getAll(); } protected function fetchData(){ - $currency_service = new \Wallee\Sdk\Service\CurrencyService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); + $currency_service = new \PostFinanceCheckout\Sdk\Service\CurrencyService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); return $currency_service->all(); } protected function getId($entry){ - /* @var \Wallee\Sdk\Model\RestCurrency $entry */ + /* @var \PostFinanceCheckout\Sdk\Model\RestCurrency $entry */ return $entry->getCurrencyCode(); } } \ No newline at end of file diff --git a/upload/system/library/postfinancecheckout/provider/label_description_group.php b/upload/system/library/postfinancecheckout/provider/label_description_group.php index 1e68191..3cd5831 100644 --- a/upload/system/library/postfinancecheckout/provider/label_description_group.php +++ b/upload/system/library/postfinancecheckout/provider/label_description_group.php @@ -15,7 +15,7 @@ protected function __construct(\Registry $registry){ * Returns the label descriptor group by the given code. * * @param int $id - * @return \Wallee\Sdk\Model\LabelDescriptorGroup + * @return \PostFinanceCheckout\Sdk\Model\LabelDescriptorGroup */ public function find($id){ return parent::find($id); @@ -24,20 +24,20 @@ public function find($id){ /** * Returns a list of label descriptor groups. * - * @return \Wallee\Sdk\Model\LabelDescriptorGroup[] + * @return \PostFinanceCheckout\Sdk\Model\LabelDescriptorGroup[] */ public function getAll(){ return parent::getAll(); } protected function fetchData(){ - $label_descriptor_group_service = new \Wallee\Sdk\Service\LabelDescriptionGroupService( + $label_descriptor_group_service = new \PostFinanceCheckout\Sdk\Service\LabelDescriptionGroupService( \PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); return $label_descriptor_group_service->all(); } protected function getId($entry){ - /* @var \Wallee\Sdk\Model\LabelDescriptorGroup $entry */ + /* @var \PostFinanceCheckout\Sdk\Model\LabelDescriptorGroup $entry */ return $entry->getId(); } } \ No newline at end of file diff --git a/upload/system/library/postfinancecheckout/provider/label_descriptor.php b/upload/system/library/postfinancecheckout/provider/label_descriptor.php index 0708247..3cb0538 100644 --- a/upload/system/library/postfinancecheckout/provider/label_descriptor.php +++ b/upload/system/library/postfinancecheckout/provider/label_descriptor.php @@ -15,7 +15,7 @@ protected function __construct(\Registry $registry){ * Returns the label descriptor by the given code. * * @param int $id - * @return \Wallee\Sdk\Model\LabelDescriptor + * @return \PostFinanceCheckout\Sdk\Model\LabelDescriptor */ public function find($id){ return parent::find($id); @@ -24,19 +24,19 @@ public function find($id){ /** * Returns a list of label descriptors. * - * @return \Wallee\Sdk\Model\LabelDescriptor[] + * @return \PostFinanceCheckout\Sdk\Model\LabelDescriptor[] */ public function getAll(){ return parent::getAll(); } protected function fetchData(){ - $label_descriptor_service = new \Wallee\Sdk\Service\LabelDescriptionService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); + $label_descriptor_service = new \PostFinanceCheckout\Sdk\Service\LabelDescriptionService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); return $label_descriptor_service->all(); } protected function getId($entry){ - /* @var \Wallee\Sdk\Model\LabelDescriptor $entry */ + /* @var \PostFinanceCheckout\Sdk\Model\LabelDescriptor $entry */ return $entry->getId(); } } \ No newline at end of file diff --git a/upload/system/library/postfinancecheckout/provider/language.php b/upload/system/library/postfinancecheckout/provider/language.php index 162a6b8..fe70250 100644 --- a/upload/system/library/postfinancecheckout/provider/language.php +++ b/upload/system/library/postfinancecheckout/provider/language.php @@ -15,7 +15,7 @@ protected function __construct(\Registry $registry){ * Returns the language by the given code. * * @param string $code - * @return \Wallee\Sdk\Model\RestLanguage + * @return \PostFinanceCheckout\Sdk\Model\RestLanguage */ public function find($code){ return parent::find($code); @@ -25,7 +25,7 @@ public function find($code){ * Returns the primary language in the given group. * * @param string $code - * @return \Wallee\Sdk\Model\RestLanguage + * @return \PostFinanceCheckout\Sdk\Model\RestLanguage */ public function findPrimary($code){ $code = substr($code, 0, 2); @@ -50,19 +50,19 @@ public function findByIsoCode($iso){ /** * Returns a list of language. * - * @return \Wallee\Sdk\Model\RestLanguage[] + * @return \PostFinanceCheckout\Sdk\Model\RestLanguage[] */ public function getAll(){ return parent::getAll(); } protected function fetchData(){ - $language_service = new \Wallee\Sdk\Service\LanguageService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); + $language_service = new \PostFinanceCheckout\Sdk\Service\LanguageService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); return $language_service->all(); } protected function getId($entry){ - /* @var \Wallee\Sdk\Model\RestLanguage $entry */ + /* @var \PostFinanceCheckout\Sdk\Model\RestLanguage $entry */ return $entry->getIetfCode(); } } \ No newline at end of file diff --git a/upload/system/library/postfinancecheckout/provider/payment_connector.php b/upload/system/library/postfinancecheckout/provider/payment_connector.php index af38daa..818fe67 100644 --- a/upload/system/library/postfinancecheckout/provider/payment_connector.php +++ b/upload/system/library/postfinancecheckout/provider/payment_connector.php @@ -15,7 +15,7 @@ protected function __construct(\Registry $registry){ * Returns the payment connector by the given id. * * @param int $id - * @return \Wallee\Sdk\Model\PaymentConnector + * @return \PostFinanceCheckout\Sdk\Model\PaymentConnector */ public function find($id){ return parent::find($id); @@ -24,19 +24,19 @@ public function find($id){ /** * Returns a list of payment connectors. * - * @return \Wallee\Sdk\Model\PaymentConnector[] + * @return \PostFinanceCheckout\Sdk\Model\PaymentConnector[] */ public function getAll(){ return parent::getAll(); } protected function fetchData(){ - $connector_service = new \Wallee\Sdk\Service\PaymentConnectorService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); + $connector_service = new \PostFinanceCheckout\Sdk\Service\PaymentConnectorService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); return $connector_service->all(); } protected function getId($entry){ - /* @var \Wallee\Sdk\Model\PaymentConnector $entry */ + /* @var \PostFinanceCheckout\Sdk\Model\PaymentConnector $entry */ return $entry->getId(); } } \ No newline at end of file diff --git a/upload/system/library/postfinancecheckout/provider/payment_method.php b/upload/system/library/postfinancecheckout/provider/payment_method.php index 56a5171..155dcc1 100644 --- a/upload/system/library/postfinancecheckout/provider/payment_method.php +++ b/upload/system/library/postfinancecheckout/provider/payment_method.php @@ -15,7 +15,7 @@ protected function __construct(\Registry $registry){ * Returns the payment method by the given id. * * @param int $id - * @return \Wallee\Sdk\Model\PaymentMethod + * @return \PostFinanceCheckout\Sdk\Model\PaymentMethod */ public function find($id){ return parent::find($id); @@ -24,19 +24,19 @@ public function find($id){ /** * Returns a list of payment methods. * - * @return \Wallee\Sdk\Model\PaymentMethod[] + * @return \PostFinanceCheckout\Sdk\Model\PaymentMethod[] */ public function getAll(){ return parent::getAll(); } protected function fetchData(){ - $method_service = new \Wallee\Sdk\Service\PaymentMethodService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); + $method_service = new \PostFinanceCheckout\Sdk\Service\PaymentMethodService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); return $method_service->all(); } protected function getId($entry){ - /* @var \Wallee\Sdk\Model\PaymentMethod $entry */ + /* @var \PostFinanceCheckout\Sdk\Model\PaymentMethod $entry */ return $entry->getId(); } } \ No newline at end of file diff --git a/upload/system/library/postfinancecheckout/service/abstract_job.php b/upload/system/library/postfinancecheckout/service/abstract_job.php index 3f83c53..f69034c 100644 --- a/upload/system/library/postfinancecheckout/service/abstract_job.php +++ b/upload/system/library/postfinancecheckout/service/abstract_job.php @@ -12,11 +12,11 @@ abstract class AbstractJob extends AbstractService { * Expects a database transaction to be running, and will commit / rollback depending on outcome. * * @param \PostFinanceCheckout\Entity\AbstractJob $job - * @param \Wallee\Sdk\ApiException $api_exception + * @param \PostFinanceCheckout\Sdk\ApiException $api_exception * @throws \Exception * @return \PostFinanceCheckout\Service\AbstractJob */ - protected function handleApiException(\PostFinanceCheckout\Entity\AbstractJob $job, \Wallee\Sdk\ApiException $api_exception){ + protected function handleApiException(\PostFinanceCheckout\Entity\AbstractJob $job, \PostFinanceCheckout\Sdk\ApiException $api_exception){ try { $job->setState(\PostFinanceCheckout\Entity\AbstractJob::STATE_FAILED_CHECK); $job->setFailureReason([ diff --git a/upload/system/library/postfinancecheckout/service/abstract_service.php b/upload/system/library/postfinancecheckout/service/abstract_service.php index 51c817c..fddbf34 100644 --- a/upload/system/library/postfinancecheckout/service/abstract_service.php +++ b/upload/system/library/postfinancecheckout/service/abstract_service.php @@ -30,11 +30,11 @@ public static function instance(\Registry $registry){ * @param string $field_name * @param mixed $value * @param string $operator - * @return \Wallee\Sdk\Model\EntityQueryFilter + * @return \PostFinanceCheckout\Sdk\Model\EntityQueryFilter */ - protected function createEntityFilter($field_name, $value, $operator = \Wallee\Sdk\Model\CriteriaOperator::EQUALS){ - $filter = new \Wallee\Sdk\Model\EntityQueryFilter(); - $filter->setType(\Wallee\Sdk\Model\EntityQueryFilterType::LEAF); + protected function createEntityFilter($field_name, $value, $operator = \PostFinanceCheckout\Sdk\Model\CriteriaOperator::EQUALS){ + $filter = new \PostFinanceCheckout\Sdk\Model\EntityQueryFilter(); + $filter->setType(\PostFinanceCheckout\Sdk\Model\EntityQueryFilterType::LEAF); $filter->setOperator($operator); $filter->setFieldName($field_name); $filter->setValue($value); @@ -46,10 +46,10 @@ protected function createEntityFilter($field_name, $value, $operator = \Wallee\S * * @param string $field_name * @param string $sort_order - * @return \Wallee\Sdk\Model\EntityQueryOrderBy + * @return \PostFinanceCheckout\Sdk\Model\EntityQueryOrderBy */ - protected function createEntityOrderBy($field_name, $sort_order = \Wallee\Sdk\Model\EntityQueryOrderByType::DESC){ - $order_by = new \Wallee\Sdk\Model\EntityQueryOrderBy(); + protected function createEntityOrderBy($field_name, $sort_order = \PostFinanceCheckout\Sdk\Model\EntityQueryOrderByType::DESC){ + $order_by = new \PostFinanceCheckout\Sdk\Model\EntityQueryOrderBy(); $order_by->setFieldName($field_name); $order_by->setSorting($sort_order); return $order_by; diff --git a/upload/system/library/postfinancecheckout/service/completion.php b/upload/system/library/postfinancecheckout/service/completion.php index 9f6f3f3..710d797 100644 --- a/upload/system/library/postfinancecheckout/service/completion.php +++ b/upload/system/library/postfinancecheckout/service/completion.php @@ -33,7 +33,7 @@ public function send(\PostFinanceCheckout\Entity\CompletionJob $job){ \PostFinanceCheckoutHelper::instance($this->registry)->dbTransactionStart(); \PostFinanceCheckoutHelper::instance($this->registry)->dbTransactionLock($job->getSpaceId(), $job->getTransactionId()); - $service = new \Wallee\Sdk\Service\TransactionCompletionService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); + $service = new \PostFinanceCheckout\Sdk\Service\TransactionCompletionService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); $operation = $service->completeOnline($job->getSpaceId(), $job->getTransactionId()); if ($operation->getFailureReason() != null) { @@ -53,7 +53,7 @@ public function send(\PostFinanceCheckout\Entity\CompletionJob $job){ \PostFinanceCheckoutHelper::instance($this->registry)->dbTransactionCommit(); return $job; } - catch (\Wallee\Sdk\ApiException $api_exception) { + catch (\PostFinanceCheckout\Sdk\ApiException $api_exception) { return $this->handleApiException($job, $api_exception); } catch (\Exception $e) { diff --git a/upload/system/library/postfinancecheckout/service/line_item.php b/upload/system/library/postfinancecheckout/service/line_item.php index b74fad9..f2b8ad9 100644 --- a/upload/system/library/postfinancecheckout/service/line_item.php +++ b/upload/system/library/postfinancecheckout/service/line_item.php @@ -2,9 +2,9 @@ namespace PostFinanceCheckout\Service; -use Wallee\Sdk\Model\LineItemCreate; -use Wallee\Sdk\Model\LineItemType; -use Wallee\Sdk\Model\TaxCreate; +use PostFinanceCheckout\Sdk\Model\LineItemCreate; +use PostFinanceCheckout\Sdk\Model\LineItemType; +use PostFinanceCheckout\Sdk\Model\TaxCreate; /** * This service provides methods to handle manual tasks. @@ -24,10 +24,10 @@ public static function instance(\Registry $registry){ } public function getTotalLineItem($total){ - $line_item = new \Wallee\Sdk\Model\LineItemCreate(); + $line_item = new \PostFinanceCheckout\Sdk\Model\LineItemCreate(); $line_item->setAmountIncludingTax($total); $line_item->setQuantity(1); - $line_item->setType(\Wallee\Sdk\Model\LineItemType::PRODUCT); + $line_item->setType(\PostFinanceCheckout\Sdk\Model\LineItemType::PRODUCT); $line_item->setName('temp'); $line_item->setUniqueId('temp'); return $line_item; @@ -39,7 +39,7 @@ public function getTotalLineItem($total){ * @param array $order_info * @param int $transaction_id * @param int $space_id - * @return \Wallee\Sdk\Model\LineItemCreate[] + * @return \PostFinanceCheckout\Sdk\Model\LineItemCreate[] */ public function getReducedItemsFromOrder(array $order_info, $transaction_id, $space_id){ $this->tax = \PostFinanceCheckoutVersionHelper::newTax($this->registry); @@ -300,11 +300,11 @@ private function createXFeeLineItem($total){ if($total['value'] < 0){ $line_item->setType(LineItemType::DISCOUNT); } - $line_item->setAmountIncludingTax(\WalleeHelper::instance($this->registry)->formatAmount($total['value'])); + $line_item->setAmountIncludingTax(\PostFinanceCheckoutHelper::instance($this->registry)->formatAmount($total['value'])); $fee_id = substr($total['code'], 4); if ($config->get ( 'xfee_tax_class_id' . $fee_id )) { $tax_amount = $this->addTaxesToLineItem($line_item, $total['value'], $config->get( 'xfee_tax_class_id' . $fee_id )); - $line_item->setAmountIncludingTax(\WalleeHelper::instance($this->registry)->formatAmount($total['value'] + $tax_amount)); + $line_item->setAmountIncludingTax(\PostFinanceCheckoutHelper::instance($this->registry)->formatAmount($total['value'] + $tax_amount)); } return $this->cleanLineItem($line_item); } @@ -560,8 +560,8 @@ private function getTotalCouponHistoriesByCustomerId($coupon, $customer_id){ /** * Cleans the given line item for it to meet the API's requirements. * - * @param \Wallee\Sdk\Model\LineItemCreate $lineItem - * @return \Wallee\Sdk\Model\LineItemCreate + * @param \PostFinanceCheckout\Sdk\Model\LineItemCreate $lineItem + * @return \PostFinanceCheckout\Sdk\Model\LineItemCreate */ private function cleanLineItem(LineItemCreate $line_item){ $line_item->setSku($this->fixLength($line_item->getSku(), 200)); diff --git a/upload/system/library/postfinancecheckout/service/manual_task.php b/upload/system/library/postfinancecheckout/service/manual_task.php index f294b11..71965f3 100644 --- a/upload/system/library/postfinancecheckout/service/manual_task.php +++ b/upload/system/library/postfinancecheckout/service/manual_task.php @@ -25,12 +25,12 @@ public function getNumberOfManualTasks(){ */ public function update(){ $number_of_manual_tasks = 0; - $manual_task_service = new \Wallee\Sdk\Service\ManualTaskService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); + $manual_task_service = new \PostFinanceCheckout\Sdk\Service\ManualTaskService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); $space_id = $this->registry->get('config')->get('postfinancecheckout_space_id'); if (!empty($space_id)) { $number_of_manual_tasks = $manual_task_service->count($space_id, - $this->createEntityFilter('state', \Wallee\Sdk\Model\ManualTaskState::OPEN)); + $this->createEntityFilter('state', \PostFinanceCheckout\Sdk\Model\ManualTaskState::OPEN)); $table = DB_PREFIX . 'setting'; $key = self::CONFIG_KEY; diff --git a/upload/system/library/postfinancecheckout/service/method_configuration.php b/upload/system/library/postfinancecheckout/service/method_configuration.php index d20c7f1..0c46e53 100644 --- a/upload/system/library/postfinancecheckout/service/method_configuration.php +++ b/upload/system/library/postfinancecheckout/service/method_configuration.php @@ -7,9 +7,9 @@ class MethodConfiguration extends AbstractService { /** * Updates the data of the payment method configuration. * - * @param \Wallee\Sdk\Model\PaymentMethodConfiguration $configuration + * @param \PostFinanceCheckout\Sdk\Model\PaymentMethodConfiguration $configuration */ - public function updateData(\Wallee\Sdk\Model\PaymentMethodConfiguration $configuration){ + public function updateData(\PostFinanceCheckout\Sdk\Model\PaymentMethodConfiguration $configuration){ /* @var \PostFinanceCheckout\Entity\MethodConfiguration $entity */ $entity = \PostFinanceCheckout\Entity\MethodConfiguration::loadByConfiguration($this->registry, $configuration->getLinkedSpaceId(), $configuration->getId()); if ($entity->getId() !== null && $this->hasChanged($configuration, $entity)) { @@ -22,7 +22,7 @@ public function updateData(\Wallee\Sdk\Model\PaymentMethodConfiguration $configu } } - private function hasChanged(\Wallee\Sdk\Model\PaymentMethodConfiguration $configuration, \PostFinanceCheckout\Entity\MethodConfiguration $entity){ + private function hasChanged(\PostFinanceCheckout\Sdk\Model\PaymentMethodConfiguration $configuration, \PostFinanceCheckout\Entity\MethodConfiguration $entity){ if ($configuration->getName() != $entity->getConfigurationName()) { return true; } @@ -53,9 +53,9 @@ public function synchronize($space_id){ $existing_found = array(); $existing_configurations = \PostFinanceCheckout\Entity\MethodConfiguration::loadBySpaceId($this->registry, $space_id); - $payment_method_configuration_service = new \Wallee\Sdk\Service\PaymentMethodConfigurationService( + $payment_method_configuration_service = new \PostFinanceCheckout\Sdk\Service\PaymentMethodConfigurationService( \PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); - $configurations = $payment_method_configuration_service->search($space_id, new \Wallee\Sdk\Model\EntityQuery()); + $configurations = $payment_method_configuration_service->search($space_id, new \PostFinanceCheckout\Sdk\Model\EntityQuery()); foreach ($configurations as $configuration) { $method = \PostFinanceCheckout\Entity\MethodConfiguration::loadByConfiguration($this->registry, $space_id, $configuration->getId()); @@ -88,7 +88,7 @@ public function synchronize($space_id){ * Returns the payment method for the given id. * * @param int $id - * @return \Wallee\Sdk\Model\PaymentMethod + * @return \PostFinanceCheckout\Sdk\Model\PaymentMethod */ protected function getPaymentMethod($id){ return \PostFinanceCheckout\Provider\PaymentMethod::instance($this->registry)->find($id); @@ -97,14 +97,14 @@ protected function getPaymentMethod($id){ /** * Returns the state for the payment method configuration. * - * @param \Wallee\Sdk\Model\PaymentMethodConfiguration $configuration + * @param \PostFinanceCheckout\Sdk\Model\PaymentMethodConfiguration $configuration * @return string */ - protected function getConfigurationState(\Wallee\Sdk\Model\PaymentMethodConfiguration $configuration){ + protected function getConfigurationState(\PostFinanceCheckout\Sdk\Model\PaymentMethodConfiguration $configuration){ switch ($configuration->getState()) { - case \Wallee\Sdk\Model\CreationEntityState::ACTIVE: + case \PostFinanceCheckout\Sdk\Model\CreationEntityState::ACTIVE: return \PostFinanceCheckout\Entity\MethodConfiguration::STATE_ACTIVE; - case \Wallee\Sdk\Model\CreationEntityState::INACTIVE: + case \PostFinanceCheckout\Sdk\Model\CreationEntityState::INACTIVE: return \PostFinanceCheckout\Entity\MethodConfiguration::STATE_INACTIVE; default: return \PostFinanceCheckout\Entity\MethodConfiguration::STATE_HIDDEN; diff --git a/upload/system/library/postfinancecheckout/service/refund.php b/upload/system/library/postfinancecheckout/service/refund.php index e0a2d5d..37013db 100644 --- a/upload/system/library/postfinancecheckout/service/refund.php +++ b/upload/system/library/postfinancecheckout/service/refund.php @@ -46,7 +46,7 @@ public function send(\PostFinanceCheckout\Entity\RefundJob $job){ \PostFinanceCheckoutHelper::instance($this->registry)->dbTransactionStart(); \PostFinanceCheckoutHelper::instance($this->registry)->dbTransactionLock($job->getSpaceId(), $job->getTransactionId()); - $service = new \Wallee\Sdk\Service\RefundService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); + $service = new \PostFinanceCheckout\Sdk\Service\RefundService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); $operation = $service->refund($job->getSpaceId(), $this->createRefund($job)); if ($operation->getFailureReason() != null) { @@ -67,7 +67,7 @@ public function send(\PostFinanceCheckout\Entity\RefundJob $job){ \PostFinanceCheckoutHelper::instance($this->registry)->dbTransactionCommit(); return $job; } - catch (\Wallee\Sdk\ApiException $api_exception) { + catch (\PostFinanceCheckout\Sdk\ApiException $api_exception) { } catch (\Exception $e) { \PostFinanceCheckoutHelper::instance($this->registry)->dbTransactionRollback(); @@ -78,11 +78,11 @@ public function send(\PostFinanceCheckout\Entity\RefundJob $job){ } private function createRefund(\PostFinanceCheckout\Entity\RefundJob $job){ - $refund_create = new \Wallee\Sdk\Model\RefundCreate(); + $refund_create = new \PostFinanceCheckout\Sdk\Model\RefundCreate(); $refund_create->setReductions($job->getReductionItems()); $refund_create->setExternalId($job->getExternalId()); $refund_create->setTransaction($job->getTransactionId()); - $refund_create->setType(\Wallee\Sdk\Model\RefundType::MERCHANT_INITIATED_ONLINE); + $refund_create->setType(\PostFinanceCheckout\Sdk\Model\RefundType::MERCHANT_INITIATED_ONLINE); return $refund_create; } @@ -90,7 +90,7 @@ private function getLineItemReductions(array $reductions){ $reduction_line_items = array(); foreach ($reductions as $reduction) { if ($reduction['quantity'] || $reduction['unit_price']) { - $line_item = new \Wallee\Sdk\Model\LineItemReductionCreate(); + $line_item = new \PostFinanceCheckout\Sdk\Model\LineItemReductionCreate(); $line_item->setLineItemUniqueId($reduction['id']); $line_item->setQuantityReduction(floatval($reduction['quantity'])); $line_item->setUnitPriceReduction(floatval($reduction['unit_price'])); diff --git a/upload/system/library/postfinancecheckout/service/token.php b/upload/system/library/postfinancecheckout/service/token.php index 38173b5..7f46943 100644 --- a/upload/system/library/postfinancecheckout/service/token.php +++ b/upload/system/library/postfinancecheckout/service/token.php @@ -10,14 +10,14 @@ class Token extends AbstractService { /** * The token API service. * - * @var \Wallee\Sdk\Service\TokenService + * @var \PostFinanceCheckout\Sdk\Service\TokenService */ private $token_service; /** * The token version API service. * - * @var \Wallee\Sdk\Service\TokenVersionService + * @var \PostFinanceCheckout\Sdk\Service\TokenVersionService */ private $token_version_service; @@ -27,13 +27,13 @@ public function updateTokenVersion($space_id, $token_version_id){ } public function updateToken($space_id, $token_id){ - $query = new \Wallee\Sdk\Model\EntityQuery(); - $filter = new \Wallee\Sdk\Model\EntityQueryFilter(); - $filter->setType(\Wallee\Sdk\Model\EntityQueryFilterType::_AND); + $query = new \PostFinanceCheckout\Sdk\Model\EntityQuery(); + $filter = new \PostFinanceCheckout\Sdk\Model\EntityQueryFilter(); + $filter->setType(\PostFinanceCheckout\Sdk\Model\EntityQueryFilterType::_AND); $filter->setChildren( array( $this->createEntityFilter('token.id', $token_id), - $this->createEntityFilter('state', \Wallee\Sdk\Model\TokenVersionState::ACTIVE) + $this->createEntityFilter('state', \PostFinanceCheckout\Sdk\Model\TokenVersionState::ACTIVE) )); $query->setFilter($filter); $query->setNumberOfEntities(1); @@ -49,12 +49,12 @@ public function updateToken($space_id, $token_id){ } } - protected function updateInfo($space_id, \Wallee\Sdk\Model\TokenVersion $token_version){ + protected function updateInfo($space_id, \PostFinanceCheckout\Sdk\Model\TokenVersion $token_version){ $info = \PostFinanceCheckout\Entity\TokenInfo::loadByToken($this->registry, $space_id, $token_version->getToken()->getId()); if (!in_array($token_version->getToken()->getState(), array( - \Wallee\Sdk\Model\TokenVersionState::ACTIVE, - \Wallee\Sdk\Model\TokenVersionState::UNINITIALIZED + \PostFinanceCheckout\Sdk\Model\TokenVersionState::ACTIVE, + \PostFinanceCheckout\Sdk\Model\TokenVersionState::UNINITIALIZED ))) { if ($info->getId()) { $info->delete(); @@ -85,11 +85,11 @@ public function deleteToken($space_id, $token_id){ /** * Returns the token API service. * - * @return \Wallee\Sdk\Service\TokenService + * @return \PostFinanceCheckout\Sdk\Service\TokenService */ protected function getTokenService(){ if ($this->token_service == null) { - $this->token_service = new \Wallee\Sdk\Service\TokenService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); + $this->token_service = new \PostFinanceCheckout\Sdk\Service\TokenService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); } return $this->token_service; @@ -98,11 +98,11 @@ protected function getTokenService(){ /** * Returns the token version API service. * - * @return \Wallee\Sdk\Service\TokenVersionService + * @return \PostFinanceCheckout\Sdk\Service\TokenVersionService */ protected function getTokenVersionService(){ if ($this->token_version_service == null) { - $this->token_version_service = new \Wallee\Sdk\Service\TokenVersionService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); + $this->token_version_service = new \PostFinanceCheckout\Sdk\Service\TokenVersionService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); } return $this->token_version_service; diff --git a/upload/system/library/postfinancecheckout/service/transaction.php b/upload/system/library/postfinancecheckout/service/transaction.php index 9bd2399..c53025a 100644 --- a/upload/system/library/postfinancecheckout/service/transaction.php +++ b/upload/system/library/postfinancecheckout/service/transaction.php @@ -2,9 +2,9 @@ namespace PostFinanceCheckout\Service; -use Wallee\Sdk\Service\ChargeAttemptService; -use Wallee\Sdk\Service\TransactionService; -use Wallee\Sdk\Model\TransactionPending; +use PostFinanceCheckout\Sdk\Service\ChargeAttemptService; +use PostFinanceCheckout\Sdk\Service\TransactionService; +use PostFinanceCheckout\Sdk\Model\TransactionPending; /** * This service provides functions to deal with PostFinanceCheckout transactions. @@ -20,14 +20,14 @@ public function getPaymentMethods(array $order_info){ $cart_id = \PostFinanceCheckoutVersionHelper::getCurrentCartId($this->registry); if (!$cart_id || !array_key_exists($cart_id, self::$possible_payment_method_cache)) { $transaction = $this->update($order_info, false); - try{ + try { $payment_methods = $this->getTransactionService()->fetchPossiblePaymentMethods($transaction->getLinkedSpaceId(), $transaction->getId()); foreach ($payment_methods as $payment_method) { MethodConfiguration::instance($this->registry)->updateData($payment_method); } self::$possible_payment_method_cache[$cart_id] = $payment_methods; } - catch(\Exception $e) { + catch (\Exception $e) { self::$possible_payment_method_cache[$cart_id] = array(); throw $e; } @@ -37,12 +37,12 @@ public function getPaymentMethods(array $order_info){ public function getJavascriptUrl(){ $transaction = $this->getTransaction(array(), false, array( - \Wallee\Sdk\Model\TransactionState::PENDING + \PostFinanceCheckout\Sdk\Model\TransactionState::PENDING )); return $this->getTransactionService()->buildJavaScriptUrl($transaction->getLinkedSpaceId(), $transaction->getId()); } - public function getPaymentPageUrl(\Wallee\Sdk\Model\Transaction $transaction, $paymentCode){ + public function getPaymentPageUrl(\PostFinanceCheckout\Sdk\Model\Transaction $transaction, $paymentCode){ $paymentMethodId = substr($paymentCode, strlen('postfinancecheckout_')); return $this->getTransactionService()->buildPaymentPageUrl($transaction->getLinkedSpaceId(), $transaction->getId()) . '&paymentMethodConfigurationId=' . $paymentMethodId; @@ -53,14 +53,14 @@ public function update(array $order_info, $confirm = false){ try { for ($i = 0; $i < 5; $i++) { $transaction = $this->getTransaction($order_info, false); - if ($transaction->getState() !== \Wallee\Sdk\Model\TransactionState::PENDING) { + if ($transaction->getState() !== \PostFinanceCheckout\Sdk\Model\TransactionState::PENDING) { if ($confirm) { throw new \Exception('No pending transaction available to be confirmed.'); } return $this->create($order_info); } - $pending_transaction = new \Wallee\Sdk\Model\TransactionPending(); + $pending_transaction = new \PostFinanceCheckout\Sdk\Model\TransactionPending(); $pending_transaction->setId($transaction->getId()); $pending_transaction->setVersion($transaction->getVersion()); $this->assembleTransaction($pending_transaction, $order_info); @@ -78,7 +78,7 @@ public function update(array $order_info, $confirm = false){ return $transaction; } } - catch (\Wallee\Sdk\ApiException $e) { + catch (\PostFinanceCheckout\Sdk\ApiException $e) { $last = $e; if ($e->getCode() != 409) { throw $e; @@ -88,11 +88,34 @@ public function update(array $order_info, $confirm = false){ throw $last; } + /** + * Wait for the order to reach a given state. + * + * @param $order_id + * @param array $states + * @param int $maxWaitTime + * @return boolean + */ + public function waitForStates($order_id, array $states, $maxWaitTime = 10){ + $startTime = microtime(true); + while (true) { + $transactionInfo = \PostFinanceCheckout\Entity\TransactionInfo::loadByOrderId($this->registry, $order_id); + if (in_array($transactionInfo->getState(), $states)) { + return true; + } + + if (microtime(true) - $startTime >= $maxWaitTime) { + return false; + } + sleep(1); + } + } + /** * Reads or creates a new transaction. * * @param array $order_info - * @return \Wallee\Sdk\Model\Transaction + * @return \PostFinanceCheckout\Sdk\Model\Transaction */ public function getTransaction($order_info = array(), $cache = true, $allowed_states = array()){ $cart_id = \PostFinanceCheckoutVersionHelper::getCurrentCartId($this->registry); @@ -142,9 +165,9 @@ private function persist($transaction, array $order_info){ } private function create(array $order_info){ - $create_transaction = new \Wallee\Sdk\Model\TransactionCreate(); + $create_transaction = new \PostFinanceCheckout\Sdk\Model\TransactionCreate(); - $create_transaction->setCustomersPresence(\Wallee\Sdk\Model\CustomersPresence::VIRTUAL_PRESENT); + $create_transaction->setCustomersPresence(\PostFinanceCheckout\Sdk\Model\CustomersPresence::VIRTUAL_PRESENT); if (isset($this->registry->get('request')->cookie['postfinancecheckout_device_id'])) { $create_transaction->setDeviceSessionIdentifier($this->registry->get('request')->cookie['postfinancecheckout_device_id']); } @@ -159,7 +182,7 @@ private function create(array $order_info){ return $transaction; } - private function assembleTransaction(\Wallee\Sdk\Model\AbstractTransactionPending $transaction, array $order_info){ + private function assembleTransaction(\PostFinanceCheckout\Sdk\Model\AbstractTransactionPending $transaction, array $order_info){ $order_id = isset($order_info['order_id']) ? $order_info['order_id'] : null; $data = $this->registry->get('session')->data; @@ -200,35 +223,35 @@ private function assembleTransaction(\Wallee\Sdk\Model\AbstractTransactionPendin /** * Cache for cart transactions. * - * @var \Wallee\Sdk\Model\Transaction[] + * @var \PostFinanceCheckout\Sdk\Model\Transaction[] */ private static $transaction_cache = array(); /** * Cache for possible payment methods by cart. * - * @var \Wallee\Sdk\Model\PaymentMethodConfiguration[] + * @var \PostFinanceCheckout\Sdk\Model\PaymentMethodConfiguration[] */ private static $possible_payment_method_cache = array(); /** * The transaction API service. * - * @var \Wallee\Sdk\Service\TransactionService + * @var \PostFinanceCheckout\Sdk\Service\TransactionService */ private $transaction_service; /** * The charge attempt API service. * - * @var \Wallee\Sdk\Service\ChargeAttemptService + * @var \PostFinanceCheckout\Sdk\Service\ChargeAttemptService */ private $charge_attempt_service; /** * Returns the transaction API service. * - * @return \Wallee\Sdk\Service\TransactionService + * @return \PostFinanceCheckout\Sdk\Service\TransactionService */ private function getTransactionService(){ if ($this->transaction_service === null) { @@ -240,7 +263,7 @@ private function getTransactionService(){ /** * Returns the charge attempt API service. * - * @return \Wallee\Sdk\Service\ChargeAttemptService + * @return \PostFinanceCheckout\Sdk\Service\ChargeAttemptService */ private function getChargeAttemptService(){ if ($this->charge_attempt_service === null) { @@ -253,7 +276,7 @@ private function getChargeAttemptService(){ * Updates the line items to be in line with the current order. * * @param string $order_id - * @return \Wallee\Sdk\Model\TransactionLineItemVersion + * @return \PostFinanceCheckout\Sdk\Model\TransactionLineItemVersion */ public function updateLineItemsFromOrder($order_id){ $order_info = \PostFinanceCheckoutHelper::instance($this->registry)->getOrder($order_id); @@ -262,7 +285,7 @@ public function updateLineItemsFromOrder($order_id){ $line_items = \PostFinanceCheckout\Service\LineItem::instance($this->registry)->getItemsFromOrder($order_info, $transaction_info->getTransactionId(), $transaction_info->getSpaceId()); - $update_request = new \Wallee\Sdk\Model\TransactionLineItemUpdateRequest(); + $update_request = new \PostFinanceCheckout\Sdk\Model\TransactionLineItemUpdateRequest(); $update_request->setTransactionId($transaction_info->getTransactionId()); $update_request->setNewLineItems($line_items); return $this->getTransactionService()->updateTransactionLineItems($transaction_info->getSpaceId(), $update_request); @@ -271,11 +294,11 @@ public function updateLineItemsFromOrder($order_id){ /** * Stores the transaction data in the database. * - * @param \Wallee\Sdk\Model\Transaction $transaction + * @param \PostFinanceCheckout\Sdk\Model\Transaction $transaction * @param array $order_info * @return \PostFinanceCheckout\Entity\TransactionInfo */ - public function updateTransactionInfo(\Wallee\Sdk\Model\Transaction $transaction, $order_id){ + public function updateTransactionInfo(\PostFinanceCheckout\Sdk\Model\Transaction $transaction, $order_id){ $info = \PostFinanceCheckout\Entity\TransactionInfo::loadByTransaction($this->registry, $transaction->getLinkedSpaceId(), $transaction->getId()); $info->setTransactionId($transaction->getId()); @@ -293,8 +316,8 @@ public function updateTransactionInfo(\Wallee\Sdk\Model\Transaction $transaction null ? $transaction->getPaymentConnectorConfiguration()->getPaymentMethodConfiguration()->getPaymentMethod() : null); $info->setImage($this->getPaymentMethodImage($transaction)); $info->setLabels($this->getTransactionLabels($transaction)); - if ($transaction->getState() == \Wallee\Sdk\Model\TransactionState::FAILED || - $transaction->getState() == \Wallee\Sdk\Model\TransactionState::DECLINE) { + if ($transaction->getState() == \PostFinanceCheckout\Sdk\Model\TransactionState::FAILED || + $transaction->getState() == \PostFinanceCheckout\Sdk\Model\TransactionState::DECLINE) { $failed_charge_attempt = $this->getFailedChargeAttempt($transaction->getLinkedSpaceId(), $transaction->getId()); if ($failed_charge_attempt && $failed_charge_attempt->getFailureReason() != null) { $info->setFailureReason($failed_charge_attempt->getFailureReason()->getDescription()); @@ -312,17 +335,17 @@ public function updateTransactionInfo(\Wallee\Sdk\Model\Transaction $transaction * * @param int $space_id * @param int $transaction_id - * @return \Wallee\Sdk\Model\ChargeAttempt + * @return \PostFinanceCheckout\Sdk\Model\ChargeAttempt */ private function getFailedChargeAttempt($space_id, $transaction_id){ $charge_attempt_service = $this->getChargeAttemptService(); - $query = new \Wallee\Sdk\Model\EntityQuery(); - $filter = new \Wallee\Sdk\Model\EntityQueryFilter(); - $filter->setType(\Wallee\Sdk\Model\EntityQueryFilterType::_AND); + $query = new \PostFinanceCheckout\Sdk\Model\EntityQuery(); + $filter = new \PostFinanceCheckout\Sdk\Model\EntityQueryFilter(); + $filter->setType(\PostFinanceCheckout\Sdk\Model\EntityQueryFilterType::_AND); $filter->setChildren( array( $this->createEntityFilter('charge.transaction.id', $transaction_id), - $this->createEntityFilter('state', \Wallee\Sdk\Model\ChargeAttemptState::FAILED) + $this->createEntityFilter('state', \PostFinanceCheckout\Sdk\Model\ChargeAttemptState::FAILED) )); $query->setFilter($filter); $query->setOrderBys(array( @@ -341,10 +364,10 @@ private function getFailedChargeAttempt($space_id, $transaction_id){ /** * Returns an array of the transaction's labels. * - * @param \Wallee\Sdk\Model\Transaction $transaction + * @param \PostFinanceCheckout\Sdk\Model\Transaction $transaction * @return string[] */ - private function getTransactionLabels(\Wallee\Sdk\Model\Transaction $transaction){ + private function getTransactionLabels(\PostFinanceCheckout\Sdk\Model\Transaction $transaction){ $charge_attempt = $this->getChargeAttempt($transaction); if ($charge_attempt != null) { $labels = array(); @@ -361,18 +384,18 @@ private function getTransactionLabels(\Wallee\Sdk\Model\Transaction $transaction /** * Returns the successful charge attempt of the transaction. * - * @param \Wallee\Sdk\Model\Transaction $transaction - * @return \Wallee\Sdk\Model\ChargeAttempt + * @param \PostFinanceCheckout\Sdk\Model\Transaction $transaction + * @return \PostFinanceCheckout\Sdk\Model\ChargeAttempt */ - private function getChargeAttempt(\Wallee\Sdk\Model\Transaction $transaction){ + private function getChargeAttempt(\PostFinanceCheckout\Sdk\Model\Transaction $transaction){ $charge_attempt_service = $this->getChargeAttemptService(); - $query = new \Wallee\Sdk\Model\EntityQuery(); - $filter = new \Wallee\Sdk\Model\EntityQueryFilter(); - $filter->setType(\Wallee\Sdk\Model\EntityQueryFilterType::_AND); + $query = new \PostFinanceCheckout\Sdk\Model\EntityQuery(); + $filter = new \PostFinanceCheckout\Sdk\Model\EntityQueryFilter(); + $filter->setType(\PostFinanceCheckout\Sdk\Model\EntityQueryFilterType::_AND); $filter->setChildren( array( $this->createEntityFilter('charge.transaction.id', $transaction->getId()), - $this->createEntityFilter('state', \Wallee\Sdk\Model\ChargeAttemptState::SUCCESSFUL) + $this->createEntityFilter('state', \PostFinanceCheckout\Sdk\Model\ChargeAttemptState::SUCCESSFUL) )); $query->setFilter($filter); $query->setNumberOfEntities(1); @@ -388,10 +411,10 @@ private function getChargeAttempt(\Wallee\Sdk\Model\Transaction $transaction){ /** * Returns the payment method's image. * - * @param \Wallee\Sdk\Model\Transaction $transaction + * @param \PostFinanceCheckout\Sdk\Model\Transaction $transaction * @return string */ - private function getPaymentMethodImage(\Wallee\Sdk\Model\Transaction $transaction){ + private function getPaymentMethodImage(\PostFinanceCheckout\Sdk\Model\Transaction $transaction){ if ($transaction->getPaymentConnectorConfiguration() == null || $transaction->getPaymentConnectorConfiguration()->getPaymentMethodConfiguration() == null) { return null; @@ -400,7 +423,7 @@ private function getPaymentMethodImage(\Wallee\Sdk\Model\Transaction $transactio } private function assembleAddress($source, $prefix = ''){ - $address = new \Wallee\Sdk\Model\AddressCreate(); + $address = new \PostFinanceCheckout\Sdk\Model\AddressCreate(); if (isset($source[$prefix . 'city'])) { $address->setCity($this->getFixedSource($source, $prefix . 'city', 100)); @@ -474,13 +497,13 @@ private function getSessionSpaceId(){ return $this->registry->get('session')->data['postfinancecheckout_space_id']; } - private function storeTransactionIdsInSession(\Wallee\Sdk\Model\Transaction $transaction){ + private function storeTransactionIdsInSession(\PostFinanceCheckout\Sdk\Model\Transaction $transaction){ $this->registry->get('session')->data['postfinancecheckout_customer'] = \PostFinanceCheckoutHelper::instance($this->registry)->getCustomerSessionIdentifier(); $this->registry->get('session')->data['postfinancecheckout_transaction_id'] = $transaction->getId(); $this->registry->get('session')->data['postfinancecheckout_space_id'] = $transaction->getLinkedSpaceId(); } - private function storeShipping(\Wallee\Sdk\Model\Transaction $transaction){ + private function storeShipping(\PostFinanceCheckout\Sdk\Model\Transaction $transaction){ if (isset($this->registry->get('session')->data['shipping_method'])) { $shipping_info = \PostFinanceCheckout\Entity\ShippingInfo::loadByTransaction($this->registry, $transaction->getLinkedSpaceId(), $transaction->getId()); @@ -492,7 +515,7 @@ private function storeShipping(\Wallee\Sdk\Model\Transaction $transaction){ } } - private function storeCoupon(\Wallee\Sdk\Model\Transaction $transaction){ + private function storeCoupon(\PostFinanceCheckout\Sdk\Model\Transaction $transaction){ if (isset($this->registry->get('session')->data['coupon']) && isset($this->registry->get('session')->data['order_id'])) { $transaction_info = \PostFinanceCheckout\Entity\TransactionInfo::loadByTransaction($this->registry, $this->registry->get('session')->data['order_id']); @@ -500,7 +523,7 @@ private function storeCoupon(\Wallee\Sdk\Model\Transaction $transaction){ $transaction_info->setSpaceId($transaction->getLinkedSpaceId()); $transaction_info->setOrderId($this->registry->get('session')->data['order_id']); $transaction_info->setCouponCode($this->registry->get('session')->data['coupon']); - $transaction_info->setState(\Wallee\Sdk\Model\TransactionState::CREATE); + $transaction_info->setState(\PostFinanceCheckout\Sdk\Model\TransactionState::CREATE); $transaction_info->save(); } } diff --git a/upload/system/library/postfinancecheckout/service/void_job.php b/upload/system/library/postfinancecheckout/service/void_job.php index 9a8daa9..c3cf2ba 100644 --- a/upload/system/library/postfinancecheckout/service/void_job.php +++ b/upload/system/library/postfinancecheckout/service/void_job.php @@ -32,7 +32,7 @@ public function send(\PostFinanceCheckout\Entity\VoidJob $job){ \PostFinanceCheckoutHelper::instance($this->registry)->dbTransactionStart(); \PostFinanceCheckoutHelper::instance($this->registry)->dbTransactionLock($job->getSpaceId(), $job->getTransactionId()); - $service = new \Wallee\Sdk\Service\TransactionVoidService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); + $service = new \PostFinanceCheckout\Sdk\Service\TransactionVoidService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); $operation = $service->voidOnline($job->getSpaceId(), $job->getTransactionId()); if ($operation->getFailureReason() != null) { @@ -52,7 +52,7 @@ public function send(\PostFinanceCheckout\Entity\VoidJob $job){ \PostFinanceCheckoutHelper::instance($this->registry)->dbTransactionCommit(); return $job; } - catch (\Wallee\Sdk\ApiException $api_exception) { + catch (\PostFinanceCheckout\Sdk\ApiException $api_exception) { } catch (\Exception $e) { \PostFinanceCheckoutHelper::instance($this->registry)->dbTransactionRollback(); diff --git a/upload/system/library/postfinancecheckout/service/webhook.php b/upload/system/library/postfinancecheckout/service/webhook.php index 970a691..a3fcd77 100644 --- a/upload/system/library/postfinancecheckout/service/webhook.php +++ b/upload/system/library/postfinancecheckout/service/webhook.php @@ -12,14 +12,14 @@ class Webhook extends AbstractService { /** * The webhook listener API service. * - * @var \Wallee\Sdk\Service\WebhookListenerService + * @var \PostFinanceCheckout\Sdk\Service\WebhookListenerService */ private $webhook_listener_service; /** * The webhook url API service. * - * @var \Wallee\Sdk\Service\WebhookUrlService + * @var \PostFinanceCheckout\Sdk\Service\WebhookUrlService */ private $webhook_url_service; private $webhook_entities = array(); @@ -31,61 +31,61 @@ protected function __construct(\Registry $registry){ parent::__construct($registry); $this->webhook_entities[1487165678181] = new Entity(1487165678181, 'Manual Task', array( - \Wallee\Sdk\Model\ManualTaskState::DONE, - \Wallee\Sdk\Model\ManualTaskState::EXPIRED, - \Wallee\Sdk\Model\ManualTaskState::OPEN + \PostFinanceCheckout\Sdk\Model\ManualTaskState::DONE, + \PostFinanceCheckout\Sdk\Model\ManualTaskState::EXPIRED, + \PostFinanceCheckout\Sdk\Model\ManualTaskState::OPEN ), 'PostFinanceCheckout\Webhook\ManualTask'); $this->webhook_entities[1472041857405] = new Entity(1472041857405, 'Payment Method Configuration', array( - \Wallee\Sdk\Model\CreationEntityState::ACTIVE, - \Wallee\Sdk\Model\CreationEntityState::DELETED, - \Wallee\Sdk\Model\CreationEntityState::DELETING, - \Wallee\Sdk\Model\CreationEntityState::INACTIVE + \PostFinanceCheckout\Sdk\Model\CreationEntityState::ACTIVE, + \PostFinanceCheckout\Sdk\Model\CreationEntityState::DELETED, + \PostFinanceCheckout\Sdk\Model\CreationEntityState::DELETING, + \PostFinanceCheckout\Sdk\Model\CreationEntityState::INACTIVE ), 'PostFinanceCheckout\Webhook\MethodConfiguration', true); $this->webhook_entities[1472041829003] = new Entity(1472041829003, 'Transaction', array( - \Wallee\Sdk\Model\TransactionState::CONFIRMED, - \Wallee\Sdk\Model\TransactionState::AUTHORIZED, - \Wallee\Sdk\Model\TransactionState::DECLINE, - \Wallee\Sdk\Model\TransactionState::FAILED, - \Wallee\Sdk\Model\TransactionState::FULFILL, - \Wallee\Sdk\Model\TransactionState::VOIDED, - \Wallee\Sdk\Model\TransactionState::COMPLETED, - \Wallee\Sdk\Model\TransactionState::PROCESSING + \PostFinanceCheckout\Sdk\Model\TransactionState::CONFIRMED, + \PostFinanceCheckout\Sdk\Model\TransactionState::AUTHORIZED, + \PostFinanceCheckout\Sdk\Model\TransactionState::DECLINE, + \PostFinanceCheckout\Sdk\Model\TransactionState::FAILED, + \PostFinanceCheckout\Sdk\Model\TransactionState::FULFILL, + \PostFinanceCheckout\Sdk\Model\TransactionState::VOIDED, + \PostFinanceCheckout\Sdk\Model\TransactionState::COMPLETED, + \PostFinanceCheckout\Sdk\Model\TransactionState::PROCESSING ), 'PostFinanceCheckout\Webhook\Transaction'); $this->webhook_entities[1472041819799] = new Entity(1472041819799, 'Delivery Indication', array( - \Wallee\Sdk\Model\DeliveryIndicationState::MANUAL_CHECK_REQUIRED + \PostFinanceCheckout\Sdk\Model\DeliveryIndicationState::MANUAL_CHECK_REQUIRED ), 'PostFinanceCheckout\Webhook\DeliveryIndication'); $this->webhook_entities[1472041831364] = new Entity(1472041831364, 'Transaction Completion', array( - \Wallee\Sdk\Model\TransactionCompletionState::FAILED, - \Wallee\Sdk\Model\TransactionCompletionState::SUCCESSFUL + \PostFinanceCheckout\Sdk\Model\TransactionCompletionState::FAILED, + \PostFinanceCheckout\Sdk\Model\TransactionCompletionState::SUCCESSFUL ), 'PostFinanceCheckout\Webhook\TransactionCompletion'); $this->webhook_entities[1472041867364] = new Entity(1472041867364, 'Transaction Void', array( - \Wallee\Sdk\Model\TransactionVoidState::FAILED, - \Wallee\Sdk\Model\TransactionVoidState::SUCCESSFUL + \PostFinanceCheckout\Sdk\Model\TransactionVoidState::FAILED, + \PostFinanceCheckout\Sdk\Model\TransactionVoidState::SUCCESSFUL ), 'PostFinanceCheckout\Webhook\TransactionVoid'); $this->webhook_entities[1472041839405] = new Entity(1472041839405, 'Refund', array( - \Wallee\Sdk\Model\RefundState::FAILED, - \Wallee\Sdk\Model\RefundState::SUCCESSFUL + \PostFinanceCheckout\Sdk\Model\RefundState::FAILED, + \PostFinanceCheckout\Sdk\Model\RefundState::SUCCESSFUL ), 'PostFinanceCheckout\Webhook\TransactionRefund'); $this->webhook_entities[1472041806455] = new Entity(1472041806455, 'Token', array( - \Wallee\Sdk\Model\CreationEntityState::ACTIVE, - \Wallee\Sdk\Model\CreationEntityState::DELETED, - \Wallee\Sdk\Model\CreationEntityState::DELETING, - \Wallee\Sdk\Model\CreationEntityState::INACTIVE + \PostFinanceCheckout\Sdk\Model\CreationEntityState::ACTIVE, + \PostFinanceCheckout\Sdk\Model\CreationEntityState::DELETED, + \PostFinanceCheckout\Sdk\Model\CreationEntityState::DELETING, + \PostFinanceCheckout\Sdk\Model\CreationEntityState::INACTIVE ), 'PostFinanceCheckout\Webhook\Token'); $this->webhook_entities[1472041811051] = new Entity(1472041811051, 'Token Version', array( - \Wallee\Sdk\Model\TokenVersionState::ACTIVE, - \Wallee\Sdk\Model\TokenVersionState::OBSOLETE + \PostFinanceCheckout\Sdk\Model\TokenVersionState::ACTIVE, + \PostFinanceCheckout\Sdk\Model\TokenVersionState::OBSOLETE ), 'PostFinanceCheckout\Webhook\TokenVersion'); } @@ -146,15 +146,15 @@ public function getWebhookEntityForId($id){ * * @param Entity $entity * @param int $space_id - * @param \Wallee\Sdk\Model\WebhookUrl $webhook_url - * @return \Wallee\Sdk\Model\WebhookListenerCreate + * @param \PostFinanceCheckout\Sdk\Model\WebhookUrl $webhook_url + * @return \PostFinanceCheckout\Sdk\Model\WebhookListenerCreate */ - protected function createWebhookListener(Entity $entity, $space_id, \Wallee\Sdk\Model\WebhookUrl $webhook_url){ - $webhook_listener = new \Wallee\Sdk\Model\WebhookListenerCreate(); + protected function createWebhookListener(Entity $entity, $space_id, \PostFinanceCheckout\Sdk\Model\WebhookUrl $webhook_url){ + $webhook_listener = new \PostFinanceCheckout\Sdk\Model\WebhookListenerCreate(); $webhook_listener->setEntity($entity->getId()); $webhook_listener->setEntityStates($entity->getStates()); $webhook_listener->setName('Opencart ' . $entity->getName()); - $webhook_listener->setState(\Wallee\Sdk\Model\CreationEntityState::ACTIVE); + $webhook_listener->setState(\PostFinanceCheckout\Sdk\Model\CreationEntityState::ACTIVE); $webhook_listener->setUrl($webhook_url->getId()); $webhook_listener->setNotifyEveryChange($entity->isNotifyEveryChange()); return $this->getWebhookListenerService()->create($space_id, $webhook_listener); @@ -164,16 +164,16 @@ protected function createWebhookListener(Entity $entity, $space_id, \Wallee\Sdk\ * Returns the existing webhook listeners. * * @param int $space_id - * @param \Wallee\Sdk\Model\WebhookUrl $webhook_url - * @return \Wallee\Sdk\Model\WebhookListener[] + * @param \PostFinanceCheckout\Sdk\Model\WebhookUrl $webhook_url + * @return \PostFinanceCheckout\Sdk\Model\WebhookListener[] */ - protected function getWebhookListeners($space_id, \Wallee\Sdk\Model\WebhookUrl $webhook_url){ - $query = new \Wallee\Sdk\Model\EntityQuery(); - $filter = new \Wallee\Sdk\Model\EntityQueryFilter(); - $filter->setType(\Wallee\Sdk\Model\EntityQueryFilterType::_AND); + protected function getWebhookListeners($space_id, \PostFinanceCheckout\Sdk\Model\WebhookUrl $webhook_url){ + $query = new \PostFinanceCheckout\Sdk\Model\EntityQuery(); + $filter = new \PostFinanceCheckout\Sdk\Model\EntityQueryFilter(); + $filter->setType(\PostFinanceCheckout\Sdk\Model\EntityQueryFilterType::_AND); $filter->setChildren( array( - $this->createEntityFilter('state', \Wallee\Sdk\Model\CreationEntityState::ACTIVE), + $this->createEntityFilter('state', \PostFinanceCheckout\Sdk\Model\CreationEntityState::ACTIVE), $this->createEntityFilter('url.id', $webhook_url->getId()) )); $query->setFilter($filter); @@ -184,12 +184,12 @@ protected function getWebhookListeners($space_id, \Wallee\Sdk\Model\WebhookUrl $ * Creates a webhook url. * * @param int $space_id - * @return \Wallee\Sdk\Model\WebhookUrlCreate + * @return \PostFinanceCheckout\Sdk\Model\WebhookUrlCreate */ protected function createWebhookUrl($space_id){ - $webhook_url = new \Wallee\Sdk\Model\WebhookUrlCreate(); + $webhook_url = new \PostFinanceCheckout\Sdk\Model\WebhookUrlCreate(); $webhook_url->setUrl($this->getUrl()); - $webhook_url->setState(\Wallee\Sdk\Model\CreationEntityState::ACTIVE); + $webhook_url->setState(\PostFinanceCheckout\Sdk\Model\CreationEntityState::ACTIVE); $webhook_url->setName('Opencart'); return $this->getWebhookUrlService()->create($space_id, $webhook_url); } @@ -198,16 +198,16 @@ protected function createWebhookUrl($space_id){ * Returns the existing webhook url if there is one. * * @param int $space_id - * @return \Wallee\Sdk\Model\WebhookUrl + * @return \PostFinanceCheckout\Sdk\Model\WebhookUrl */ protected function getWebhookUrl($space_id, $url){ - $query = new \Wallee\Sdk\Model\EntityQuery(); + $query = new \PostFinanceCheckout\Sdk\Model\EntityQuery(); $query->setNumberOfEntities(1); - $filter = new \Wallee\Sdk\Model\EntityQueryFilter(); - $filter->setType(\Wallee\Sdk\Model\EntityQueryFilterType::_AND); + $filter = new \PostFinanceCheckout\Sdk\Model\EntityQueryFilter(); + $filter->setType(\PostFinanceCheckout\Sdk\Model\EntityQueryFilterType::_AND); $filter->setChildren( array( - $this->createEntityFilter('state', \Wallee\Sdk\Model\CreationEntityState::ACTIVE), + $this->createEntityFilter('state', \PostFinanceCheckout\Sdk\Model\CreationEntityState::ACTIVE), $this->createEntityFilter('url', $url) )); $query->setFilter($filter); @@ -232,11 +232,11 @@ protected function getUrl(){ /** * Returns the webhook listener API service. * - * @return \Wallee\Sdk\Service\WebhookListenerService + * @return \PostFinanceCheckout\Sdk\Service\WebhookListenerService */ protected function getWebhookListenerService(){ if ($this->webhook_listener_service == null) { - $this->webhook_listener_service = new \Wallee\Sdk\Service\WebhookListenerService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); + $this->webhook_listener_service = new \PostFinanceCheckout\Sdk\Service\WebhookListenerService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); } return $this->webhook_listener_service; } @@ -244,11 +244,11 @@ protected function getWebhookListenerService(){ /** * Returns the webhook url API service. * - * @return \Wallee\Sdk\Service\WebhookUrlService + * @return \PostFinanceCheckout\Sdk\Service\WebhookUrlService */ protected function getWebhookUrlService(){ if ($this->webhook_url_service == null) { - $this->webhook_url_service = new \Wallee\Sdk\Service\WebhookUrlService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); + $this->webhook_url_service = new \PostFinanceCheckout\Sdk\Service\WebhookUrlService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); } return $this->webhook_url_service; } diff --git a/upload/system/library/postfinancecheckout/version_helper.php b/upload/system/library/postfinancecheckout/version_helper.php index 658fd83..7e2a10a 100644 --- a/upload/system/library/postfinancecheckout/version_helper.php +++ b/upload/system/library/postfinancecheckout/version_helper.php @@ -35,7 +35,11 @@ public static function getModifications(){ 'PostFinanceCheckoutFrontendPdf' => array( 'file' => 'PostFinanceCheckoutFrontendPdf.ocmod.xml', 'default_status' => 1 - ) + ) , + 'PostFinanceCheckoutTransactionView' => array( + 'file' => 'PostFinanceCheckoutTransactionView.ocmod.xml', + 'default_status' => 1 + ) ); } diff --git a/upload/system/library/postfinancecheckout/webhook/delivery_indication.php b/upload/system/library/postfinancecheckout/webhook/delivery_indication.php index 5350a47..b1eb7b6 100644 --- a/upload/system/library/postfinancecheckout/webhook/delivery_indication.php +++ b/upload/system/library/postfinancecheckout/webhook/delivery_indication.php @@ -10,27 +10,27 @@ class DeliveryIndication extends AbstractOrderRelated { /** * * @see AbstractOrderRelated::load_entity() - * @return \Wallee\Sdk\Model\DeliveryIndication + * @return \PostFinanceCheckout\Sdk\Model\DeliveryIndication */ protected function loadEntity(Request $request){ - $delivery_indication_service = new \Wallee\Sdk\Service\DeliveryIndicationService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); + $delivery_indication_service = new \PostFinanceCheckout\Sdk\Service\DeliveryIndicationService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); return $delivery_indication_service->read($request->getSpaceId(), $request->getEntityId()); } protected function getOrderId($delivery_indication){ - /* @var \Wallee\Sdk\Model\DeliveryIndication $delivery_indication */ + /* @var \PostFinanceCheckout\Sdk\Model\DeliveryIndication $delivery_indication */ return $delivery_indication->getTransaction()->getMerchantReference(); } protected function getTransactionId($delivery_indication){ - /* @var $delivery_indication \Wallee\Sdk\Model\DeliveryIndication */ + /* @var $delivery_indication \PostFinanceCheckout\Sdk\Model\DeliveryIndication */ return $delivery_indication->getLinkedTransaction(); } protected function processOrderRelatedInner(array $order_info, $delivery_indication){ - /* @var \Wallee\Sdk\Model\DeliveryIndication $delivery_indication */ + /* @var \PostFinanceCheckout\Sdk\Model\DeliveryIndication $delivery_indication */ switch ($delivery_indication->getState()) { - case \Wallee\Sdk\Model\DeliveryIndicationState::MANUAL_CHECK_REQUIRED: + case \PostFinanceCheckout\Sdk\Model\DeliveryIndicationState::MANUAL_CHECK_REQUIRED: $this->review($order_info); break; default: diff --git a/upload/system/library/postfinancecheckout/webhook/transaction.php b/upload/system/library/postfinancecheckout/webhook/transaction.php index 3ebafed..def9c6f 100644 --- a/upload/system/library/postfinancecheckout/webhook/transaction.php +++ b/upload/system/library/postfinancecheckout/webhook/transaction.php @@ -10,55 +10,55 @@ class Transaction extends AbstractOrderRelated { /** * * @see AbstractOrderRelated::load_entity() - * @return \Wallee\Sdk\Model\Transaction + * @return \PostFinanceCheckout\Sdk\Model\Transaction */ protected function loadEntity(Request $request){ - $transaction_service = new \Wallee\Sdk\Service\TransactionService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); + $transaction_service = new \PostFinanceCheckout\Sdk\Service\TransactionService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); return $transaction_service->read($request->getSpaceId(), $request->getEntityId()); } protected function getOrderId($transaction){ - /* @var \Wallee\Sdk\Model\Transaction $transaction */ + /* @var \PostFinanceCheckout\Sdk\Model\Transaction $transaction */ return $transaction->getMerchantReference(); } protected function getTransactionId($transaction){ - /* @var \Wallee\Sdk\Model\Transaction $transaction */ + /* @var \PostFinanceCheckout\Sdk\Model\Transaction $transaction */ return $transaction->getId(); } protected function processOrderRelatedInner(array $order_info, $transaction){ $oid = $order_info['order_id']; $tid = $transaction->getId(); - /* @var \Wallee\Sdk\Model\Transaction $transaction */ + /* @var \PostFinanceCheckout\Sdk\Model\Transaction $transaction */ $transaction_info = \PostFinanceCheckout\Entity\TransactionInfo::loadByOrderId($this->registry, $order_info['order_id']); if ($transaction->getState() != $transaction_info->getState()) { switch ($transaction->getState()) { - case \Wallee\Sdk\Model\TransactionState::CONFIRMED: + case \PostFinanceCheckout\Sdk\Model\TransactionState::CONFIRMED: $this->processing($transaction, $order_info); break; - case \Wallee\Sdk\Model\TransactionState::PROCESSING: + case \PostFinanceCheckout\Sdk\Model\TransactionState::PROCESSING: $this->confirm($transaction, $order_info); break; - case \Wallee\Sdk\Model\TransactionState::AUTHORIZED: + case \PostFinanceCheckout\Sdk\Model\TransactionState::AUTHORIZED: $this->authorize($transaction, $order_info); break; - case \Wallee\Sdk\Model\TransactionState::DECLINE: + case \PostFinanceCheckout\Sdk\Model\TransactionState::DECLINE: $this->decline($transaction, $order_info); break; - case \Wallee\Sdk\Model\TransactionState::FAILED: + case \PostFinanceCheckout\Sdk\Model\TransactionState::FAILED: $this->failed($transaction, $order_info); break; - case \Wallee\Sdk\Model\TransactionState::FULFILL: + case \PostFinanceCheckout\Sdk\Model\TransactionState::FULFILL: if ($transaction_info->getState() != 'AUTHORIZED' && $transaction_info->getState() != 'COMPLETED') { $this->authorize($transaction, $order_info); } $this->fulfill($transaction, $order_info); break; - case \Wallee\Sdk\Model\TransactionState::VOIDED: + case \PostFinanceCheckout\Sdk\Model\TransactionState::VOIDED: $this->voided($transaction, $order_info); break; - case \Wallee\Sdk\Model\TransactionState::COMPLETED: + case \PostFinanceCheckout\Sdk\Model\TransactionState::COMPLETED: $this->waiting($transaction, $order_info); break; default: @@ -70,42 +70,45 @@ protected function processOrderRelatedInner(array $order_info, $transaction){ \PostFinanceCheckout\Service\Transaction::instance($this->registry)->updateTransactionInfo($transaction, $order_info['order_id']); } - protected function processing(\Wallee\Sdk\Model\Transaction $transaction, array $order_info){ + protected function processing(\PostFinanceCheckout\Sdk\Model\Transaction $transaction, array $order_info){ + // TODO none.. \PostFinanceCheckoutHelper::instance($this->registry)->addOrderHistory($order_info['order_id'], 'postfinancecheckout_processing_status_id', \PostFinanceCheckoutHelper::instance($this->registry)->getTranslation('message_webhook_processing')); } - protected function confirm(\Wallee\Sdk\Model\Transaction $transaction, array $order_info){ - \PostFinanceCheckoutHelper::instance($this->registry)->addOrderHistory($order_info['order_id'], 'postfinancecheckout_confirmed_status_id', + protected function confirm(\PostFinanceCheckout\Sdk\Model\Transaction $transaction, array $order_info){ + // TODO none.. + \PostFinanceCheckoutHelper::instance($this->registry)->addOrderHistory($order_info['order_id'], 'postfinancecheckout_processing_status_id', \PostFinanceCheckoutHelper::instance($this->registry)->getTranslation('message_webhook_confirm')); } - protected function authorize(\Wallee\Sdk\Model\Transaction $transaction, array $order_info){ + protected function authorize(\PostFinanceCheckout\Sdk\Model\Transaction $transaction, array $order_info){ \PostFinanceCheckoutHelper::instance($this->registry)->addOrderHistory($order_info['order_id'], 'postfinancecheckout_authorized_status_id', \PostFinanceCheckoutHelper::instance($this->registry)->getTranslation('message_webhook_authorize')); } - protected function waiting(\Wallee\Sdk\Model\Transaction $transaction, array $order_info){ + protected function waiting(\PostFinanceCheckout\Sdk\Model\Transaction $transaction, array $order_info){ \PostFinanceCheckoutHelper::instance($this->registry)->addOrderHistory($order_info['order_id'], 'postfinancecheckout_completed_status_id', \PostFinanceCheckoutHelper::instance($this->registry)->getTranslation('message_webhook_waiting')); } - protected function decline(\Wallee\Sdk\Model\Transaction $transaction, array $order_info){ + protected function decline(\PostFinanceCheckout\Sdk\Model\Transaction $transaction, array $order_info){ \PostFinanceCheckoutHelper::instance($this->registry)->addOrderHistory($order_info['order_id'], 'postfinancecheckout_decline_status_id', \PostFinanceCheckoutHelper::instance($this->registry)->getTranslation('message_webhook_decline')); } - protected function failed(\Wallee\Sdk\Model\Transaction $transaction, array $order_info){ + protected function failed(\PostFinanceCheckout\Sdk\Model\Transaction $transaction, array $order_info){ + // TODO none \PostFinanceCheckoutHelper::instance($this->registry)->addOrderHistory($order_info['order_id'], 'postfinancecheckout_failed_status_id', \PostFinanceCheckoutHelper::instance($this->registry)->getTranslation('message_webhook_failed')); } - protected function fulfill(\Wallee\Sdk\Model\Transaction $transaction, array $order_info){ + protected function fulfill(\PostFinanceCheckout\Sdk\Model\Transaction $transaction, array $order_info){ \PostFinanceCheckoutHelper::instance($this->registry)->addOrderHistory($order_info['order_id'], 'postfinancecheckout_fulfill_status_id', \PostFinanceCheckoutHelper::instance($this->registry)->getTranslation('message_webhook_fulfill')); } - protected function voided(\Wallee\Sdk\Model\Transaction $transaction, array $order_info){ + protected function voided(\PostFinanceCheckout\Sdk\Model\Transaction $transaction, array $order_info){ \PostFinanceCheckoutHelper::instance($this->registry)->addOrderHistory($order_info['order_id'], 'postfinancecheckout_voided_status_id', \PostFinanceCheckoutHelper::instance($this->registry)->getTranslation('message_webhook_voided')); } diff --git a/upload/system/library/postfinancecheckout/webhook/transaction_completion.php b/upload/system/library/postfinancecheckout/webhook/transaction_completion.php index 004232e..646f7b7 100644 --- a/upload/system/library/postfinancecheckout/webhook/transaction_completion.php +++ b/upload/system/library/postfinancecheckout/webhook/transaction_completion.php @@ -10,30 +10,30 @@ class TransactionCompletion extends AbstractOrderRelated { /** * * @see AbstractOrderRelated::loadEntity() - * @return \Wallee\Sdk\Model\TransactionCompletion + * @return \PostFinanceCheckout\Sdk\Model\TransactionCompletion */ protected function loadEntity(Request $request){ - $completion_service = new \Wallee\Sdk\Service\TransactionCompletionService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); + $completion_service = new \PostFinanceCheckout\Sdk\Service\TransactionCompletionService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); return $completion_service->read($request->getSpaceId(), $request->getEntityId()); } protected function getOrderId($completion){ - /* @var \Wallee\Sdk\Model\TransactionCompletion $completion */ + /* @var \PostFinanceCheckout\Sdk\Model\TransactionCompletion $completion */ return $completion->getLineItemVersion()->getTransaction()->getMerchantReference(); } protected function getTransactionId($entity){ - /* @var $entity \Wallee\Sdk\Model\TransactionCompletion */ + /* @var $entity \PostFinanceCheckout\Sdk\Model\TransactionCompletion */ return $entity->getLinkedTransaction(); } protected function processOrderRelatedInner(array $order_info, $completion){ - /* @var \Wallee\Sdk\Model\TransactionCompletion $completion */ + /* @var \PostFinanceCheckout\Sdk\Model\TransactionCompletion $completion */ switch ($completion->getState()) { - case \Wallee\Sdk\Model\TransactionCompletionState::FAILED: + case \PostFinanceCheckout\Sdk\Model\TransactionCompletionState::FAILED: $this->failed($completion, $order_info); break; - case \Wallee\Sdk\Model\TransactionCompletionState::SUCCESSFUL: + case \PostFinanceCheckout\Sdk\Model\TransactionCompletionState::SUCCESSFUL: $this->success($completion, $order_info); break; default: @@ -43,7 +43,7 @@ protected function processOrderRelatedInner(array $order_info, $completion){ } } - protected function success(\Wallee\Sdk\Model\TransactionCompletion $completion, array $order_info){ + protected function success(\PostFinanceCheckout\Sdk\Model\TransactionCompletion $completion, array $order_info){ $completion_job = \PostFinanceCheckout\Entity\CompletionJob::loadByJob($this->registry, $completion->getLinkedSpaceId(), $completion->getId()); if (!$completion_job->getId()) { //We have no completion job with this id -> the server could not store the id of the completion after sending the request. (e.g. connection issue or crash) @@ -61,7 +61,7 @@ protected function success(\Wallee\Sdk\Model\TransactionCompletion $completion, $completion_job->save(); } - protected function failed(\Wallee\Sdk\Model\TransactionCompletion $completion, array $order_info){ + protected function failed(\PostFinanceCheckout\Sdk\Model\TransactionCompletion $completion, array $order_info){ $completion_job = \PostFinanceCheckout\Entity\CompletionJob::loadByJob($this->registry, $completion->getLinkedSpaceId(), $completion->getId()); if (!$completion_job->getId()) { //We have no completion job with this id -> the server could not store the id of the completion after sending the request. (e.g. connection issue or crash) diff --git a/upload/system/library/postfinancecheckout/webhook/transaction_refund.php b/upload/system/library/postfinancecheckout/webhook/transaction_refund.php index bab5ab3..7ba00d0 100644 --- a/upload/system/library/postfinancecheckout/webhook/transaction_refund.php +++ b/upload/system/library/postfinancecheckout/webhook/transaction_refund.php @@ -10,30 +10,30 @@ class TransactionRefund extends AbstractOrderRelated { /** * * @see AbstractOrderRelated::load_entity() - * @return \Wallee\Sdk\Model\Refund + * @return \PostFinanceCheckout\Sdk\Model\Refund */ protected function loadEntity(Request $request){ - $refund_service = new \Wallee\Sdk\Service\RefundService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); + $refund_service = new \PostFinanceCheckout\Sdk\Service\RefundService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); return $refund_service->read($request->getSpaceId(), $request->getEntityId()); } protected function getOrderId($refund){ - /* @var \Wallee\Sdk\Model\Refund $refund */ + /* @var \PostFinanceCheckout\Sdk\Model\Refund $refund */ return $refund->getTransaction()->getMerchantReference(); } protected function getTransactionId($entity){ - /* @var $entity \Wallee\Sdk\Model\Refund */ + /* @var $entity \PostFinanceCheckout\Sdk\Model\Refund */ return $entity->getTransaction()->getId(); } protected function processOrderRelatedInner(array $order_info, $refund){ - /* @var \Wallee\Sdk\Model\Refund $refund */ + /* @var \PostFinanceCheckout\Sdk\Model\Refund $refund */ switch ($refund->getState()) { - case \Wallee\Sdk\Model\RefundState::FAILED: + case \PostFinanceCheckout\Sdk\Model\RefundState::FAILED: $this->failed($refund, $order_info); break; - case \Wallee\Sdk\Model\RefundState::SUCCESSFUL: + case \PostFinanceCheckout\Sdk\Model\RefundState::SUCCESSFUL: $this->refunded($refund, $order_info); default: // Nothing to do. @@ -41,7 +41,7 @@ protected function processOrderRelatedInner(array $order_info, $refund){ } } - protected function failed(\Wallee\Sdk\Model\Refund $refund, array $order_info){ + protected function failed(\PostFinanceCheckout\Sdk\Model\Refund $refund, array $order_info){ $refund_job = \PostFinanceCheckout\Entity\RefundJob::loadByExternalId($this->registry, $refund->getLinkedSpaceId(), $refund->getExternalId()); if ($refund_job->getId()) { @@ -56,7 +56,7 @@ protected function failed(\Wallee\Sdk\Model\Refund $refund, array $order_info){ } } - protected function refunded(\Wallee\Sdk\Model\Refund $refund, array $order_info){ + protected function refunded(\PostFinanceCheckout\Sdk\Model\Refund $refund, array $order_info){ $refund_job = \PostFinanceCheckout\Entity\RefundJob::loadByExternalId($this->registry, $refund->getLinkedSpaceId(), $refund->getExternalId()); if ($refund_job->getId()) { $refund_job->setState(\PostFinanceCheckout\Entity\RefundJob::STATE_SUCCESS); @@ -82,11 +82,11 @@ protected function refunded(\Wallee\Sdk\Model\Refund $refund, array $order_info) } } - protected function restock(\Wallee\Sdk\Model\Refund $refund){ + protected function restock(\PostFinanceCheckout\Sdk\Model\Refund $refund){ $db = $this->registry->get('db'); $table = DB_PREFIX . 'product'; foreach ($refund->getLineItems() as $line_item) { - if ($line_item->getType() == \Wallee\Sdk\Model\LineItemType::PRODUCT) { + if ($line_item->getType() == \PostFinanceCheckout\Sdk\Model\LineItemType::PRODUCT) { $quantity = $db->escape($line_item->getQuantity()); $id = $db->escape($line_item->getUniqueId()); $query = "UPDATE $table SET quantity=quantity+$quantity WHERE product_id='$id';"; diff --git a/upload/system/library/postfinancecheckout/webhook/transaction_void.php b/upload/system/library/postfinancecheckout/webhook/transaction_void.php index a7c5039..1f81c3b 100644 --- a/upload/system/library/postfinancecheckout/webhook/transaction_void.php +++ b/upload/system/library/postfinancecheckout/webhook/transaction_void.php @@ -10,30 +10,30 @@ class TransactionVoid extends AbstractOrderRelated { /** * * @see AbstractOrderRelated::loadEntity() - * @return \Wallee\Sdk\Model\TransactionVoid + * @return \PostFinanceCheckout\Sdk\Model\TransactionVoid */ protected function loadEntity(Request $request){ - $void_service = new \Wallee\Sdk\Service\TransactionVoidService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); + $void_service = new \PostFinanceCheckout\Sdk\Service\TransactionVoidService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); return $void_service->read($request->getSpaceId(), $request->getEntityId()); } protected function getOrderId($void){ - /* @var \Wallee\Sdk\Model\TransactionVoid $void */ + /* @var \PostFinanceCheckout\Sdk\Model\TransactionVoid $void */ return $void->getTransaction()->getMerchantReference(); } protected function getTransactionId($entity){ - /* @var $entity \Wallee\Sdk\Model\TransactionVoid */ + /* @var $entity \PostFinanceCheckout\Sdk\Model\TransactionVoid */ return $entity->getTransaction()->getId(); } protected function processOrderRelatedInner(array $order_info, $void){ - /* @var \Wallee\Sdk\Model\TransactionVoid $void */ + /* @var \PostFinanceCheckout\Sdk\Model\TransactionVoid $void */ switch ($void->getState()) { - case \Wallee\Sdk\Model\TransactionVoidState::FAILED: + case \PostFinanceCheckout\Sdk\Model\TransactionVoidState::FAILED: $this->failed($void, $order_info); break; - case \Wallee\Sdk\Model\TransactionVoidState::SUCCESSFUL: + case \PostFinanceCheckout\Sdk\Model\TransactionVoidState::SUCCESSFUL: $this->success($void, $order_info); break; default: @@ -42,7 +42,7 @@ protected function processOrderRelatedInner(array $order_info, $void){ } } - protected function success(\Wallee\Sdk\Model\TransactionVoid $void, array $order_info){ + protected function success(\PostFinanceCheckout\Sdk\Model\TransactionVoid $void, array $order_info){ $void_job = \PostFinanceCheckout\Entity\VoidJob::loadByJob($this->registry, $void->getLinkedSpaceId(), $void->getId()); if (!$void_job->getId()) { //We have no void job with this id -> the server could not store the id of the void after sending the request. (e.g. connection issue or crash) @@ -59,7 +59,7 @@ protected function success(\Wallee\Sdk\Model\TransactionVoid $void, array $order $void_job->save(); } - protected function failed(\Wallee\Sdk\Model\TransactionVoid $void, array $order_info){ + protected function failed(\PostFinanceCheckout\Sdk\Model\TransactionVoid $void, array $order_info){ $void_job = \PostFinanceCheckout\Entity\VoidJob::loadByJob($this->registry, $void->getLinkedSpaceId(), $void->getId()); if (!$void_job->getId()) { //We have no void job with this id -> the server could not store the id of the void after sending the request. (e.g. connection issue or crash)