Skip to content

Commit

Permalink
Merge pull request #10 from bayonetio/missing-minor-fixes
Browse files Browse the repository at this point in the history
Adds missing standard fix and tweaks
  • Loading branch information
imran-arshad authored Jan 4, 2021
2 parents 4f57602 + d90b6e9 commit 8130ad3
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Helper/DirectQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function customQuery($table, $requestedValue, $whereConditions)
if ($whereConditions) {
foreach ($whereConditions as $key => $value) {
if ($key === 'decision') {
$select = $select->where("o.$key != ?", $value);
$select = $select->where("o.$key != ? OR o.$key is NULL", $value);
} else {
$select = $select->where("o.$key = ?", $value);
}
Expand Down
13 changes: 9 additions & 4 deletions Helper/Order/OrderHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ protected function generateAddress($address)

$generatedAddress = [];
$street = $address->getStreet();
$generatedAddress['line_1'] = ($street !== null && array_key_exists('0', $street)) ? $street['0'] : null;
$generatedAddress['line_2'] = ($street !== null && array_key_exists('1', $street)) ? $street['1'] : null;
$generatedAddress['line_1'] = ($street !== null && isset($street['0'])) ? $street['0'] : null;
$generatedAddress['line_2'] = ($street !== null && isset($street['1'])) ? $street['1'] : null;
$generatedAddress['city'] = $address->getCity();
$generatedAddress['state'] = $address->getRegion();
$generatedAddress['country'] = $this->convertCountryCode($address->getCountryId());
Expand Down Expand Up @@ -276,7 +276,7 @@ private function checkForCard($paymentGatewayCode, $gateway)
$ccCodes = ['cc', 'card', 'tarjeta'];

if (strpos($paymentGatewayCode, 'stripe') !== false) {
if (array_key_exists('save_card', $this->getOrder()->getPayment()->getAdditionalInformation())) {
if (isset($this->getOrder()->getPayment()->getAdditionalInformation()['save_card'])) {
$paymentDetails = $this->mapPaymentDetails($gateway);
} elseif (strpos($paymentGatewayCode, 'oxxo') !== false) {
$paymentDetails['payment_method'] = 'offline';
Expand Down Expand Up @@ -311,6 +311,7 @@ private function mapPaymentDetails($paymentGateway)
switch ($paymentGateway) {
case 'conekta':
$paymentDetails['payment_gateway'] = 'conekta';
$paymentDetails['payment_method'] = 'card';
if (isset($this->getOrder()->getPayment()->getAdditionalInformation()['additional_data']['cc_bin']) &&
isset($this->getOrder()->getPayment()->getAdditionalInformation()['additional_data']['cc_last_4'])) {
$paymentDetails['card_bin'] = $this->getOrder()->getPayment()->getAdditionalInformation()['additional_data']['cc_bin'];
Expand Down Expand Up @@ -397,7 +398,11 @@ protected function getTransactionTime($requestType)
{
if ($requestType === 'consulting') {
$quote = $this->quoteRepository->get($this->getOrder()->getQuoteId());
return strtotime($quote->getData('updated_at'));
if ($quote->getData('updated_at') !== null) {
return strtotime($quote->getData('updated_at'));
} elseif ($quote->getData('created_at') !== null) {
return strtotime($quote->getData('created_at'));
}
} elseif ($requestType === 'backfill') {
return strtotime($this->getOrder()->getData('created_at'));
}
Expand Down
24 changes: 23 additions & 1 deletion Observer/OrderUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,28 @@ public function execute(\Magento\Framework\Event\Observer $observer)
$whereConditions
);

if (!$bayonetId || !$trackingId) {
if (!$bayonetId) {
return;
}

if (!$trackingId) {
$currentOrderId = $this->directQuery->customQuery(
'bayonet_antifraud_orders',
'order_id',
[
'bayonet_id' => $bayonetId
]
);

if (!$currentOrderId) {
$bayonetOrder = $this->bayonetOrderFactory->create();
$orderData = [
'bayonet_id' => $bayonetId,
'order_id' => $order->getId()
];
$bayonetOrder->setData($orderData);
$bayonetOrder->save();
}
return;
}

Expand Down Expand Up @@ -121,6 +142,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
$bayonetOrder->setData($orderData);
$bayonetOrder->save();
} catch (\Exception $e) {
return;
}
}
}
3 changes: 1 addition & 2 deletions README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ El módulo actualmente soporta las siguientes pasarelas de pago:

## Instalación

### Instalación Usando el Back Office de Magento
### Instalación Usando el Marketplace de Magento

Puedes seguir las instrucciones que se encuentran en [https://devdocs.magento.com/guides/v2.3/comp-mgr/extens-man/extensman-main-pg.html](https://devdocs.magento.com/guides/v2.3/comp-mgr/extens-man/extensman-main-pg.html)

Expand All @@ -46,7 +46,6 @@ Deberás ir a la raíz de tu directorio de Magento 2, una vez que estés ahí, e

```bash
composer require bayonetio/bayonet-magento # (*)
composer install
php bin/magento module:enable Bayonet_BayonetAntiFraud --clear-static-content
php bin/magento setup:upgrade
php bin/magento setup:di:compile
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The module currently supports the following payment gateways:

## Installation

### Installation Using the Magento Back Office
### Installation Using the Magento Marketplace

You can follow Magento's instruction provided at
[https://devdocs.magento.com/guides/v2.3/comp-mgr/extens-man/extensman-main-pg.html](https://devdocs.magento.com/guides/v2.3/comp-mgr/extens-man/extensman-main-pg.html)
Expand All @@ -46,7 +46,6 @@ You should go to your Magento 2 root directory, and once you are there, run the

```bash
composer require bayonetio/bayonet-magento # (*)
composer install
php bin/magento module:enable Bayonet_BayonetAntiFraud --clear-static-content
php bin/magento setup:upgrade
php bin/magento setup:di:compile
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"magento/framework": "100.1.*|101.0.*|102.0.*|103.0.*"
},
"type": "magento2-module",
"version": "1.0.0",
"version": "1.0.1",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Bayonet_BayonetAntiFraud" setup_version="1.0.0">
<module name="Bayonet_BayonetAntiFraud" setup_version="1.0.1">
<sequence>
<module name="Magento_Sales"/>
</sequence>
Expand Down

0 comments on commit 8130ad3

Please sign in to comment.