Skip to content

Commit

Permalink
1.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
dyd committed Apr 18, 2024
1 parent 5fc6310 commit daa4715
Show file tree
Hide file tree
Showing 419 changed files with 3,191 additions and 1,608 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
emerchantpay.ocmod.zip
/vendor/
bin/check-standards
phpcs_report.xml
phpmd_report.xml
62 changes: 58 additions & 4 deletions .phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,64 @@
<?xml version="1.0"?>
<ruleset name="OpenCart EMP Plugin Coding Standards">
<description>Generally-applicable sniffs for OpenCart EMP Plugin</description>

<rule ref="OpenCart" />
<ruleset name="OpenCart Combined Coding Standards">
<description>Combined Code Sniffer rule set for OpenCart and OpenCart EMP Plugin</description>

<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*.min.js</exclude-pattern>
<exclude-pattern>*.min.css</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>

<rule ref="Squiz.ControlStructures.InlineIfDeclaration" />
<rule ref="Zend.Files.ClosingTag">
<severity>5</severity>
<type>error</type>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<severity>1</severity>
<type>warning</type>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.StartFile" />
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EndFile" />
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines" />
<rule ref="Generic.PHP.DeprecatedFunctions">
<severity>5</severity>
<type>error</type>
</rule>
<rule ref="Generic.PHP.DisallowShortOpenTag">
<severity>5</severity>
<type>error</type>
</rule>
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
<rule ref="Generic.PHP.LowerCaseConstant" />
<rule ref="Generic.Formatting.NoSpaceAfterCast" />
<rule ref="Generic.Functions.CallTimePassByReference" />
<rule ref="Generic.Functions.FunctionCallArgumentSpacing" />
<rule ref="Generic.NamingConventions.CamelCapsFunctionName"/>
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
<rule ref="Generic.Files.ByteOrderMark"/>
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent">
<exclude-pattern>*.tpl</exclude-pattern>
<exclude-pattern>*.css</exclude-pattern>
<exclude-pattern>*.html</exclude-pattern>
<exclude-pattern>*.ini</exclude-pattern>
<exclude-pattern>*.txt</exclude-pattern>
<severity>1</severity>
<type>warning</type>
</rule>
<rule ref="Generic.Commenting.Todo.CommentFound">
<message>Please review this TODO comment: %s</message>
<severity>3</severity>
<type>warning</type>
</rule>
<rule ref="Generic.Commenting.Todo.Fixme">
<message>Please review this FIXME comment: %s</message>
<severity>5</severity>
<type>warning</type>
</rule>
<rule ref="Generic.Files.LineEndings">
<properties>
<property name="eolChar" value="\n"/>
</properties>
</rule>
<rule ref="Squiz.ControlStructures.ControlSignature" />
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie"/>
</ruleset>
5 changes: 3 additions & 2 deletions .phpmd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
</rule>
<!--End of CodeSize RuleSets-->

<!--Start of Controlversial RuleSets-->
<!--Start of Controversial RuleSets-->
<rule ref="rulesets/controversial.xml">
<exclude name="CamelCaseClassName" />
<exclude name="CamelCasePropertyName" />
<exclude name="CamelCaseMethodName" />
<exclude name="CamelCaseParameterName" />
<exclude name="CamelCaseVariableName" />
</rule>
<!--End of Controlversial RuleSets-->
<!--End of Controversial RuleSets-->

<rule ref="rulesets/design.xml"/>

Expand All @@ -58,4 +58,5 @@
<rule ref="rulesets/unusedcode.xml"/>

