3

I am working on custom payment module with Authorize technique using XML API based.

I need to use Magento out of box vault module to save customer card details. Any one have knowledge on this How Can I use this vault to save card.?

Thanks.

5

2 Answers 2

1

Add vault to module dependencies

You need to add dependencies on the Magento_Vault module in the payment method’s module.xml files.

Example: adding Vault module dependencies for the Braintree payment method

app/code/Magento/Braintree/etc/module.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Magento_Braintree" setup_version="2.0.0">
        <sequence>
            ...
            <module name="Magento_Vault"/>
            ...
        </sequence>
    </module>
</config>

Now configuration vault payment

You need to configure the main parameters of the vault implementation in the config.xml file of your payment method module:

model - instance of the vault payment implementation, configured in di.xml.

title - vault payment method title; can be overwritten in the store configuration.

These parameters are specified in the section defined by the unique vault implementation code. They are the minimum required to create vault payment. All other payment settings are inherited from the payment provider integration.

Additional configuration might be required depending on your implementation.

The following example is the config.xml file of the Braintree payment method:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <payment>
            <braintree>
                <model>BraintreeFacade</model>
                ...
            </braintree>
            <braintree_cc_vault>
                <model>BraintreeCreditCardVaultFacade</model>
                <title>Stored Cards (Braintree)</title>
            </braintree_cc_vault>
        </payment>
    </default>
</config>

More at:

1) http://devdocs.magento.com/guides/v2.1/payments-integrations/vault/vault-di.html

2) Magento 2: How to set VaultProvider?

2
  • Hi, I am trying to add Vault to the payfort module by following the official doc devdocs.magento.com/guides/v2.1/payments-integrations/vault/…, but i cannot get the dependency injection correct. I tried to copy the di.xml from the braintree module but it is also very confusing. the code inside the VaultDetailsHandler which is used as handler is not getting executed. What is your opinion about using sales_order_payment_save_after or checkout_onepage_controller_success_action event observers to add token to vault Feb 5, 2019 at 12:43
  • have you get any solution @SreejithSasidharan Oct 20, 2020 at 12:09
0

Magento 2.4.2 I made a payment gateway with a safe, it saves and lists the cards, but it doesn't go through the custom builders at the end of the purchase, finishing normally. Without the card saved (vault) it ends the order and passes the builders normally

<virtualType name="CustomCcVaultPaymentConfig" type="Magento\Payment\Gateway\Config\Config">
    <arguments>
        <argument name="methodCode" xsi:type="const">Vendor\CustomPayment\Gateway\Config::CC_VAULT_CODE</argument>
    </arguments>
</virtualType>
<virtualType name="CustomCcVaultPaymentValueHandler" type="VaultPaymentDefaultValueHandler">
    <arguments>
        <argument name="configInterface" xsi:type="object">CustomCcVaultPaymentConfig</argument>
    </arguments>
</virtualType>
<virtualType name="CustomCcVaultPaymentValueHandlerPool" type="VaultPaymentValueHandlerPool">
    <arguments>
        <argument name="handlers" xsi:type="array">
            <item name="default" xsi:type="string">CustomCcVaultPaymentValueHandler</item>
        </argument>
    </arguments>
</virtualType>
<virtualType name="CustomCcVaultFacade" type="Magento\Vault\Model\Method\Vault">
    <arguments>
        <argument name="config" xsi:type="object">CustomCcVaultPaymentConfig</argument>
        <argument name="valueHandlerPool" xsi:type="object">CustomCcVaultPaymentValueHandlerPool</argument>
        <argument name="vaultProvider" xsi:type="object">CustomCcFacade</argument>
        <argument name="code" xsi:type="const">Vendor\CustomPayment\Gateway\Config::CC_VAULT_CODE</argument>
    </arguments>
</virtualType>

I followed the documentation and the vendor. Detail that in the debug comes canCancel false

Payload on the front goes with the right hash.

What would it need to pass in the builds used in the module?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.