Skip to content

Commit

Permalink
5.4.0: payment config dupplicate method.
Browse files Browse the repository at this point in the history
  • Loading branch information
ebanolopes committed Jul 11, 2023
1 parent 63ebf3c commit d3ddd07
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 167 deletions.
21 changes: 0 additions & 21 deletions Block/Adminhtml/Form/Field/PolicyExceptions.php

This file was deleted.

29 changes: 5 additions & 24 deletions Helper/ConfigHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,37 +267,18 @@ public function getDefaultPolicy($scopeType = ScopeConfigInterface::SCOPE_TYPE_D

public function getPolicyName($scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode = null)
{
$policyName = $this->getDefaultPolicy($scopeType, $scopeCode);
$policyExceptionsData = $this->scopeConfigInterface->getValue(
'signifyd/general/policy_exceptions',
$defaultPolicyName = $this->getDefaultPolicy($scopeType, $scopeCode);
$policyName = $this->scopeConfigInterface->getValue(
'signifyd/advanced/policy_name',
$scopeType,
$scopeCode
);

try {
$policyExceptions = $this->jsonSerializer->unserialize($policyExceptionsData);
} catch (\InvalidArgumentException $e) {
return $policyName;
}

if (empty($policyExceptions)) {
if (isset($policyName)) {
return $policyName;
}

$mergePolicy = [];
$mergePolicy[$policyName] = [];

foreach ($policyExceptions as $key => $value) {
if (is_array($value) && isset($value['policy']) && isset($value['payment_method'])) {
if (in_array($value['policy'], array_keys($mergePolicy)) === false) {
$mergePolicy[$value['policy']] = [];
}

$mergePolicy[$value['policy']][] = $value['payment_method'];
}
}

return $this->jsonSerializer->serialize($mergePolicy);
return $defaultPolicyName;
}

/**
Expand Down
114 changes: 0 additions & 114 deletions Setup/Patch/Data/PolicyUpdate.php

This file was deleted.

43 changes: 40 additions & 3 deletions docs/POLICY-MAPPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,48 @@ By default the extension will automatically use asynchronous response (POST_AUTH

For more information about transaction risk analysis pre-auth (SCA_PRE_AUTH), access the [documentation](SCA_PRE_AUTH.md).

### Setting policy exceptions
### Setting global synchronous response

It is possible to set a policy exceptions per payment method.
If the setting has a string as "PRE_AUTH" then the extension will assume this as the only policy for all cases.

In the Signifyd session on admin, in the field "Policy exceptions" set policy as "POST_AUTH", "PRE_AUTH" or "SCA_PRE_AUTH" and in "Payment Method" the payment code, for example "adyen_cc".
To set global synchronous response run command below on your database:

```sql
INSERT INTO core_config_data (path, value) VALUES ('signifyd/advanced/policy_name', 'PRE_AUTH');
```

### Setting global asynchronous response

To revert back to the extension's default policy, just delete it from the database:

```sql
DELETE FROM core_config_data WHERE path = 'signifyd/advanced/policy_name';
```

### Setting policy per payment method

It is possible to select a different policy per payment method.

If the setting stores a JSON, then it will map each payment method listed on JSON to the corresponding policy. Any payment methods not mapped will fallback to the POST_AUTH policy. Here it is an example of how the final JSON could look like:

```
{"PRE_AUTH": ["paypal_braintree"], "POST_AUTH": ["checkmo"], "SCA_PRE_AUTH": ["braintree"]}
```
To set policy per payment method run command below on your database:

```sql
INSERT INTO core_config_data (path, value) VALUES ('signifyd/advanced/policy_name', 'INSERT-JSON-MAPPING');
```

### Check policy

To check the current policy, run the command below on your database:

```sql
SELECT * FROM core_config_data WHERE path = 'signifyd/advanced/policy_name';
```

If no records are found, the extension will automatically use asynchronous response.

## Policy decline message

Expand Down
5 changes: 0 additions & 5 deletions etc/adminhtml/system/signifyd/general.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,5 @@
<label>Signifyd Policy</label>
<source_model>Signifyd\Connect\Model\System\Config\Source\Options\PolicyName</source_model>
</field>
<field id="policy_exceptions" type="select" sortOrder="30" showInWebsite="1" showInStore="1" showInDefault="1" translate="label">
<label>Policy exceptions</label>
<frontend_model>Signifyd\Connect\Block\Adminhtml\Form\Field\PolicyExceptions</frontend_model>
<backend_model>Magento\Config\Model\Config\Backend\Serialized\ArraySerialized</backend_model>
</field>
</group>
</include>

0 comments on commit d3ddd07

Please sign in to comment.