Skip to content

Commit

Permalink
Release 1.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
sbossert committed Jan 30, 2019
1 parent e27ef5f commit a337958
Show file tree
Hide file tree
Showing 52 changed files with 1,337 additions and 294 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Please see the [license file](https://github.com/pfpayments/opencart-2.3/blob/1.0.7/LICENSE) for more information.
8 changes: 8 additions & 0 deletions docs/en/assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions docs/en/documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h2>Documentation</h2> </div>
</a>
</li>
<li>
<a href="https://github.com/pfpayments/opencart-2.3/releases/tag/1.0.6/">
<a href="https://github.com/pfpayments/opencart-2.3/releases/tag/1.0.7/">
Source
</a>
</li>
Expand All @@ -48,7 +48,7 @@ <h1>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><a href="https://github.com/pfpayments/opencart-2.3/releases/tag/1.0.6/">Download</a> the extension.</p>
<p><a href="https://github.com/pfpayments/opencart-2.3/releases/tag/1.0.7/">Download</a> the extension.</p>
</li>
<li>
<p>Extract the files and upload the content of the <code>Upload</code> directory into the root directory of your store using FTP/SSH.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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,
Expand Down
213 changes: 213 additions & 0 deletions upload/admin/controller/extension/postfinancecheckout/transaction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
<?php
require_once modification(DIR_SYSTEM . 'library/postfinancecheckout/helper.php');

class ControllerExtensionPostFinanceCheckoutTransaction extends \PostFinanceCheckout\Controller\AbstractController {

public function index(){
$this->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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions upload/admin/model/extension/postfinancecheckout/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand All @@ -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');
}
}
63 changes: 63 additions & 0 deletions upload/admin/model/extension/postfinancecheckout/transaction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
require_once modification(DIR_SYSTEM . 'library/postfinancecheckout/helper.php');
use PostFinanceCheckout\Model\AbstractModel;
use PostFinanceCheckout\Entity\TransactionInfo;
use PostFinanceCheckout\Provider\PaymentMethod;

class ModelExtensionPostFinanceCheckoutTransaction extends AbstractModel {
const DATE_FORMAT = 'Y-m-d H:i:s';

public function loadList(array $filters){
$transactionInfoList = TransactionInfo::loadByFilters($this->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);
}
}
Loading

0 comments on commit a337958

Please sign in to comment.