Skip to content

Commit

Permalink
Merge pull request #25 from bayonetio/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ilugobayo authored Feb 15, 2021
2 parents 6d838c9 + c23b1a3 commit 267dfef
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 24 deletions.
8 changes: 4 additions & 4 deletions Controller/Adminhtml/BayonetBlocklist/ListAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function execute()
$resultBlock->reason_code,
$resultBlock->reason_message
);
$this->messageManager->addSuccess(__('Customer added to blocklist'));
$this->messageManager->addSuccess(__('Email added to blocklist'));
return $resultRedirect->setPath('*/*/');
} else {
$this->messageManager->addError(__(
Expand All @@ -101,7 +101,7 @@ public function execute()
$resultBlock->reason_code,
$resultBlock->reason_message
);
$this->messageManager->addSuccess(__('Customer removed from blocklist'));
$this->messageManager->addSuccess(__('Email removed from blocklist'));
return $resultRedirect->setPath('*/*/');
} else {
$this->messageManager->addError(__(
Expand All @@ -123,7 +123,7 @@ public function execute()
);
$resultWhite = $this->addWhite($requestBody);
if (isset($resultWhite) && (int)$resultWhite->reason_code === 0) {
$this->messageManager->addSuccess(__('Customer added to whitelist'));
$this->messageManager->addSuccess(__('Email added to whitelist'));
$this->updateListRow(
$blocklistId,
1,
Expand Down Expand Up @@ -154,7 +154,7 @@ public function execute()
$resultWhite->reason_code,
$resultWhite->reason_message
);
$this->messageManager->addSuccess(__('Customer removed from whitelist'));
$this->messageManager->addSuccess(__('Email removed from whitelist'));
return $resultRedirect->setPath('*/*/');
} else {
$this->messageManager->addError(__(
Expand Down
17 changes: 17 additions & 0 deletions Model/BayonetOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class BayonetOrder extends AbstractModel

const API_MODE_SANDBOX = 0;
const API_MODE_LIVE = 1;
const DECISION_ACCEPT = 'accept';
const DECISION_REVIEW = 'review';
const DECISION_DECLINE = 'decline';

public function __construct(
Context $context,
Expand Down Expand Up @@ -69,4 +72,18 @@ public function getAvailableApiModes()
{
return [self::API_MODE_SANDBOX => __('Sandbox (test)'), self::API_MODE_LIVE => __('Live (production)')];
}

/**
* Prepares available decisions for the listing grid
*
* @return array
*/
public function getAvailableDecisions()
{
return [
self::DECISION_ACCEPT => __('ACCEPT'),
self::DECISION_REVIEW => __('REVIEW'),
self::DECISION_DECLINE => __('DECLINE')
];
}
}
38 changes: 38 additions & 0 deletions Model/BayonetOrder/Source/Decision.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Bayonet\BayonetAntiFraud\Model\BayonetOrder\Source;

use Magento\Framework\Data\OptionSourceInterface;

/**
* Class Decision.
* Used to map the decisions in the Bayonet Orders custom grid in the
* Admin dashboard
*/
class Decision implements OptionSourceInterface
{
protected $bayonetOrder;

public function __construct(\Bayonet\BayonetAntiFraud\Model\BayonetOrder $bayonetOrder)
{
$this->bayonetOrder = $bayonetOrder;
}

/**
* Get options
*
* @return array
*/
public function toOptionArray()
{
$availableOptions = $this->bayonetOrder->getAvailableDecisions();
$options = [];
foreach ($availableOptions as $key => $value) {
$options[] = [
'label' => $value,
'value' => $key,
];
}
return $options;
}
}
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.4",
"version": "1.0.5",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
14 changes: 10 additions & 4 deletions i18n/en_US.csv
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"Bayonet Anti-Fraud","Bayonet Anti-Fraud"
"Bayonet Anti-Fraud Blocklist/Whitelist","Bayonet Anti-Fraud Blocklist/Whitelist"
"Customer added to blocklist","Customer added to blocklist"
"Email added to blocklist","Email added to blocklist"
"An error ocurred while trying to add to the blocklist. Please try again","An error ocurred while trying to add to the blocklist. Please try again"
"Customer removed from blocklist","Customer removed from blocklist"
"Email removed from blocklist","Email removed from blocklist"
"An error ocurred while trying to remove from the blocklist. Please try again","An error ocurred while trying to remove from the blocklist. Please try again"
"Customer added to whitelist","Customer added to whitelist"
"Email added to whitelist","Email added to whitelist"
"An error ocurred while trying to add to the whitelist. Please try again","An error ocurred while trying to add to the whitelist. Please try again"
"Customer removed from whitelist","Customer removed from whitelist"
"Email removed from whitelist","Email removed from whitelist"
"An error ocurred while trying to remove from the whitelist. Please try again","An error ocurred while trying to remove from the whitelist. Please try again"
"The API key for that API mode has not been added yet. Please add your key and try again","The API key for that API mode has not been added yet. Please add your key and try again"
"Orders Processed by Bayonet Anti-Fraud","Orders Processed by Bayonet Anti-Fraud"
Expand Down Expand Up @@ -109,3 +109,9 @@ Whitelist,Whitelist
Decision,Decision
"Triggered Rules","Triggered Rules"
Created,Created
accept,ACCEPT
review,REVIEW
decline,DECLINE
ACCEPT,ACCEPT
REVIEW,REVIEW
DECLINE,DECLINE
19 changes: 12 additions & 7 deletions i18n/es_ES.csv
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"Bayonet Anti-Fraud","Bayonet Anti-Fraud"
"Bayonet Anti-Fraud Blocklist/Whitelist","Lista de Bloqueo/Aprobación de Bayonet Anti-Fraud"
"Customer added to blocklist","Cliente agregado a lista de bloqueo"
"Email added to blocklist","Correo electrónico agregado a lista de bloqueo"
"An error ocurred while trying to add to the blocklist. Please try again","Un error ocurrió al intentar agregar el cliente a la lista de bloqueo. Por favor intenta de nuevo"
"Customer removed from blocklist","Cliente removido de la lista de bloqueo"
"Email removed from blocklist","Correo electrónico removido de la lista de bloqueo"
"An error ocurred while trying to remove from the blocklist. Please try again","Un error ocurrió al intentar remover el cliente de la lista de bloqueo. Por favor intenta de nuevo"
"Customer added to whitelist","Cliente agregado a la lista de aceptación"
"Email added to whitelist","Correo electrónico agregado a la lista de aceptación"
"An error ocurred while trying to add to the whitelist. Please try again","Un error ocurrió al intentar agregar el cliente a la lista de aceptación. Por favor intenta de nuevo"
"Customer removed from whitelist","Customer removed from whitelist"
"Email removed from whitelist","Correo electrónico removed from whitelist"
"An error ocurred while trying to remove from the whitelist. Please try again","Un error ocurrió al intentar remover el cliente de la lista de aceptación. Por favor intenta de nuevo"
"The API key for that API mode has not been added yet. Please add your key and try again","La llave de API para este modo de API no ha sido agregada aún. Por favor agrega tu llave e intenta de nuevo"
"Orders Processed by Bayonet Anti-Fraud","Ordenes Procesadas por Bayonet Anti-Fraud"
Expand Down Expand Up @@ -38,7 +38,7 @@ Added,Agregado
"Information for Bayonet Anti-Fraud","Información para Bayonet Anti-Fraud"
"ID of Order:","ID de orden:"
"Bayonet Tracking ID:","Bayonet Tracking ID:"
"API Call Status:","Estatus de la Llama al API:"
"API Call Status:","Estatus de la Llamada al API:"
Decision:,Decisión:
"Triggered Rules:","Reglas Disparadas:"
"Orders Processed by Bayonet","Ordenes Procesadas por Bayonet"
Expand All @@ -59,7 +59,7 @@ Blocklist/Whitelist,Lista de Bloqueo/Aceptación
In order to be able to use Bayonet in Live Mode properly, you must add both your IP address and your domain to the whitelist in <a href=""https://bayonet.io/login"" target=""_blank"" rel=""noopener noreferrer"">Bayonet's Console</a>.
This is located in the <a href=""https://bayonet.io/developers/setup"" target=""_blank"" rel=""noopener noreferrer"">Setup section</a>, the same place where you get your API keys.
<br><br>
If you need any support regarding this module, you can either send a mail to <a href=""mailto:soporte@bayonet.io"">soporte@bayonet.io</a> or contact us via Intercom on our <a href=""https://bayonet.io/"" target=""_blank"" rel=""noopener noreferrer"">Website</a>.
If you need any support regarding this module, you can either send a mail to <a href=""mailto:magento@bayonet.io"">magento@bayonet.io</a> or contact us via Intercom on our <a href=""https://bayonet.io/"" target=""_blank"" rel=""noopener noreferrer"">Website</a>.
<br><br>
","
<b>IMPORTANTE - LEE EL MANUAL</b>
Expand Down Expand Up @@ -107,4 +107,9 @@ Whitelist,Lista de Aceptación
Decision,Decisión
"Triggered Rules","Reglas Disparadas"
Created,Creado
"View Order Details","Ver Detalles de Orden"
accept,ACEPTAR
review,REVISAR
decline,DECLINAR
ACCEPT,ACEPTAR
REVIEW,REVISAR
DECLINE,DECLINAR
19 changes: 12 additions & 7 deletions i18n/es_MX.csv
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"Bayonet Anti-Fraud","Bayonet Anti-Fraud"
"Bayonet Anti-Fraud Blocklist/Whitelist","Lista de Bloqueo/Aprobación de Bayonet Anti-Fraud"
"Customer added to blocklist","Cliente agregado a lista de bloqueo"
"Email added to blocklist","Correo electrónico agregado a lista de bloqueo"
"An error ocurred while trying to add to the blocklist. Please try again","Un error ocurrió al intentar agregar el cliente a la lista de bloqueo. Por favor intenta de nuevo"
"Customer removed from blocklist","Cliente removido de la lista de bloqueo"
"Email removed from blocklist","Correo electrónico removido de la lista de bloqueo"
"An error ocurred while trying to remove from the blocklist. Please try again","Un error ocurrió al intentar remover el cliente de la lista de bloqueo. Por favor intenta de nuevo"
"Customer added to whitelist","Cliente agregado a la lista de aceptación"
"Email added to whitelist","Correo electrónico agregado a la lista de aceptación"
"An error ocurred while trying to add to the whitelist. Please try again","Un error ocurrió al intentar agregar el cliente a la lista de aceptación. Por favor intenta de nuevo"
"Customer removed from whitelist","Customer removed from whitelist"
"Email removed from whitelist","Correo electrónico removed from whitelist"
"An error ocurred while trying to remove from the whitelist. Please try again","Un error ocurrió al intentar remover el cliente de la lista de aceptación. Por favor intenta de nuevo"
"The API key for that API mode has not been added yet. Please add your key and try again","La llave de API para este modo de API no ha sido agregada aún. Por favor agrega tu llave e intenta de nuevo"
"Orders Processed by Bayonet Anti-Fraud","Ordenes Procesadas por Bayonet Anti-Fraud"
Expand Down Expand Up @@ -38,7 +38,7 @@ Added,Agregado
"Information for Bayonet Anti-Fraud","Información para Bayonet Anti-Fraud"
"ID of Order:","ID de orden:"
"Bayonet Tracking ID:","Bayonet Tracking ID:"
"API Call Status:","Estatus de la Llama al API:"
"API Call Status:","Estatus de la Llamada al API:"
Decision:,Decisión:
"Triggered Rules:","Reglas Disparadas:"
"Orders Processed by Bayonet","Ordenes Procesadas por Bayonet"
Expand All @@ -59,7 +59,7 @@ Blocklist/Whitelist,Lista de Bloqueo/Aceptación
In order to be able to use Bayonet in Live Mode properly, you must add both your IP address and your domain to the whitelist in <a href=""https://bayonet.io/login"" target=""_blank"" rel=""noopener noreferrer"">Bayonet's Console</a>.
This is located in the <a href=""https://bayonet.io/developers/setup"" target=""_blank"" rel=""noopener noreferrer"">Setup section</a>, the same place where you get your API keys.
<br><br>
If you need any support regarding this module, you can either send a mail to <a href=""mailto:soporte@bayonet.io"">soporte@bayonet.io</a> or contact us via Intercom on our <a href=""https://bayonet.io/"" target=""_blank"" rel=""noopener noreferrer"">Website</a>.
If you need any support regarding this module, you can either send a mail to <a href=""mailto:magento@bayonet.io"">magento@bayonet.io</a> or contact us via Intercom on our <a href=""https://bayonet.io/"" target=""_blank"" rel=""noopener noreferrer"">Website</a>.
<br><br>
","
<b>IMPORTANTE - LEE EL MANUAL</b>
Expand Down Expand Up @@ -107,4 +107,9 @@ Whitelist,Lista de Aceptación
Decision,Decisión
"Triggered Rules","Reglas Disparadas"
Created,Creado
"View Order Details","Ver Detalles de Orden"
accept,ACEPTAR
review,REVISAR
decline,DECLINAR
ACCEPT,ACEPTAR
REVIEW,REVISAR
DECLINE,DECLINAR
2 changes: 1 addition & 1 deletion view/adminhtml/templates/tab/view/my_order_info.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</tr>
<tr>
<th><?= $block->escapeHtml(__('Decision:')) ?></th>
<td><?= $block->escapeHtml($block->getDecision()); ?></td>
<td><?= $block->escapeHtml(__($block->getDecision())); ?></td>
</tr>
<tr>
<th><?= $block->escapeHtml(__('Triggered Rules:')) ?></th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,12 @@
</column>
<column name="decision">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Bayonet\BayonetAntiFraud\Model\BayonetOrder\Source\Decision</item>
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item>
<item name="editor" xsi:type="string">select</item>
<item name="dataType" xsi:type="string">select</item>
<item name="label" xsi:type="string" translate="true">Decision</item>
</item>
</argument>
Expand Down

0 comments on commit 267dfef

Please sign in to comment.