Skip to content

Commit

Permalink
1.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
dyd committed Feb 9, 2024
1 parent deb2dc1 commit 5fc6310
Show file tree
Hide file tree
Showing 49 changed files with 2,599 additions and 1,356 deletions.
2 changes: 2 additions & 0 deletions .phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
<rule ref="OpenCart" />

<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*.min.js</exclude-pattern>
<exclude-pattern>*.min.css</exclude-pattern>
</ruleset>
6 changes: 0 additions & 6 deletions .pronto.yml

This file was deleted.

6 changes: 0 additions & 6 deletions Gemfile

This file was deleted.

53 changes: 0 additions & 53 deletions Gemfile.lock

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Requirements
------------

* OpenCart 4.0.2.X (due to architectural changes, this module is __incompatible__ with older OpenCart versions)
* [GenesisPHP v1.24.0](https://github.com/GenesisGateway/genesis_php/tree/1.24.0) - (Integrated in Module)
* [GenesisPHP v1.24.2](https://github.com/GenesisGateway/genesis_php/tree/1.24.2) - (Integrated in Module)
* PCI-certified server in order to use ```emerchantpay Direct```

GenesisPHP Requirements
Expand Down
2 changes: 1 addition & 1 deletion admin/controller/payment/emerchantpay_direct.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected function validate(): bool
{
parent::validate();

if (@empty($this->request->post["{$this->module_name}_token"])) {
if (empty($this->request->post["{$this->module_name}_token"])) {
$this->error['token'] = $this->language->get('error_token');
}

Expand Down
57 changes: 33 additions & 24 deletions admin/language/en-gb/payment/emerchantpay_checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,34 @@
$_['text_select_status'] = 'Select Status';

// Entry
$_['entry_username'] = 'Genesis Username';
$_['entry_password'] = 'Genesis Password';
$_['entry_token'] = 'Genesis Token';
$_['entry_sandbox'] = 'Test Mode';
$_['entry_transaction_type'] = 'Transaction Types';
$_['entry_wpf_tokenization'] = 'WPF Tokenization Enabled';
$_['entry_supports_partial_capture'] = 'Partial Capture';
$_['entry_supports_partial_refund'] = 'Partial Refund';
$_['entry_supports_void'] = 'Cancel Transaction';
$_['entry_total'] = 'Total';
$_['entry_order_status'] = 'Order Status';
$_['entry_order_status_failure'] = 'Order Status (Failed)';
$_['entry_geo_zone'] = 'Geo Zone';
$_['entry_status'] = 'Status';
$_['entry_debug'] = 'Error Logging';
$_['entry_sort_order'] = 'Sort Order';
$_['entry_supports_recurring'] = 'Recurring Payments';
$_['entry_recurring_transaction_type'] = 'Recurring Transaction Types';
$_['entry_recurring_log'] = 'Recurring Log';
$_['entry_recurring_token'] = 'Recurring Token';
$_['entry_cron_time_limit'] = 'Processing time for re-billing';
$_['entry_cron_allowed_ip'] = 'IP address';
$_['entry_cron_last_execution'] = 'Cron/schtasks last execution';
$_['entry_bank_codes'] = 'Bank code(s) for Online banking';
$_['entry_username'] = 'Genesis Username';
$_['entry_password'] = 'Genesis Password';
$_['entry_token'] = 'Genesis Token';
$_['entry_sandbox'] = 'Test Mode';
$_['entry_transaction_type'] = 'Transaction Types';
$_['entry_wpf_tokenization'] = 'WPF Tokenization Enabled';
$_['entry_supports_partial_capture'] = 'Partial Capture';
$_['entry_supports_partial_refund'] = 'Partial Refund';
$_['entry_supports_void'] = 'Cancel Transaction';
$_['entry_total'] = 'Total';
$_['entry_order_status'] = 'Order Status';
$_['entry_order_status_failure'] = 'Order Status (Failed)';
$_['entry_geo_zone'] = 'Geo Zone';
$_['entry_status'] = 'Status';
$_['entry_debug'] = 'Error Logging';
$_['entry_sort_order'] = 'Sort Order';
$_['entry_supports_recurring'] = 'Recurring Payments';
$_['entry_recurring_transaction_type'] = 'Recurring Transaction Types';
$_['entry_recurring_log'] = 'Recurring Log';
$_['entry_recurring_token'] = 'Recurring Token';
$_['entry_cron_time_limit'] = 'Processing time for re-billing';
$_['entry_cron_allowed_ip'] = 'IP address';
$_['entry_cron_last_execution'] = 'Cron/schtasks last execution';
$_['entry_bank_codes'] = 'Bank code(s) for Online banking';
$_['entry_threeds_allowed'] = 'Enable 3DSv2';
$_['entry_threeds_challenge_indicator'] = '3DSv2 Challenge';
$_['entry_sca_exemption'] = 'SCA Exemption';
$_['entry_sca_exemption_amount'] = 'Exemption Amount';

// Transaction Types
//$_ = array_merge($_, EmerchantpayHelper::getTransactionTypeNames());
Expand Down Expand Up @@ -138,6 +142,10 @@
$_['help_cron_time_limit'] = 'Тhe total time in seconds allowed for re-billing recurring orders in a single execution of the cron / schtasks. If there is a re-billing in process while reaching this limit, it will try to continue and respectively the execution time will exceed the allowed time.';
$_['help_cron_allowed_ip'] = 'The IP address allowed to send HTTP requests to the cron-handling URLs.';
$_['help_cron_last_execution'] = 'The time the cron / schtasks was last executed.';
$_['help_threeds_allowed'] = 'Enable 3DSv2 optional parameters.';
$_['help_threeds_challenge_indicator'] = 'The value has weight and might impact the decision whether a challenge will be required for the transaction or not.';
$_['help_sca_exemption'] = 'Exemption for the Strong Customer Authentication.';
$_['help_sca_exemption_amount'] = 'Exemption Amount determinate if the SCA Exemption should be included in the request to the Gateway.';

// Error
$_['error_permission'] = 'Warning: You do not have permission to modify payment module emerchantpay!';
Expand All @@ -147,6 +155,7 @@
$_['error_controls_invalidated'] = 'Warning: You have to fill-in all the required fields';
$_['error_order_status'] = 'Order Status is Required';
$_['error_order_failure_status'] = 'Order Status (Failed) is Required';
$_['error_sca_exemption_amount'] = 'SCA Exemption amount must have positive value';

//Alert
$_['alert_disable_recurring'] = 'Warning: Disabling the Recurring Payments disables placing new recurring orders. It does not disable the re-billing of the existing ones.';
Expand Down
9 changes: 9 additions & 0 deletions admin/language/en-gb/payment/emerchantpay_direct.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@
$_['entry_cron_time_limit'] = 'Processing time for re-billing';
$_['entry_cron_allowed_ip'] = 'IP address';
$_['entry_cron_last_execution'] = 'Cron/schtasks last execution';
$_['entry_threeds_allowed'] = 'Enable 3DSv2';
$_['entry_threeds_challenge_indicator'] = '3DSv2 Challenge';
$_['entry_sca_exemption'] = 'SCA Exemption';
$_['entry_sca_exemption_amount'] = 'Exemption Amount';

// Transaction Types
//$_ = array_merge($_, EmerchantpayHelper::getTransactionTypeNames());
Expand Down Expand Up @@ -138,6 +142,10 @@
$_['help_cron_time_limit'] = 'Тhe total time in seconds allowed for re-billing recurring orders in a single execution of the cron / schtasks. If there is a re-billing in process while reaching this limit, it will try to continue and respectively the actual the execution time will exceed the allowed time.';
$_['help_cron_allowed_ip'] = 'The IP address allowed to send HTTP requests to the cron-handling URLs.';
$_['help_cron_last_execution'] = 'The time the cron / schtasks was last executed.';
$_['help_threeds_allowed'] = 'Enable 3DSv2 optional parameters.';
$_['help_threeds_challenge_indicator'] = 'The value has weight and might impact the decision whether a challenge will be required for the transaction or not.';
$_['help_sca_exemption'] = 'Exemption for the Strong Customer Authentication.';
$_['help_sca_exemption_amount'] = 'Exemption Amount determinate if the SCA Exemption should be included in the request to the Gateway.';

// Error
$_['error_permission'] = 'Warning: You do not have permission to modify payment module emerchantpay!';
Expand All @@ -150,6 +158,7 @@
$_['error_order_status'] = 'Order Status is Required';
$_['error_order_failure_status'] = 'Order Status (Failed) is Required';
$_['error_async_order_status'] = 'Order Status (Async) is Required';
$_['error_sca_exemption_amount'] = 'SCA Exemption amount must have positive value';

//Alert
$_['alert_disable_recurring'] = 'Warning: Disabling the Recurring Payments disables placing new recurring orders. It does not disable the re-billing of the existing ones.';
Expand Down
62 changes: 62 additions & 0 deletions admin/model/payment/emerchantpay/base_model.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/*
* Copyright (C) 2018-2024 emerchantpay Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* @author emerchantpay
* @copyright 2018-2024 emerchantpay Ltd.
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License, version 2 (GPL-2.0)
*/

namespace Opencart\Admin\Model\Extension\Emerchantpay\Payment\emerchantpay;

use Genesis\API\Constants\Transaction\Parameters\ScaExemptions;
use Opencart\System\Engine\Model;

/**
* Common model methods for Direct and Checkout
*
* @package BaseModel
*/
class BaseModel extends Model
{
/**
* Holds the current module version
* Will be displayed on Admin Settings Form
*
* @var string
*/
protected $module_version = '1.1.4';

/**
* Returns formatted array with available SCA Exemptions
*
* @return array
*/
public function getScaExemptions(): array
{
$data = [];
$sca_exemptions = [
ScaExemptions::EXEMPTION_LOW_RISK => 'Low risk',
ScaExemptions::EXEMPTION_LOW_VALUE => 'Low value',
];

foreach ($sca_exemptions as $value => $label) {
$data[] = [
'id' => $value,
'name' => $label
];
}

return $data;
}
}
20 changes: 6 additions & 14 deletions admin/model/payment/emerchantpay_checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,19 @@
use Genesis\API\Request\Financial\Alternatives\Klarna\Items as KlarnaItems;
use Genesis\Config;
use Genesis\Genesis;
use Opencart\Admin\Model\Extension\Emerchantpay\Payment\emerchantpay\BaseModel;
use Opencart\Extension\Emerchantpay\System\DbHelper;
use Opencart\Extension\Emerchantpay\System\EmerchantpayHelper;
use Opencart\System\Engine\Model;

/**
* Backend model for the "emerchantpay Checkout" module
*
* @package EMerchantpayCheckout
*/
class EmerchantpayCheckout extends Model
class EmerchantpayCheckout extends BaseModel
{
protected $module_name = 'emerchantpay_checkout';

/**
* Holds the current module version
* Will be displayed on Admin Settings Form
*
* @var string
*/
protected $module_version = '1.1.3';

/**
* Perform installation logic
*
Expand All @@ -70,7 +62,7 @@ public function install(): void
`message` VARCHAR(255) NULL,
`technical_message` VARCHAR(255) NULL,
`terminal_token` VARCHAR(255) NULL,
`amount` DECIMAL( 10, 2 ) DEFAULT NULL,
`amount` DECIMAL( 15, 4 ) DEFAULT NULL,
`currency` CHAR(3) NULL,
PRIMARY KEY (`unique_id`)
) ENGINE=InnoDB DEFAULT COLLATE=utf8_general_ci;
Expand Down Expand Up @@ -243,7 +235,7 @@ public function capture($type, $reference_id, $amount, $currency, $usage, $order
$this->genTransactionId('ocart-')
)
->setRemoteIp(
$this->request->server['REMOTE_ADDR']
EmerchantpayHelper::getFirstRemoteAddress($this->request->server['REMOTE_ADDR'])
)
->setUsage($usage)
->setReferenceId($reference_id)
Expand Down Expand Up @@ -292,7 +284,7 @@ public function refund($type, $reference_id, $amount, $currency, $usage = '', $t
$this->genTransactionId('ocart-')
)
->setRemoteIp(
$this->request->server['REMOTE_ADDR']
EmerchantpayHelper::getFirstRemoteAddress($this->request->server['REMOTE_ADDR'])
)
->setUsage($usage)
->setReferenceId($reference_id)
Expand Down Expand Up @@ -335,7 +327,7 @@ public function void($reference_id, $usage = '', $token = null): object|string
$this->genTransactionId('ocart-')
)
->setRemoteIp(
$this->request->server['REMOTE_ADDR']
EmerchantpayHelper::getFirstRemoteAddress($this->request->server['REMOTE_ADDR'])
)
->setUsage($usage)
->setReferenceId($reference_id);
Expand Down
20 changes: 6 additions & 14 deletions admin/model/payment/emerchantpay_direct.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,19 @@
use Genesis\API\Constants\Transaction\Types;
use Genesis\Config;
use Genesis\Genesis;
use Opencart\Admin\Model\Extension\Emerchantpay\Payment\emerchantpay\BaseModel;
use Opencart\Extension\Emerchantpay\System\DbHelper;
use Opencart\Extension\Emerchantpay\System\EmerchantpayHelper;
use Opencart\System\Engine\Model;

/**
* Backend model for the "emerchantpay Direct" module
*
* @package EMerchantpayDirect
*/
class EmerchantpayDirect extends Model
class EmerchantpayDirect extends BaseModel
{
protected $module_name = "emerchantpay_direct";

/**
* Holds the current module version
* Will be displayed on Admin Settings Form
*
* @var string
*/
protected $module_version = '1.1.3';

/**
* Perform installation logic
*
Expand All @@ -64,7 +56,7 @@ public function install(): void
`status` CHAR(32) NOT NULL,
`message` VARCHAR(255) NULL,
`technical_message` VARCHAR(255) NULL,
`amount` DECIMAL( 10, 2 ) DEFAULT NULL,
`amount` DECIMAL( 15, 4 ) DEFAULT NULL,
`currency` CHAR(3) NULL,
PRIMARY KEY (`unique_id`)
) ENGINE=InnoDB DEFAULT COLLATE=utf8_general_ci;
Expand Down Expand Up @@ -224,7 +216,7 @@ public function capture($type, $reference_id, $amount, $currency, $usage): objec
$this->genTransactionId('ocart-')
)
->setRemoteIp(
$this->request->server['REMOTE_ADDR']
EmerchantpayHelper::getFirstRemoteAddress($this->request->server['REMOTE_ADDR'])
)
->setUsage($usage)
->setReferenceId($reference_id)
Expand Down Expand Up @@ -266,7 +258,7 @@ public function refund($type, $reference_id, $amount, $currency, $usage = ''): o
$this->genTransactionId('ocart-')
)
->setRemoteIp(
$this->request->server['REMOTE_ADDR']
EmerchantpayHelper::getFirstRemoteAddress($this->request->server['REMOTE_ADDR'])
)
->setUsage($usage)
->setReferenceId($reference_id)
Expand Down Expand Up @@ -304,7 +296,7 @@ public function void($reference_id, $usage = ''): object|string
$this->genTransactionId('ocart-')
)
->setRemoteIp(
$this->request->server['REMOTE_ADDR']
EmerchantpayHelper::getFirstRemoteAddress($this->request->server['REMOTE_ADDR'])
)
->setUsage($usage)
->setReferenceId($reference_id);
Expand Down
Loading

0 comments on commit 5fc6310

Please sign in to comment.