Adyen / adyen-magento2

Adyen Payment plugin for Magento2
MIT License
155 stars 211 forks source link

[PW-3384/3658] SEPA direct debit saved in vault - 2nd use, incorrect information saved #900

Closed paulappelbe closed 2 years ago

paulappelbe commented 3 years ago

Describe the bug When a SEPA direct debit is saved to the vault : the first payment is fine, but when a payment uses the vault (so second payment onwards) the data saved to the order is wrong, it treats it « half » like a credit card

To Reproduce Steps to reproduce the behavior:

  1. Create an order, use sepa direct debit and save to vault
  2. Create another order using sepa direct debit from vault
  3. see order email & payment information in admin -> wrong data - half of the information is credit card related which is obviously incorrect

Expected behavior expected

Actual behavior

Capture d’écran 2020-11-20 à 11 21 52

acampos1916 commented 3 years ago

Hello @paulappelbe,

Indeed this is a known situation. In order to use Vault with a non-card payment method we still had to use card tokens. Magento doesn't support Vault tokenisation for payment methods with initialize command. See #822.

Still, we're investigating an alternative solution, I've added this issue to our internal tracker.

Best, Ángel

gudal commented 3 years ago

Hello, Do you know when this issue will be dealt with ?

Thanks, Guillaume Dalaudier

acampos1916 commented 3 years ago

Hello @gudal,

It is still in our backlog, as soon as it is addressed we'll update this issue.

gudal commented 3 years ago

Hello,

Any news on this issue ?

Thanks, Guillaume Dalaudier

gudal commented 3 years ago

Hello,

Any news on this issue ?

Thanks, Guillaume Dalaudier

acampos1916 commented 3 years ago

Hey @gudal apologies for the delay. Unfortunately still in our backlog but we've preliminary planned the following:

Since the payment info block is showing the data from the vault payment method provider (in this case CC vault):

We're still having discussions if this is the best way to approach it, and we'll update this issue with progress made ASAP.

mverroyedata commented 3 years ago

Hi, Regarding your code, it seems that you use same payment method ("adyen_cc_vault") for all vault payments (in our case CC and HPP). So all vault payment are marked as "CC" (credit card). Also you are recording all vault_payment_token as adyen_cc. I add a fix by creating "adyen_hpp_vault" payment method which doesn't exist and changing value of payment_method_code for HPP payent with "adyen_hpp_vault" value. I don't make any changes for frontend part because we don't use it. I'm waiting for your correction to replace this fix.

Regards,

acampos1916 commented 3 years ago

@mverroyedata thanks for your feedback. Indeed we thought of that solution as well, but HPP is a payment method that requires an initialize command and Magento doesn't support initialize + vault. Here we rolled back those changes #822. If you're not using Magento's frontend maybe you already have a workaround for this and it works for you.

mverroyedata commented 3 years ago

Yes HPP requires an initialize but not HPP_vault wich works like CC_VAULT used at now (with token). So you can create an HPP_VAULT method with a specific configuration and set "can_initialize" to 0. I have created "adyen_hpp_vault" based on virtualtype AdyenPaymentHppVaultFacade with code "adyen_hpp_vault" and specific config AdyenPaymentHppVaultConfig, specific valueHandlerPool , specific vaultProvider, ... And I still use adyen_hpp (with initialize) to new sepa payment. Hope it can help.

acampos1916 commented 3 years ago

@mverroyedata interesting! Which vault provider did you use? https://github.com/Adyen/adyen-magento2/pull/822/files#diff-093a1e43a11122404c853506b7ca4f661e18dd4f6557ec3089cad8ceae34a606L62

If it's possible for you, a PR with this recommendation to our develop branch would be greatly appreciated.

mverroyedata commented 3 years ago

Hi,

I use « AdyenPaymentHppVaultAdapter ». I don’t make lot of changes :

Etc/config.xml :

0 AdyenPaymentHppFacade pending Alternative payment methods 0 oj9GsQ 3 authorize 1 1 1 1 0 1 1 1 1 1 0 1 adyen AdyenPaymentHppVaultFacade Stored Alternative payment methods (Adyen) Adyen\Payment\Model\InstantPurchase\CreditCard\AvailabilityChecker Adyen\Payment\Model\InstantPurchase\CreditCard\TokenFormatter pending 0 oj9GsQ 3 authorize 1 1 1 1 0 1 1 1 1 1 1 adyen 0

