Skip to content

Commit

Permalink
Release of 3.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
danielcivit authored Mar 19, 2021
2 parents 34551e0 + 827d817 commit 69700e2
Show file tree
Hide file tree
Showing 29 changed files with 635 additions and 83 deletions.
29 changes: 27 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,34 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

***

## 3.9.0
Release date: March, 19th 2021

### Added
+ PLGOPNS-374: Add generic gateway

### Changed
+ PLGOPNS-384: Upgrade PHP-SDK to 5.1.0

***

## 3.8.0
Release date: February, 11th 2021

### Fixed
+ PLGOPNS-382: Fix bug to get the proper settings in a multi store OpenCart site

***

## 3.7.0
Release date: February, 9th 2021

### Fixed
+ PLGOPNS-381: Fix percentage coupon applied before taxes

***

## 3.6.0
Release date: February, 8th 2021
Expand All @@ -35,6 +49,7 @@ Release date: February, 8th 2021
+ PLGOPNS-375: Remove unneded code related with the shopping cart of the transaction
+ PLGOPNS-378: Fix bug for fixed coupons applied before taxes

***

## 3.5.0
Release date: December, 18th 2020
Expand All @@ -54,6 +69,7 @@ Release date: December, 18th 2020
+ PLGOPNS-366: Fix bug, gift voucher items should pass to the transaction as negative amounts
+ PLGOPNS-371: Fix filter per customer group; when customer is not logged

***

## 3.4.0
Release date: November, 19th 2020
Expand All @@ -67,6 +83,8 @@ Release date: November, 19th 2020
### Changed
+ PLGOPNS-257: Include in support tab the contact details of international offices

***

## 3.3.0
Release date: October, 13th 2020

Expand All @@ -78,6 +96,8 @@ Release date: October, 13th 2020
+ PLGOPNS-303: Improve iDEAL issuer selection list
+ PLGOPNS-245: Improve the alignment of payment methods logos in checkout page

***

## 3.2.0
Release date: September, 17th 2020

Expand All @@ -88,6 +108,8 @@ Release date: September, 17th 2020
+ PLGOPNS-295: Add getEventByCode function, which does not exist prior to OC 3.0.2
+ PLGOPNS-284: Fix placeholder for 'lifetime payment link' field

***

## 3.1.0
Release date: September, 14th 2020

Expand All @@ -97,6 +119,8 @@ Release date: September, 14th 2020
+ PLGOPNS-253: Validate the field lifetime of payment link to avoid negative number
+ PLGOPNS-252: Improve description for each payment method on backoffice

***

## 3.0.0
Release date: September, 7th 2020

Expand All @@ -118,7 +142,6 @@ Release date: September, 7th 2020
+ Add support to update order status as cancelled or expired from the admin
+ Add support for payment method in3, CBC


### Fixed
+ PLGOPNS-226: Tax issue
+ PLGOPNS-212: Fix PHP DocBlock declaration and correct @author property
Expand All @@ -134,14 +157,14 @@ Release date: September, 7th 2020
+ Fix support for taxes
+ Fix support for coupons


### Removed
+ PLGOPNS-228: Remove payment methods BABYGIFTCARD, EROTIEKBON.
+ PLGOPNS-225: Reorder the directories to put MultiSafepay.combined.php in the OpenCart library folder
+ PLGOPNS-147: Remove FastCheckout code
+ PLGOPNS-174: Remove unsupported giftcards
+ Remove VqMod dependency

***

## 2.3.0
Release date: April 2nd, 2020
Expand Down Expand Up @@ -202,6 +225,8 @@ Release date: June 15th, 2018
+ PLGOPNS-74: MultiStore is now correctly supported
+ PLGOPNS-75: Configuration form is now applied for geozone and min/max amount

***

