diff --git a/Helper/PurchaseHelper.php b/Helper/PurchaseHelper.php
index 9cdac1a7..adae1dea 100644
--- a/Helper/PurchaseHelper.php
+++ b/Helper/PurchaseHelper.php
@@ -409,19 +409,18 @@ public function getProductImage($product)
*
* The decision request.
*/
- public function getDecisionRequest()
+ public function getDecisionRequest($paymentMethod = null)
{
$decisionRequest = [];
if ($this->configHelper->isScoreOnly()) {
$decisionRequest['paymentFraud'] = 'SCORE';
- } else {
- $configDecision = $this->configHelper->getDecisionRequest();
- $allowedDecisions = ['GUARANTEE', 'SCORE', 'DECISION'];
- $decisionRequest['paymentFraud'] = in_array($configDecision, $allowedDecisions) ?
- $configDecision : 'GUARANTEE';
+ return $decisionRequest;
}
+ $configDecision = $this->configHelper->getDecisionRequest();
+ $decisionRequest['paymentFraud'] = $this->getDecisionForMethod($configDecision, $paymentMethod);
+
return $decisionRequest;
}
@@ -794,6 +793,26 @@ public function makeShipments(Order $order)
return $shipments;
}
+ /**
+ * @param Quote $quote
+ * @return array
+ */
+ public function makeShipmentsFromQuote(Quote $quote)
+ {
+ $shipments = [];
+ $shipment = [];
+ $shippingMethod = $quote->getShippingAddress()->getShippingMethod();
+ $shippingAmount = $quote->getShippingAddress()->getShippingAmount();
+
+ $shipment['shippingMethod'] = $shippingMethod ? $this->makeshippingMethod($shippingMethod) : null;
+ $shipment['shippingPrice'] = is_numeric($shippingAmount) ? floatval($shippingAmount) : null;
+ $shipment['shipper'] = $shippingMethod ? $this->makeShipper($shippingMethod) : null;
+
+ $shipments[] = $shipment;
+
+ return $shipments;
+ }
+
public function makeShipper($shippingMethod)
{
if (is_string($shippingMethod)) {
@@ -1131,7 +1150,7 @@ public function processOrderData($order)
$case['customerOrderRecommendation'] = $this->getCustomerOrderRecommendation();
$case['deviceFingerprints'] = $this->getDeviceFingerprints();
$case['policy'] = $this->makePolicy($order, ScopeInterface::SCOPE_STORES, $order->getStoreId());
- $case['decisionRequest'] = $this->getDecisionRequest();
+ $case['decisionRequest'] = $this->getDecisionRequest($order->getPayment()->getMethod());
$case['sellers'] = $this->getSellers();
$case['tags'] = $this->getTags();
$case['purchase']['checkoutToken'] = uniqid();
@@ -1532,8 +1551,8 @@ public function processQuoteData(Quote $quote, $checkoutPaymentDetails = null, $
$case['customerOrderRecommendation'] = $this->getCustomerOrderRecommendation();
$case['deviceFingerprints'] = $this->getDeviceFingerprints();
$case['policy'] = $this->makePolicy($quote, ScopeInterface::SCOPE_STORES, $quote->getStoreId());
- $case['decisionRequest'] = $this->getDecisionRequest();
- $case['purchase']['checkoutToken'] = uniqid();
+ $case['decisionRequest'] = $this->getDecisionRequest($paymentMethod);
+ $case['purchase']['checkoutToken'] = sha1($this->jsonSerializer->serialize($case));
$positiveAction = $this->configHelper->getConfigData('signifyd/advanced/guarantee_positive_action');
$transactionType = $positiveAction == 'capture' ? 'SALE' : 'AUTHORIZATION';
@@ -1630,6 +1649,7 @@ public function makePurchaseFromQuote(Quote $quote)
}
}
+ $purchase['shipments'] = $this->makeShipmentsFromQuote($quote);
$purchase['orderChannel'] = "WEB";
$purchase['totalPrice'] = $quote->getGrandTotal();
$purchase['currency'] = $quote->getQuoteCurrencyCode();
@@ -1865,6 +1885,44 @@ public function getIsPreAuth($policyName, $paymentMethod)
}
}
+ public function getDecisionForMethod($decision, $paymentMethod)
+ {
+ $isJson = $this->isJson($decision);
+
+ if ($isJson) {
+ if (isset($paymentMethod) === false) {
+ return "GUARANTEE";
+ }
+
+ $configDecisions = $this->jsonSerializer->unserialize($decision);
+
+ foreach ($configDecisions as $configDecision => $method) {
+ if ($this->isDecisionValid($configDecision) === false) {
+ continue;
+ }
+
+ if (in_array($paymentMethod, $method)) {
+ return $configDecision;
+ }
+ }
+
+ return "GUARANTEE";
+ } else {
+ if ($this->isDecisionValid($decision) === false) {
+ return "GUARANTEE";
+ }
+
+ return $decision;
+ }
+ }
+
+ public function isDecisionValid($decision)
+ {
+ $allowedDecisions = ['GUARANTEE', 'SCORE', 'DECISION'];
+
+ return in_array($decision, $allowedDecisions);
+ }
+
public function isJson($string)
{
json_decode($string);
diff --git a/Model/Casedata.php b/Model/Casedata.php
index 527d8da5..696a62ff 100644
--- a/Model/Casedata.php
+++ b/Model/Casedata.php
@@ -512,20 +512,7 @@ public function updateOrder()
$order->setCustomerNoteNotify(true);
$order->setIsInProcess(true);
- if ($enableTransaction) {
- $this->orderResourceModel->save($order);
- $this->invoiceResourceModel->save($invoice);
- } else {
- /** @var \Magento\Framework\DB\Transaction $transactionSave */
- $transactionSave = $this->transactionFactory->create();
- $transactionSave->addObject(
- $invoice
- )->addObject(
- $invoice->getOrder()
- );
-
- $transactionSave->save();
- }
+ $this->handleTransaction($enableTransaction, $order, $invoice);
$this->orderHelper->addCommentToStatusHistory(
$order,
@@ -587,15 +574,7 @@ public function updateOrder()
$invoices = $order->getInvoiceCollection();
if ($invoices->getTotalCount() > 0) {
- foreach ($invoices as $invoice) {
- $creditmemo = $this->creditmemoFactory->createByOrder($order);
- $creditmemo->setInvoice($invoice);
- $this->creditmemoService->refund($creditmemo);
- $this->logger->debug(
- 'Credit memo was created for order: ' . $order->getIncrementId(),
- ['entity' => $order]
- );
- }
+ $this->createInvoicesCreditMemo($invoices, $order);
} else {
$this->holdOrder($order);
$message = "Signifyd: tried to refund, but there is no invoice to add credit memo";
@@ -867,4 +846,35 @@ public function holdOrder($order)
$this->orderResourceModel->save($order);
}
}
+
+ public function handleTransaction($enableTransaction, $order, $invoice)
+ {
+ if ($enableTransaction) {
+ $this->orderResourceModel->save($order);
+ $this->invoiceResourceModel->save($invoice);
+ } else {
+ /** @var \Magento\Framework\DB\Transaction $transactionSave */
+ $transactionSave = $this->transactionFactory->create();
+ $transactionSave->addObject(
+ $invoice
+ )->addObject(
+ $invoice->getOrder()
+ );
+
+ $transactionSave->save();
+ }
+ }
+
+ public function createInvoicesCreditMemo($invoices, $order)
+ {
+ foreach ($invoices as $invoice) {
+ $creditmemo = $this->creditmemoFactory->createByOrder($order);
+ $creditmemo->setInvoice($invoice);
+ $this->creditmemoService->refund($creditmemo);
+ $this->logger->debug(
+ 'Credit memo was created for order: ' . $order->getIncrementId(),
+ ['entity' => $order]
+ );
+ }
+ }
}
diff --git a/Observer/PreAuth.php b/Observer/PreAuth.php
index 7de0a3dc..9470ada9 100644
--- a/Observer/PreAuth.php
+++ b/Observer/PreAuth.php
@@ -20,6 +20,7 @@
use Signifyd\Connect\Model\CasedataFactory;
use Magento\Framework\App\Request\Http as RequestHttp;
use Magento\Framework\Serialize\Serializer\Json as JsonSerializer;
+use Magento\Framework\ObjectManagerInterface;
class PreAuth implements ObserverInterface
{
@@ -88,6 +89,11 @@ class PreAuth implements ObserverInterface
*/
protected $configHelper;
+ /**
+ * @var ObjectManagerInterface
+ */
+ protected $objectManagerInterface;
+
/**
* PreAuth constructor.
* @param Logger $logger
@@ -103,6 +109,7 @@ class PreAuth implements ObserverInterface
* @param RequestHttp $requestHttp
* @param JsonSerializer $jsonSerializer
* @param ConfigHelper $configHelper
+ * @param ObjectManagerInterface $objectManagerInterface
*/
public function __construct(
Logger $logger,
@@ -117,7 +124,8 @@ public function __construct(
CasedataResourceModel $casedataResourceModel,
RequestHttp $requestHttp,
JsonSerializer $jsonSerializer,
- ConfigHelper $configHelper
+ ConfigHelper $configHelper,
+ ObjectManagerInterface $objectManagerInterface
) {
$this->logger = $logger;
$this->purchaseHelper = $purchaseHelper;
@@ -132,6 +140,7 @@ public function __construct(
$this->requestHttp = $requestHttp;
$this->jsonSerializer = $jsonSerializer;
$this->configHelper = $configHelper;
+ $this->objectManagerInterface = $objectManagerInterface;
}
public function execute(Observer $observer)
@@ -153,7 +162,12 @@ public function execute(Observer $observer)
$paymentMethod = null;
$data = $this->requestHttp->getContent();
- $dataArray = $this->jsonSerializer->unserialize($data);
+
+ if (empty($data) === false) {
+ $dataArray = $this->jsonSerializer->unserialize($data);
+ } else {
+ $dataArray = [];
+ }
if (isset($dataArray['paymentMethod']) &&
isset($dataArray['paymentMethod']['method'])
@@ -185,9 +199,49 @@ public function execute(Observer $observer)
if (isset($dataArray['paymentMethod']) &&
isset($dataArray['paymentMethod']['additional_data'])
+ ) {
+ if ($paymentMethod == 'adyen_oneclick' &&
+ isset($dataArray['paymentMethod']['additional_data']['stateData'])
) {
- $checkoutPaymentDetails['cardBin'] =
- $dataArray['paymentMethod']['additional_data']['cardBin'] ?? null;
+ try {
+ $stateData = $this->jsonSerializer
+ ->unserialize($dataArray['paymentMethod']['additional_data']['stateData']);
+
+ /** @var \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest */
+ $paymentRequest = $this->objectManagerInterface->create(
+ \Adyen\Payment\Model\Api\PaymentRequest::class
+ );
+
+ if ($quote->getCustomer()->getId() < 10) {
+ $shopperReference = '00' . $quote->getCustomer()->getId();
+ } elseif ($quote->getCustomer()->getId() >= 10 && $quote->getCustomer()->getId() <= 100) {
+ $shopperReference = '0' . $quote->getCustomer()->getId();
+ } else {
+ $shopperReference = $quote->getCustomer()->getId();
+ }
+
+ $contracts = $paymentRequest->getRecurringContractsForShopper(
+ $shopperReference,
+ $quote->getStoreId()
+ );
+
+ if (isset($stateData['paymentMethod']) &&
+ isset($stateData['paymentMethod']['storedPaymentMethodId'])
+ ) {
+ $storedPaymentMethodId = $stateData['paymentMethod']['storedPaymentMethodId'];
+
+ $checkoutPaymentDetails['cardBin'] =
+ $contracts[$storedPaymentMethodId]['additionalData']['cardBin'] ?? null;
+ } else {
+ $checkoutPaymentDetails['cardBin'] = null;
+ }
+ } catch (\Exception $e) {
+ $checkoutPaymentDetails['cardBin'] = null;
+ }
+ } else {
+ $checkoutPaymentDetails['cardBin'] =
+ $dataArray['paymentMethod']['additional_data']['cardBin'] ?? null;
+ }
$checkoutPaymentDetails['holderName'] =
$dataArray['paymentMethod']['additional_data']['holderName'] ?? null;
diff --git a/Observer/Purchase.php b/Observer/Purchase.php
index f0081ad4..5122bb7e 100644
--- a/Observer/Purchase.php
+++ b/Observer/Purchase.php
@@ -311,9 +311,6 @@ public function execute(Observer $observer, $checkOwnEventsMethods = true)
$checkoutToken = $orderData['purchase']['checkoutToken'];
$caseResponse = $this->purchaseHelper->postCaseToSignifyd($orderData, $order);
- // Initial hold order
- $this->holdOrder($order, $case, $isPassive);
-
if (is_object($caseResponse)) {
$case->setCode($caseResponse->getCaseId());
$case->setMagentoStatus(Casedata::IN_REVIEW_STATUS);
@@ -323,6 +320,9 @@ public function execute(Observer $observer, $checkOwnEventsMethods = true)
$this->casedataResourceModel->save($case);
+ // Initial hold order
+ $this->holdOrder($order, $case, $isPassive);
+
if ($isPassive === false) {
$this->orderResourceModel->save($order);
}
diff --git a/Plugin/Adyen/Payment/Gateway/Request/CheckoutDataBuilder.php b/Plugin/Adyen/Payment/Gateway/Request/CheckoutDataBuilder.php
index 5f22addd..99035b1c 100644
--- a/Plugin/Adyen/Payment/Gateway/Request/CheckoutDataBuilder.php
+++ b/Plugin/Adyen/Payment/Gateway/Request/CheckoutDataBuilder.php
@@ -18,6 +18,7 @@
use Signifyd\Connect\Model\WebhookLink;
use Signifyd\Core\Api\WebhooksApiFactory;
use Signifyd\Models\WebhookFactory;
+use Magento\Store\Model\StoreManagerInterface;
class CheckoutDataBuilder
{
@@ -91,6 +92,11 @@ class CheckoutDataBuilder
*/
protected $logger;
+ /**
+ * @var StoreManagerInterface
+ */
+ protected $storeManagerInterface;
+
/**
* CheckoutDataBuilder constructor.
* @param QuoteResourceModel $quoteResourceModel
@@ -106,6 +112,7 @@ class CheckoutDataBuilder
* @oaram WebhookLink $webhookLink
* @param ConfigHelper $configHelper
* @param Logger $logger
+ * @param StoreManagerInterface $storeManagerInterface
*/
public function __construct(
QuoteResourceModel $quoteResourceModel,
@@ -120,7 +127,8 @@ public function __construct(
WebhookFactory $webhookFactory,
WebhookLink $webhookLink,
ConfigHelper $configHelper,
- Logger $logger
+ Logger $logger,
+ StoreManagerInterface $storeManagerInterface
) {
$this->quoteResourceModel = $quoteResourceModel;
$this->quoteFactory = $quoteFactory;
@@ -135,6 +143,7 @@ public function __construct(
$this->webhookLink = $webhookLink;
$this->configHelper = $configHelper;
$this->logger = $logger;
+ $this->storeManagerInterface = $storeManagerInterface;
}
public function beforeBuild(AdyenCheckoutDataBuilder $subject, array $buildSubject)
@@ -156,10 +165,12 @@ public function afterBuild(AdyenCheckoutDataBuilder $subject, $request)
return $request;
}
+ $storeId = $this->storeManagerInterface->getStore()->getId();
+
$adyenProxyEnabled = $this->scopeConfig->isSetFlag(
'signifyd/proxy/adyen_enable',
'stores',
- $quote->getStoreId()
+ $storeId
);
if ($adyenProxyEnabled === false) {
@@ -207,7 +218,7 @@ public function afterBuild(AdyenCheckoutDataBuilder $subject, $request)
}
if ($this->deviceHelper->isDeviceFingerprintEnabled()) {
- $request['body']['additionalData']['ordersessionId'] =
+ $request['body']['additionalData']['orderSessionId'] =
$this->deviceHelper->generateFingerprint($quote->getId());
}
diff --git a/Plugin/Adyen/Payment/Helper/Data.php b/Plugin/Adyen/Payment/Helper/Data.php
index f594b2b8..8decbbf7 100644
--- a/Plugin/Adyen/Payment/Helper/Data.php
+++ b/Plugin/Adyen/Payment/Helper/Data.php
@@ -9,15 +9,6 @@
class Data
{
- /**
- *
- * @var string[]
- */
- protected $endpoints = [
- \Adyen\Environment::TEST => 'https://checkout-test.adyen.staging.signifyd.com/checkout',
- \Adyen\Environment::LIVE => 'https://checkout-test.adyen.com/checkout'
- ];
-
/**
* @var null|int
*/
@@ -71,17 +62,24 @@ public function beforeInitializeAdyenClient(AdyenHelperData $subject, $storeId =
*/
public function afterInitializeAdyenClient(AdyenHelperData $subject, $client)
{
- $adyenProxyEnabled = $this->scopeConfig->isSetFlag(
+ $storeId = $this->storeManager->getStore()->getId();
+
+ $adyenProxyConfigEnabled = $this->scopeConfig->getValue(
'signifyd/proxy/adyen_enable',
'stores',
- $this->storeId
+ $storeId
);
- $storeId = $this->storeManager->getStore()->getId();
+ $adyenProxyEnabled = $adyenProxyConfigEnabled != 0;
if ($adyenProxyEnabled && $this->configHelper->getEnabledByStoreId($storeId)) {
- $environment = $subject->isDemoMode($this->storeId) ? \Adyen\Environment::TEST : \Adyen\Environment::LIVE;
- $client->getConfig()->set('endpointCheckout', $this->endpoints[$environment]);
+ $environmentReplace = $adyenProxyConfigEnabled == 2 ?
+ ".staging.signifyd.com" : ".signifyd.com";
+
+ $environmentUrl = $client->getConfig()->get('endpointCheckout');
+ $environmentSignifydUrl = str_replace(".com", $environmentReplace, $environmentUrl);
+
+ $client->getConfig()->set('endpointCheckout', $environmentSignifydUrl);
}
return $client;
diff --git a/Setup/Patch/Data/UpdateOrderId.php b/Setup/Patch/Data/UpdateOrderId.php
index 4fd32182..b8e096aa 100644
--- a/Setup/Patch/Data/UpdateOrderId.php
+++ b/Setup/Patch/Data/UpdateOrderId.php
@@ -45,20 +45,24 @@ public function apply()
$salesOrder = $this->schemaSetupInterface->getTable('sales_order');
try {
- $this->schemaSetupInterface->getConnection()->query("UPDATE ". $signifydConnectCase ." JOIN " . $salesOrder . " ON " .
+ $this->schemaSetupInterface->getConnection()->query(
+ "UPDATE ". $signifydConnectCase ." JOIN " . $salesOrder . " ON " .
$signifydConnectCase .".order_increment = " . $salesOrder . ".increment_id SET " .
$signifydConnectCase .".order_id = " . $salesOrder . ".entity_id WHERE " .
- $signifydConnectCase . ".magento_status='complete'");
+ $signifydConnectCase . ".magento_status='complete'"
+ );
} catch (\Exception $e) {
$this->logger->debug('Update order_id on magento status complete failed');
$this->configWriter->save("signifyd/general/upgrade4.3_inconsistency", "setup");
}
try {
- $this->schemaSetupInterface->getConnection()->query("UPDATE ". $signifydConnectCase ." JOIN " . $salesOrder . " ON " .
+ $this->schemaSetupInterface->getConnection()->query(
+ "UPDATE ". $signifydConnectCase ." JOIN " . $salesOrder . " ON " .
$signifydConnectCase .".order_increment = " . $salesOrder . ".increment_id SET ".
$signifydConnectCase .".order_id = " . $salesOrder . ".entity_id WHERE ".
- $signifydConnectCase . ".magento_status<>'complete'");
+ $signifydConnectCase . ".magento_status<>'complete'"
+ );
} catch (\Exception $e) {
$this->logger->debug('Update order_id on magento status different from complete failed');
$this->configWriter->save("signifyd/general/upgrade4.3_inconsistency", "setup");
diff --git a/Test/Integration/Cases/Cron/CreateTest.php b/Test/Integration/Cases/Cron/CreateTest.php
index 4b514cad..13735d39 100644
--- a/Test/Integration/Cases/Cron/CreateTest.php
+++ b/Test/Integration/Cases/Cron/CreateTest.php
@@ -26,8 +26,7 @@ public function setUp(): void
*/
public function testCronCreateCase()
{
- $this->placeQuote($this->getQuote('guest_quote'));
-
+ $order = $this->placeQuote($this->getQuote('guest_quote'));
/** @var \Signifyd\Connect\Model\Casedata $case */
$case = $this->objectManager->create(Casedata::class);
$case->setData([
@@ -35,6 +34,7 @@ public function testCronCreateCase()
// Case must be created with 60 seconds before now in order to trigger cron on retries
'created' => strftime('%Y-%m-%d %H:%M:%S', time()-60),
'updated' => strftime('%Y-%m-%d %H:%M:%S', time()-60),
+ 'order_id' => $order->getId(),
'magento_status' => \Signifyd\Connect\Model\Casedata::WAITING_SUBMISSION_STATUS
]);
$case->save();
diff --git a/Test/Integration/Cases/Cron/ReviewTest.php b/Test/Integration/Cases/Cron/ReviewTest.php
index 1ba13db1..8be8a075 100644
--- a/Test/Integration/Cases/Cron/ReviewTest.php
+++ b/Test/Integration/Cases/Cron/ReviewTest.php
@@ -16,14 +16,14 @@ public function testCronCreateCase()
*/
public function testCronReviewCase()
{
- parent::testCronCreateCase();
+ $this->placeQuote($this->getQuote('guest_quote'));
$this->updateCaseForRetry();
+
$this->tryToReviewCase();
$case = $this->getCase();
- $this->assertNotEquals('PENDING', $case->getData('signifyd_status'));
$this->assertEquals(Casedata::COMPLETED_STATUS, $case->getData('magento_status'));
$this->assertNotEmpty($case->getData('score'));
}
diff --git a/Test/Integration/Cases/Webhook/ReviewTest.php b/Test/Integration/Cases/Webhook/ReviewTest.php
index 95c58a20..fb55ef1b 100644
--- a/Test/Integration/Cases/Webhook/ReviewTest.php
+++ b/Test/Integration/Cases/Webhook/ReviewTest.php
@@ -15,7 +15,12 @@ class ReviewTest extends OrderTestCase
*/
public function testWebhookReviewCase()
{
- $this->placeQuote($this->getQuote('guest_quote'));
+ $order = $this->placeQuote($this->getQuote('guest_quote'));
+
+ $case = $this->getCase();
+ $case->setCode('991716767');
+ $case->setOrderId($order->getId());
+ $case->save();
/** @var \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig */
$scopeConfig = $this->objectManager->create(ScopeConfigInterface::class);
@@ -29,8 +34,7 @@ public function testWebhookReviewCase()
$webhookIndex->processRequest($request, $hash, 'cases/review');
/** @var \Signifyd\Connect\Model\Casedata $case */
- $case = $this->objectManager->create(Casedata::class);
- $case->load($this->incrementId);
+ $case = $this->getCase();
$this->assertEquals('APPROVED', $case->getData('guarantee'));
$this->assertEquals('792', $case->getData('score'));
diff --git a/Test/Integration/TestCase.php b/Test/Integration/TestCase.php
index 56cc2f87..3e21b090 100644
--- a/Test/Integration/TestCase.php
+++ b/Test/Integration/TestCase.php
@@ -51,7 +51,7 @@ public function getCase($incrementId = null)
/** @var \Signifyd\Connect\Model\Casedata $case */
$case = $this->objectManager->create(\Signifyd\Connect\Model\Casedata::class);
- $case->load($incrementId);
+ $case->load($incrementId, 'order_increment');
return $case;
}
diff --git a/composer.json b/composer.json
index 2eaed4c4..a42560e0 100644
--- a/composer.json
+++ b/composer.json
@@ -7,7 +7,7 @@
"php": ">=5.5.22"
},
"type": "magento2-module",
- "version": "4.3.4",
+ "version": "4.3.5",
"autoload": {
"files": [
"registration.php"
diff --git a/docs/ADYEN-PROXY.md b/docs/ADYEN-PROXY.md
index 945b892c..a9c95817 100644
--- a/docs/ADYEN-PROXY.md
+++ b/docs/ADYEN-PROXY.md
@@ -1,11 +1,34 @@
# Adyen Proxy
-### Setting Adyen Proxy
+The Adyen Proxy can be configured either in global (default) scope, store view (stores) or website (websites).
-To set Adyen Proxy run command below on your database:
+### Setting by website
+To find the website id just use the following command in the database:
+```sql
+select * from store_website;
+```
+With the id found (for exemple: 2) run command below on your database:
+
+```sql
+INSERT INTO core_config_data (scope, scope_id, path, value) VALUES ('websites', 2, 'signifyd/proxy/adyen_enable', 1);
+```
+
+### Setting by store view
+To find the store view id just use the following command in the database:
+```sql
+select * from store;
+```
+With the id found (for exemple: 4) run command below on your database:
+
+```sql
+INSERT INTO core_config_data (scope, scope_id, path, value) VALUES ('stores', 4, 'signifyd/proxy/adyen_enable', 1);
+```
+
+### Setting Global
+To set global configuration run command below on your database:
```sql
-INSERT INTO core_config_data (path, value) VALUES ('signifyd/proxy/adyen_enable', 1);
+INSERT INTO core_config_data (scope, scope_id, path, value) VALUES ('default', 0, 'signifyd/proxy/adyen_enable', 1);
```
### Remove Adyen Proxy
diff --git a/docs/DECISION_REQUEST.md b/docs/DECISION_REQUEST.md
index 171736ad..212b3d1c 100644
--- a/docs/DECISION_REQUEST.md
+++ b/docs/DECISION_REQUEST.md
@@ -6,14 +6,31 @@ A list of the possible values for DECISION-REQUEST can be founded on Signifyd AP
[https://developer.signifyd.com/api/#/reference/cases/create-case](https://developer.signifyd.com/api/#/reference/cases/create-case)
-### Setting decision
+### Setting global decision
-To set a decision, run command below on your database:
+If the setting has a string, the extension will assume this as the only decision for all cases.
+
+To set global decision run command below on your database:
```sql
INSERT INTO core_config_data (path, value) VALUES ('signifyd/general/decision_request', 'DECISION-REQUEST');
```
+### Setting decision per payment method
+
+It is possible to select a different decision per payment method.
+
+If the setting stores a JSON, then it will map each payment method listed on JSON to the corresponding decision. Any payment methods not mapped will fallback to the GUARANTEE decision. Here it is an example of how the final JSON could look like:
+
+```
+{"GUARANTEE": ["braintree"], "DECISION": ["paypal_braintree"]}
+```
+To set decision per payment method run command below on your database:
+
+```sql
+INSERT INTO core_config_data (path, value) VALUES ('signifyd/general/decision_request', 'INSERT-JSON-MAPPING');
+```
+
### Updating decision
To change the decision, run command below on your database:
diff --git a/etc/config.xml b/etc/config.xml
index f8c24f26..634bba14 100644
--- a/etc/config.xml
+++ b/etc/config.xml
@@ -14,10 +14,10 @@
pending_payment,payment_review,canceled,closed,complete
holded,pending_payment,payment_review,canceled,closed,complete
checkmo,cashondelivery,banktransfer,purchaseorder,free
- {"CREDIT_CARD":["payflow_link", "payflow_advanced", "authorizenet_acceptjs", "adyen_cc", "braintree", "cybersource", "stripe_payments", "anet_creditcard", "authorizenet_directpost", "openpay_cards"],"CHECK":["checkmo"]}
+ {"CREDIT_CARD":["payflow_link", "payflow_advanced", "authorizenet_acceptjs", "adyen_cc", "adyen_oneclick", "adyen_hpp", "braintree", "cybersource", "stripe_payments", "anet_creditcard", "authorizenet_directpost", "openpay_cards"],"CHECK":["checkmo"]}
{"FEDEX":["fedex"],"DHL":["dhl"],"SHIPWIRE":[],"USPS":["usps"],"UPS":["ups"]}
{"EXPRESS":["FEDEX_EXPRESS_SAVER", "7", "B", "C", "D", "U", "K", "L", "I", "N", "T", "X", "INT_4", "INT_5", "INT_6", "INT_7", "54", "07"],"ELECTRONIC":[],"FIRST_CLASS":["0_FCLE", "0_FCL", "0_FCP", "0_FCPC", "15", "53", "61", "INT_13", "INT_14", "INT_15", "INT_21"],"FIRST_CLASS_INTERNATIONAL":[],"FREE":["freeshipping"],"FREIGHT":["FEDEX_1_DAY_FREIGHT", "FEDEX_2_DAY_FREIGHT", "FEDEX_3_DAY_FREIGHT", "INTERNATIONAL_ECONOMY_FREIGHT", "INTERNATIONAL_PRIORITY_FREIGHT", "FEDEX_FREIGHT", "FEDEX_NATIONAL_FREIGHT"],"GROUND":["FEDEX_GROUND", "GROUND_HOME_DELIVERY", "INTERNATIONAL_GROUND", "4", "03"],"INTERNATIONAL":["INTERNATIONAL_ECONOMY", "INTERNATIONAL_FIRST"],"OVERNIGHT":["FIRST_OVERNIGHT", "PRIORITY_OVERNIGHT", "STANDARD_OVERNIGHT"],"PRIORITY":["1", "2", "3", "13", "16", "17", "22", "23", "25", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "57", "58", "59", "62", "63", "64", "INT_1", "INT_2", "INT_8", "INT_9", "INT_10", "INT_11", "INT_16", "INT_17", "INT_18", "INT_19", "INT_20", "INT_22", "INT_23", "INT_24", "INT_25", "INT_27"],"PRIORITY_INTERNATIONAL":["EUROPE_FIRST_INTERNATIONAL_PRIORITY", "INTERNATIONAL_PRIORITY"],"PICKUP":["pickup"],"STANDARD":["11"],"STORE_TO_STORE":[],"TWO_DAY":["FEDEX_2_DAY", "FEDEX_2_DAY_AM", "59", "02"]}
- cybersource
+ cybersource,mercadopago_basic
20
0
diff --git a/etc/module.xml b/etc/module.xml
index 51cdb8be..3a0b8bd5 100644
--- a/etc/module.xml
+++ b/etc/module.xml
@@ -5,7 +5,7 @@
*/
-->
-
+
diff --git a/view/base/requirejs-config.js b/view/base/requirejs-config.js
index 2112e419..b0514d20 100644
--- a/view/base/requirejs-config.js
+++ b/view/base/requirejs-config.js
@@ -12,6 +12,9 @@ var config = {
},
'Openpay_Cards/js/view/payment/method-renderer/cc-form': {
'Signifyd_Connect/js/model/openpay-cc-method-mixin': true
+ },
+ 'Adyen_Payment/js/view/payment/method-renderer/adyen-oneclick-method': {
+ 'Signifyd_Connect/js/model/adyen-oneclick-method-mixin': true
}
}
}
diff --git a/view/frontend/web/js/model/adyen-oneclick-method-mixin.js b/view/frontend/web/js/model/adyen-oneclick-method-mixin.js
new file mode 100644
index 00000000..9f36fb26
--- /dev/null
+++ b/view/frontend/web/js/model/adyen-oneclick-method-mixin.js
@@ -0,0 +1,37 @@
+define(
+ [],
+ function() {
+ 'use strict';
+
+ return function (target) {
+ return target.extend({
+ /**
+ * List all Adyen billing agreements
+ * Set up installments
+ *
+ * @returns {Array}
+ */
+ getAdyenBillingAgreements: function() {
+ let paymentList = this._super();
+
+ paymentList.forEach(function(key, payment) {
+ let expiryMonth = key.agreement_data.card.expiryMonth;
+ let expiryYear = key.agreement_data.card.expiryYear;
+ let number = key.agreement_data.card.number;
+
+ key.getDataOriginal = key.getData;
+ key.getData = function () {
+ let result = key.getDataOriginal();
+
+ result.additional_data.cardExpiryMonth = expiryMonth;
+ result.additional_data.cardExpiryYear = expiryYear;
+ result.additional_data.cardLast4 = number;
+ return result;
+ };
+ });
+
+ return paymentList;
+ }
+ });
+ };
+});