<exclude-pattern>*/genesisgateway/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
</ruleset>
125 changes: 125 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
emerchantpay Gateway Module for OpenCart
========================================
[![Software License](https://img.shields.io/badge/license-GPL-green.svg?style=flat)](http://opensource.org/licenses/gpl-2.0.php)

This is a Payment Module for OpenCart, that gives you the ability to process payments through emerchantpay's Payment Gateway - Genesis.

Requirements
------------

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

GenesisPHP Requirements
Expand Down Expand Up @@ -135,4 +136,22 @@ _Note_: If you have trouble with your credentials or terminal configuration, get

You're now ready to process payments through our gateway.

Development
------------
* Install dev packages
```shell
composer install
```
* Run PHP Code Sniffer
```shell
composer php-cs
```
* Run PHP Mess Detector
```shell
composer php-md
```
* Pack installation archive (Linux or macOS only)
```shell
composer pack
```
[support]: mailto:tech-support@emerchantpay.net
3 changes: 1 addition & 2 deletions admin/controller/payment/emerchantpay_checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ class EmerchantpayCheckout extends BaseController
*
* @return bool
*/
protected function isModuleRequiresSsl(): bool
{
protected function isModuleRequiresSsl(): bool {
return false;
}
}
20 changes: 6 additions & 14 deletions admin/controller/payment/emerchantpay_direct.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ class EmerchantpayDirect extends BaseController
*
* @param $registry
*/
public function __construct($registry)
{
public function __construct($registry) {
parent::__construct($registry);
// TODO array_push with single element
array_push($this->error_field_key_list, 'token');
Expand All @@ -52,24 +51,17 @@ public function __construct($registry)
*
* @return bool
*/
protected function isModuleRequiresSsl(): bool
{
protected function isModuleRequiresSsl(): bool {
return true;
}

/**
* Ensure that the current user has permissions to see/modify this module
*
* @return bool
* @return void
*/
protected function validate(): bool
{
parent::validate();

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

return !$this->error;
protected function validateRequiredFields(?array $required_fields = []): void {
$required_fields["{$this->module_name}_async_order_status_id"] = 'order_async_status';
parent::validateRequiredFields($required_fields);
}
}
1 change: 1 addition & 0 deletions admin/language/en-gb/payment/emerchantpay_direct.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
// Help
$_['help_total'] = 'Minimum Order Amount required, in order to activate this payment method.';
$_['help_sandbox'] = 'Use Sandbox (Test) or Production (Live) environment.';
$_['help_token'] = 'This is your Gateway token. If you do not have a token, contact tech-support@emerchantpay.com to enable Smart Router for your account.';
$_['help_order_status'] = 'Order status for successfully completed transactions';
$_['help_async_order_status'] = 'Order status for initiated asynchronous (3D) transaction';
$_['help_failure_order_status'] = 'Order status for failed transactions';
Expand Down
38 changes: 35 additions & 3 deletions admin/model/payment/emerchantpay/base_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@

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

use Genesis\API\Constants\Endpoints;
use Genesis\API\Constants\Environments;
use Genesis\API\Constants\Transaction\Parameters\ScaExemptions;
use Genesis\Config;
use Genesis\Exceptions\InvalidArgument;
use Opencart\System\Engine\Model;

/**
Expand All @@ -35,15 +39,14 @@ class BaseModel extends Model
*
* @var string
*/
protected $module_version = '1.1.4';
protected $module_version = '1.1.5';

/**
* Returns formatted array with available SCA Exemptions
*
* @return array
*/
public function getScaExemptions(): array
{
public function getScaExemptions(): array {
$data = [];
$sca_exemptions = [
ScaExemptions::EXEMPTION_LOW_RISK => 'Low risk',
Expand All @@ -59,4 +62,33 @@ public function getScaExemptions(): array

return $data;
}

/**
* Bootstrap Genesis Library
*
* @return void
*
* @throws InvalidArgument
*/
protected function bootstrap(): void {
if (!class_exists('\Genesis\Genesis', false)) {
include DIR_STORAGE . 'vendor/genesisgateway/genesis_php/vendor/autoload.php';
}

Config::setEndpoint(
Endpoints::EMERCHANTPAY
);

Config::setUsername(
$this->config->get("{$this->module_name}_username")
);

Config::setPassword(
$this->config->get("{$this->module_name}_password")
);

Config::setEnvironment(
$this->config->get("{$this->module_name}_sandbox") ? Environments::STAGING : Environments::PRODUCTION
);
}
}
Loading

0 comments on commit daa4715

Please sign in to comment.