Skip to content

Commit

Permalink
3.5.2: MAG-524: Fix for payment methods installation issues
Browse files Browse the repository at this point in the history
On previous version we're using to set payment methods verification classes
to paht 'payment/[payment_method]/[config_key]', but this was causing issues
on Magento/extension installation and/or checkout when one of defined
payment methods was not present on Magento installation

Documentation has been updated
  • Loading branch information
ebanolopes committed Feb 5, 2020
1 parent 4ddbfce commit 5566b8c
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 69 deletions.
22 changes: 20 additions & 2 deletions Model/PaymentVerificationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Signifyd\Connect\Api\PaymentVerificationInterface;
use Magento\Payment\Gateway\ConfigInterface;
use Magento\Framework\Exception\LocalizedException;
use Signifyd\Connect\Helper\ConfigHelper;

/**
* Creates verification service for provided payment method, or PaymentVerificationInterface::class
Expand Down Expand Up @@ -63,6 +64,11 @@ class PaymentVerificationFactory
*/
protected $transactionIdDefaultAdapter;

/**
* @var ConfigHelper
*/
protected $configHelper;

/**
* @param ObjectManagerInterface $objectManager
* @param ConfigInterface|Config $config
Expand All @@ -73,6 +79,7 @@ class PaymentVerificationFactory
* @param PaymentVerificationInterface $expMonthDefaultAdapter
* @param PaymentVerificationInterface $expYearDefaultAdapter
* @param PaymentVerificationInterface $binDefaultAdapter
* @param ConfigHelper $configHelper
*/
public function __construct(
ObjectManagerInterface $objectManager,
Expand All @@ -84,7 +91,8 @@ public function __construct(
PaymentVerificationInterface $expMonthDefaultAdapter,
PaymentVerificationInterface $expYearDefaultAdapter,
PaymentVerificationInterface $binDefaultAdapter,
PaymentVerificationInterface $transactionIdDefaultAdapter
PaymentVerificationInterface $transactionIdDefaultAdapter,
ConfigHelper $configHelper
) {
$this->config = $config;
$this->objectManager = $objectManager;
Expand All @@ -96,6 +104,7 @@ public function __construct(
$this->expYearDefaultAdapter = $expYearDefaultAdapter;
$this->binDefaultAdapter = $binDefaultAdapter;
$this->transactionIdDefaultAdapter = $transactionIdDefaultAdapter;
$this->configHelper = $configHelper;
}

/**
Expand Down Expand Up @@ -206,6 +215,10 @@ public function createPaymentTransactionId($paymentCode)
* Creates instance of PaymentVerificationInterface.
* Default implementation will be returned if payment method does not implement PaymentVerificationInterface.
*
* Will search for payment verification class on payment/[method]/[config_key] configuration path first
* If not found will try for signifyd/payment/[method]/[config_key]
* We keep looking on payment/[method]/[config_key] because this is the path on 3.5.1 and older versions
*
* @param PaymentVerificationInterface $defaultAdapter
* @param string $paymentCode
* @param string $configKey
Expand All @@ -217,7 +230,12 @@ private function create(PaymentVerificationInterface $defaultAdapter, $paymentCo
{
$this->config->setMethodCode($paymentCode);
$verificationClass = $this->config->getValue($configKey);
if ($verificationClass === null) {

if (empty($verificationClass)) {
$verificationClass = $this->configHelper->getConfigData("signifyd/payment/{$paymentCode}/{$configKey}");
}

if (empty($verificationClass)) {
return $defaultAdapter;
}

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"php": ">=5.5.22"
},
"type": "magento2-module",
"version": "3.5.1",
"version": "3.5.2",
"autoload": {
"files": [
"registration.php"
Expand Down
16 changes: 2 additions & 14 deletions docs/INSTALL-TROUBLESHOOT.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,9 @@

## Stripe payments error on 3.5.0 and 3.5.1

This is a known bug that will be fixed on 3.5.2 release. So it is not necessary to keep track of below modifications.
This is a known bug that has been fixed on 3.5.2 release. Upgrade to latest version to fix it

If during installation or on checkout process an exception with message "Payment model name is not provided in config" is raised and store does not have stripe_payments payment method installed, follow bellow instructions as an workaround.

On etc/config.xml find <stripe_payments> tag (line 61) and remove these lines and clear the cache.

```xml
<stripe_payments>
<signifyd_avs_ems_adapter>Signifyd\Connect\Model\Payment\Stripe\Payments\AvsEmsCodeMapper</signifyd_avs_ems_adapter>
<signifyd_cvv_ems_adapter>Signifyd\Connect\Model\Payment\Stripe\Payments\CvvEmsCodeMapper</signifyd_cvv_ems_adapter>
<signifyd_last4_adapter>Signifyd\Connect\Model\Payment\Stripe\Payments\Last4Mapper</signifyd_last4_adapter>
<signifyd_exp_month_adapter>Signifyd\Connect\Model\Payment\Stripe\Payments\ExpMonthMapper</signifyd_exp_month_adapter>
<signifyd_exp_year_adapter>Signifyd\Connect\Model\Payment\Stripe\Payments\ExpYearMapper</signifyd_exp_year_adapter>
</stripe_payments>
```
If during installation or on checkout process an exception with message "Payment model name is not provided in config" is raised and store does not have stripe_payments payment method installed and store is using Signifyd version 3.5.0 or 3.5.1, upgrate to latest version to fix it.

## Third-party cache errors

Expand Down
41 changes: 29 additions & 12 deletions docs/PAYMENT-DETAILS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ All mappers should implement Signifyd\Connect\Api\PaymentVerificationInterface.

For the inclusion of a custom payment, it is necessary to find the payment method code.

Usually it is possible to find the payment method code inside the payment method config.xml file, inside the `<default><payment>` tag. Something like this:
Usually it is possible to find the payment method code inside the payment method config.xml file, inside the `<default><signifyd><payment>` tag. Something like this:

```
```xml
<default>
<payment>
<payment_method_code>
...
</payment_method_code>
</payment>
<signifyd>
<payment>
<payment_method_code>
...
</payment_method_code>
</payment>
</signifyd>
</default>
```

Expand All @@ -67,11 +69,13 @@ On config.xml set the mapper to be used for the payment method and information a
```xml
<config>
<default>
<payment>
<payment_method_code>
<signifyd_information_code_adapter>Mapper\Class</signifyd_information_code_adapter>
</payment_method_code>
</payment>
<signifyd>
<payment>
<payment_method_code>
<signifyd_information_code_adapter>Mapper\Class</signifyd_information_code_adapter>
</payment_method_code>
</payment>
</signifyd>
</default>
</config>
```
Expand All @@ -98,6 +102,8 @@ Here is a template for mapper class implementation:

_**Replace bold parts with specific information for custom extension, payment method and information**_

_**Do not implement a validate() method inside these classes**_

```php
namespace Path\Your\Namespace;

Expand Down Expand Up @@ -182,6 +188,17 @@ Here is a list of the payment methods that have a built in helper on the extensi
- Code: braintree
- Magento built in

**Available data**
- CVV Status
- AVS Status
- Last4
- Expiry Month
- Expiry Year
- Transaction ID

### Stripe Payments
- Code: stripe_payments

**Available data**
- CVV Status
- AVS Status
Expand Down
79 changes: 40 additions & 39 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,49 +22,50 @@
<logs>
<log>1</log>
</logs>
</signifyd>
<payment>
<authorizenet_directpost>
<signifyd_cvv_ems_adapter>Signifyd\Connect\Model\Payment\Authorizenet\CvvEmsCodeMapper</signifyd_cvv_ems_adapter>
<signifyd_last4_adapter>Signifyd\Connect\Model\Payment\Authorizenet\Last4Mapper</signifyd_last4_adapter>
<signifyd_exp_month_adapter>Signifyd\Connect\Model\Payment\Authorizenet\ExpMonthMapper</signifyd_exp_month_adapter>
<signifyd_exp_year_adapter>Signifyd\Connect\Model\Payment\Authorizenet\ExpYearMapper</signifyd_exp_year_adapter>
<signifyd_transaction_id_adapter>Signifyd\Connect\Model\Payment\Authorizenet\TransactionIdMapper</signifyd_transaction_id_adapter>
</authorizenet_directpost>

<braintree>
<signifyd_avs_ems_adapter>Signifyd\Connect\Model\Payment\Braintree\AvsEmsCodeMapper</signifyd_avs_ems_adapter>
<signifyd_cvv_ems_adapter>Signifyd\Connect\Model\Payment\Braintree\CvvEmsCodeMapper</signifyd_cvv_ems_adapter>
</braintree>
<payment>
<authorizenet_directpost>
<signifyd_cvv_ems_adapter>Signifyd\Connect\Model\Payment\Authorizenet\CvvEmsCodeMapper</signifyd_cvv_ems_adapter>
<signifyd_last4_adapter>Signifyd\Connect\Model\Payment\Authorizenet\Last4Mapper</signifyd_last4_adapter>
<signifyd_exp_month_adapter>Signifyd\Connect\Model\Payment\Authorizenet\ExpMonthMapper</signifyd_exp_month_adapter>
<signifyd_exp_year_adapter>Signifyd\Connect\Model\Payment\Authorizenet\ExpYearMapper</signifyd_exp_year_adapter>
<signifyd_transaction_id_adapter>Signifyd\Connect\Model\Payment\Authorizenet\TransactionIdMapper</signifyd_transaction_id_adapter>
</authorizenet_directpost>

<braintree>
<signifyd_avs_ems_adapter>Signifyd\Connect\Model\Payment\Braintree\AvsEmsCodeMapper</signifyd_avs_ems_adapter>
<signifyd_cvv_ems_adapter>Signifyd\Connect\Model\Payment\Braintree\CvvEmsCodeMapper</signifyd_cvv_ems_adapter>
</braintree>

<payflowpro>
<signifyd_avs_ems_adapter>Signifyd\Connect\Model\Payment\Payflow\Pro\AvsEmsCodeMapper</signifyd_avs_ems_adapter>
<signifyd_cvv_ems_adapter>Signifyd\Connect\Model\Payment\Payflow\Pro\CvvEmsCodeMapper</signifyd_cvv_ems_adapter>
</payflowpro>
<payflowpro>
<signifyd_avs_ems_adapter>Signifyd\Connect\Model\Payment\Payflow\Pro\AvsEmsCodeMapper</signifyd_avs_ems_adapter>
<signifyd_cvv_ems_adapter>Signifyd\Connect\Model\Payment\Payflow\Pro\CvvEmsCodeMapper</signifyd_cvv_ems_adapter>
</payflowpro>

<payflow_link>
<signifyd_avs_ems_adapter>Signifyd\Connect\Model\Payment\Payflow\Link\AvsEmsCodeMapper</signifyd_avs_ems_adapter>
<signifyd_cvv_ems_adapter>Signifyd\Connect\Model\Payment\Payflow\Link\CvvEmsCodeMapper</signifyd_cvv_ems_adapter>
<signifyd_last4_adapter>Signifyd\Connect\Model\Payment\Payflow\Link\Last4Mapper</signifyd_last4_adapter>
<signifyd_exp_month_adapter>Signifyd\Connect\Model\Payment\Payflow\Link\ExpMonthMapper</signifyd_exp_month_adapter>
<signifyd_exp_year_adapter>Signifyd\Connect\Model\Payment\Payflow\Link\ExpYearMapper</signifyd_exp_year_adapter>
</payflow_link>
<payflow_link>
<signifyd_avs_ems_adapter>Signifyd\Connect\Model\Payment\Payflow\Link\AvsEmsCodeMapper</signifyd_avs_ems_adapter>
<signifyd_cvv_ems_adapter>Signifyd\Connect\Model\Payment\Payflow\Link\CvvEmsCodeMapper</signifyd_cvv_ems_adapter>
<signifyd_last4_adapter>Signifyd\Connect\Model\Payment\Payflow\Link\Last4Mapper</signifyd_last4_adapter>
<signifyd_exp_month_adapter>Signifyd\Connect\Model\Payment\Payflow\Link\ExpMonthMapper</signifyd_exp_month_adapter>
<signifyd_exp_year_adapter>Signifyd\Connect\Model\Payment\Payflow\Link\ExpYearMapper</signifyd_exp_year_adapter>
</payflow_link>

<payflow_advanced>
<signifyd_avs_ems_adapter>Signifyd\Connect\Model\Payment\Payflow\Link\AvsEmsCodeMapper</signifyd_avs_ems_adapter>
<signifyd_cvv_ems_adapter>Signifyd\Connect\Model\Payment\Payflow\Link\CvvEmsCodeMapper</signifyd_cvv_ems_adapter>
<signifyd_last4_adapter>Signifyd\Connect\Model\Payment\Payflow\Link\Last4Mapper</signifyd_last4_adapter>
<signifyd_exp_month_adapter>Signifyd\Connect\Model\Payment\Payflow\Link\ExpMonthMapper</signifyd_exp_month_adapter>
<signifyd_exp_year_adapter>Signifyd\Connect\Model\Payment\Payflow\Link\ExpYearMapper</signifyd_exp_year_adapter>
</payflow_advanced>
<payflow_advanced>
<signifyd_avs_ems_adapter>Signifyd\Connect\Model\Payment\Payflow\Link\AvsEmsCodeMapper</signifyd_avs_ems_adapter>
<signifyd_cvv_ems_adapter>Signifyd\Connect\Model\Payment\Payflow\Link\CvvEmsCodeMapper</signifyd_cvv_ems_adapter>
<signifyd_last4_adapter>Signifyd\Connect\Model\Payment\Payflow\Link\Last4Mapper</signifyd_last4_adapter>
<signifyd_exp_month_adapter>Signifyd\Connect\Model\Payment\Payflow\Link\ExpMonthMapper</signifyd_exp_month_adapter>
<signifyd_exp_year_adapter>Signifyd\Connect\Model\Payment\Payflow\Link\ExpYearMapper</signifyd_exp_year_adapter>
</payflow_advanced>

<stripe_payments>
<signifyd_avs_ems_adapter>Signifyd\Connect\Model\Payment\Stripe\Payments\AvsEmsCodeMapper</signifyd_avs_ems_adapter>
<signifyd_cvv_ems_adapter>Signifyd\Connect\Model\Payment\Stripe\Payments\CvvEmsCodeMapper</signifyd_cvv_ems_adapter>
<signifyd_last4_adapter>Signifyd\Connect\Model\Payment\Stripe\Payments\Last4Mapper</signifyd_last4_adapter>
<signifyd_exp_month_adapter>Signifyd\Connect\Model\Payment\Stripe\Payments\ExpMonthMapper</signifyd_exp_month_adapter>
<signifyd_exp_year_adapter>Signifyd\Connect\Model\Payment\Stripe\Payments\ExpYearMapper</signifyd_exp_year_adapter>
</stripe_payments>
</payment>
<stripe_payments>
<signifyd_avs_ems_adapter>Signifyd\Connect\Model\Payment\Stripe\Payments\AvsEmsCodeMapper</signifyd_avs_ems_adapter>
<signifyd_cvv_ems_adapter>Signifyd\Connect\Model\Payment\Stripe\Payments\CvvEmsCodeMapper</signifyd_cvv_ems_adapter>
<signifyd_last4_adapter>Signifyd\Connect\Model\Payment\Stripe\Payments\Last4Mapper</signifyd_last4_adapter>
<signifyd_exp_month_adapter>Signifyd\Connect\Model\Payment\Stripe\Payments\ExpMonthMapper</signifyd_exp_month_adapter>
<signifyd_exp_year_adapter>Signifyd\Connect\Model\Payment\Stripe\Payments\ExpYearMapper</signifyd_exp_year_adapter>
</stripe_payments>
</payment>
</signifyd>
</default>
</config>
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Signifyd_Connect" setup_version="3.5.1">
<module name="Signifyd_Connect" setup_version="3.5.2">
<sequence>
<module name="Magento_Sales" />
<module name="Magento_Payment" />
Expand Down

0 comments on commit 5566b8c

Please sign in to comment.