## 2.1.0
Release date: November 13th, 2017
### Improvements
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"php-http/guzzle6-adapter": "^2.0",
"guzzlehttp/psr7": "^1.6",
"http-interop/http-factory-guzzle": "^1.0",
"multisafepay/php-sdk": "^4.0"
"multisafepay/php-sdk": "^5.0"
},
"require-dev": {
"phpunit/phpunit" : "^7.5",
Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<exclude-pattern>*/src/system/library/multisafepay.php</exclude-pattern>
<properties>
<!-- goal is 10 -->
<property name="maxCount" value="65"/>
<property name="maxCount" value="70"/>
</properties>
</rule>

Expand Down
129 changes: 101 additions & 28 deletions src/admin/controller/extension/payment/multisafepay.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ public function index() {

$fields = $this->getFields();
$data['payment_methods_fields_values'] = $this->getPaymentMethodsFieldsValues($data['store_id']);

foreach ($fields as $field) {
if (isset($this->request->post[$field])) {
$data[$field] = $this->request->post[$field];
Expand All @@ -187,13 +186,92 @@ public function index() {
}
}

// Generic
$data['payment_generic_fields_values'] = $this->getPaymentGenericFieldsValues($data['store_id']);

$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->load->view($this->route . $this->view_extension_file, $data));
}


/**
* Define the common fields for each payment method
*
* @return array
*
*/
private function getPaymentGenericFields() {
return array(
'name',
'code',
'image',
'require_shopping_cart'
);
}

/**
* Return the values of fields for each generic methods keys
*
* @param int $store_id
* @return array
*
*/
private function getPaymentGenericFieldsValues($store_id = 0) {
$this->registry->set('multisafepay', new Multisafepay($this->registry));
$generic_gateways = $this->multisafepay->getGatewayByType('generic');
$fields = array();
foreach($generic_gateways as $gateway) {
$fields = $this->extractGenericFieldsByGateway($gateway, $fields, $store_id);
}
return $fields;
}

/**
* Extract the values of fields for each generic methods keys for each gateway
*
* @param string $gateway
* @param array $fields
* @param int $store_id
* @return array
*
*/
// phpcs:ignore ObjectCalisthenics.Metrics.MaxNestingLevel
private function extractGenericFieldsByGateway($gateway, $fields, $store_id) {
$this->load->model('tool/image');
$payment_fields = $this->getPaymentGenericFields();
foreach ($payment_fields as $payment_field) {
if ($payment_field !== 'image' && isset($this->request->post[$this->key_prefix . 'multisafepay_'.$gateway['code'].'_'.$payment_field])) {
$fields[$gateway['code']][$payment_field] = $this->request->post[$this->key_prefix . 'multisafepay_'.$gateway['code'].'_'.$payment_field];
continue;
}
if ($payment_field !== 'image' && !isset($this->request->post[$this->key_prefix . 'multisafepay_'.$gateway['code'].'_'.$payment_field])) {
$fields[$gateway['code']][$payment_field] = $this->{$this->model_call}->getSettingValue($this->key_prefix . 'multisafepay_'.$gateway['code'].'_'.$payment_field, $store_id);
continue;
}
if ($payment_field === 'image' && isset($this->request->post[$this->key_prefix . 'multisafepay_'.$gateway['code'].'_'.$payment_field])) {
$fields[$gateway['code']][$payment_field] = $this->request->post[$this->key_prefix . 'multisafepay_'.$gateway['code'].'_'.$payment_field];
$fields[$gateway['code']]['thumb'] = $this->model_tool_image->resize($this->request->post[$this->key_prefix . 'multisafepay_'.$gateway['code'].'_'.$payment_field], 100, 100);
continue;
}
if ($payment_field === 'image' && !isset($this->request->post[$this->key_prefix . 'multisafepay_'.$gateway['code'].'_'.$payment_field])) {
$fields[$gateway['code']][$payment_field] = $this->{$this->model_call}->getSettingValue($this->key_prefix . 'multisafepay_'.$gateway['code'].'_'.$payment_field, $store_id);
$image = $this->{$this->model_call}->getSettingValue($this->key_prefix . 'multisafepay_'.$gateway['code'].'_'.$payment_field, $store_id);
if($image) {
$fields[$gateway['code']]['thumb'] = $this->model_tool_image->resize($image, 100, 100);
}
if(!$image) {
$fields[$gateway['code']]['thumb'] = $this->model_tool_image->resize('no_image.png', 100, 100);
}
continue;
}
}
return $fields;
}


/**
* Return error message is PHP Version is not supported by the extension
*
Expand Down Expand Up @@ -530,29 +608,6 @@ protected function validate() {
$this->error['api_key'] = $this->language->get('error_empty_api_key');
}

$this->registry->set('multisafepay', new Multisafepay($this->registry));
$gateways = $this->multisafepay->getGateways();
$enviroment = (empty($this->request->post[$this->key_prefix . 'multisafepay_environment'])) ? true : false;
$enviroment_key = (empty($this->request->post[$this->key_prefix . 'multisafepay_environment'])) ? '' : 'sandbox_';
$api_key = $this->request->post[$this->key_prefix . 'multisafepay_' . $enviroment_key . 'api_key'];
$available_gateways = $this->multisafepay->getAvailableGateways($enviroment, $api_key);

if(!$available_gateways) {
$this->error[$enviroment_key . 'api_key'] = $this->language->get('error_invalid_api_key');
$this->error['warning'] = $this->language->get('error_check_form');
return !$this->error;
}

foreach($gateways as $gateway) {
if ($this->request->post[$this->key_prefix . 'multisafepay_'.$gateway['code'].'_status'] && $this->isGatewayAvailable($gateway, $available_gateways) !== null) {
$this->error['gateway'][$gateway['code']] = $this->isGatewayAvailable($gateway, $available_gateways);
}
}

if(!empty($this->error['gateway'])) {
$this->error['warning'] = $this->language->get('error_gateways_not_available');
}

if (!isset($this->request->post[$this->key_prefix . 'multisafepay_days_active']) || $this->request->post[$this->key_prefix . 'multisafepay_days_active'] < 1) {
$this->error['days_active'] = $this->language->get('error_days_active');
}
Expand Down Expand Up @@ -757,16 +812,14 @@ public function refundOrder() {
$this->registry->set('multisafepay', new Multisafepay($this->registry));

$msp_order = $this->multisafepay->getAdminOrderObject($this->request->get['order_id']);
$order_info = $this->multisafepay->getAdminOrderInfo($this->request->get['order_id']);
$data['status'] = $msp_order->getStatus();
$refund_request = $this->multisafepay->createRefundRequestObject($msp_order);
$refund_request->addMoney($msp_order->getMoney());
$description = sprintf($this->language->get('text_description_refunded'), $this->request->get['order_id'], date($this->language->get('datetime_format')));
$refund_request->addDescriptionText($description);

$payment_details = $msp_order->getPaymentDetails();
$gateway_id = $payment_details->getType();
$gateways_with_shopping_cart = array('AFTERPAY', 'KLARNA', 'EINVOICE', 'PAYAFTER', 'IN3');
if(in_array($gateway_id, $gateways_with_shopping_cart)) {
if($this->refundWithShoppingCart($order_info, $msp_order)) {
$msp_shopping_cart = $msp_order->getShoppingCart();
$msp_shopping_cart_data = $msp_shopping_cart->getData();
foreach ($msp_shopping_cart_data['items'] as $msp_cart_item) {
Expand All @@ -793,6 +846,26 @@ public function refundOrder() {
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));

}

/**
* Check if ShoppingCart is required to process a refund
*
* @param array $order_info
* @param \MultiSafepay\Api\Transactions\TransactionResponse $msp_order
*/
private function refundWithShoppingCart($order_info, $msp_order) {

if($order_info['payment_code'] === 'multisafepay/generic' && $this->{$this->model_call}->getSettingValue($this->key_prefix . 'multisafepay_generic_require_shopping_cart', $order_info['store_id'])) {
return true;
}

if($msp_order->requiresShoppingCart()) {
return true;
}

return false;

}

/**
Expand Down
Loading

0 comments on commit 69700e2

Please sign in to comment.