Etc/di.xml :

Danone\Adyen\Model\Ui\AdyenHppConfigProvider::CC_VAULT_CODE AdyenPaymentHppVaultConfig AdyenPaymentHppVaultPaymentValueHandlerPool AdyenPaymentHppVaultAdapter Adyen\Payment\Model\Ui\AdyenHppConfigProvider::CODE Adyen\Payment\Block\Form\Hpp Adyen\Payment\Block\Info\Hpp AdyenPaymentHppVaultValueHandlerPool AdyenPaymentHppValidatorPool AdyenPaymentHppCommandPool AdyenHppVaultCountryValidator AdyenPaymentHppVaultConfig AdyenPaymentHppVaultConfig AdyenPaymentHppVaultConfigValueHandler AdyenPaymentHppVaultConfig AdyenPaymentHppVaultPaymentValueHandler Danone\Adyen\Model\Ui\AdyenHppConfigProvider::CC_VAULT_CODE AdyenPaymentHppCommandPool AdyenPaymentHppCommandManager AdyenPaymentHppVaultAuthorizeRequest Adyen\Payment\Gateway\Http\TransferFactory Adyen\Payment\Gateway\Http\Client\TransactionAuthorization GeneralResponseValidator AdyenPaymentHppVaultResponseHandlerComposite AdyenPaymentHppAuthorizeCommand AdyenPaymentCaptureCommand AdyenPaymentCancelCommand AdyenPaymentRefundCommand AdyenPaymentCancelCommand AdyenPaymentHppVaultAuthorizeCommand Adyen\Payment\Gateway\Request\MerchantAccountDataBuilder Adyen\Payment\Gateway\Request\CustomerDataBuilder Adyen\Payment\Gateway\Request\CustomerIpDataBuilder Adyen\Payment\Gateway\Request\AddressDataBuilder Adyen\Payment\Gateway\Request\PaymentDataBuilder Adyen\Payment\Gateway\Request\BrowserInfoDataBuilder Adyen\Payment\Gateway\Request\RecurringVaultDataBuilder Adyen\Payment\Gateway\Response\PaymentAuthorisationDetailsHandler Adyen\Payment\Gateway\Response\PaymentCommentHistoryHandler

I changed \Adyen\Payment\Model\Ui\AdyenHppConfigProvider by adding

const CC_VAULT_CODE = 'adyen_hpp_vault';

and on getConfig methode

$config = [ 'payment' => [ self::CODE => [ 'vaultCode' => self::CC_VAULT_CODE, 'isActive' => true, 'redirectUrl' => $this->urlBuilder->getUrl( 'adyen/process/redirect', ['_secure' => $this->getRequest()->isSecure()] ) ] ] ];

Finally, on \Adyen\Payment\Model\Cron in methode _processNotification you make this test

if ($_paymentCode == 'adyen_hpp' && $this->configHelper->isStoreAlternativePaymentMethodEnabled()) {

then you set payment code as CC code ‘adyen_cc’

$paymentTokenAlternativePaymentMethod->setCustomerId($customerId)->setGatewayToken($this->_pspReference)->setPaymentMethodCode(AdyenCcConfigProvider::CODE)

I changed it by ‘adyen_hpp_vault’

$paymentTokenAlternativePaymentMethod->setCustomerId($customerId)->setGatewayToken($this->_pspReference)->setPaymentMethodCode(AdyenHppConfigProvider::CC_VAULT_CODE)

Regards,

@.***D727CD.F981A0C0]

De : Ángel Campos @.> Envoyé : vendredi 2 avril 2021 09:30 À : Adyen/adyen-magento2 @.> Cc : Maxime VERROYE @.>; Mention @.> Objet : Re: [Adyen/adyen-magento2] [PW-3384] SEPA direct debit saved in vault - 2nd use, incorrect information saved (#900)

@mverroyedatahttps://github.com/mverroyedata interesting! Which vault provider did you use? https://github.com/Adyen/adyen-magento2/pull/822/files#diff-093a1e43a11122404c853506b7ca4f661e18dd4f6557ec3089cad8ceae34a606L62

If it's possible for you, a PR with this recommendation to our develop branch would be greatly appreciated.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Adyen/adyen-magento2/issues/900#issuecomment-812387525, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ATPIUT2T2GWVHWKDEN46QLLTGVW67ANCNFSM4ULTOK2A.

candemiralp commented 2 years ago

Issue was fixed on #1563.