Magento – How to use the vault in custom payment module.

magento2.2.2modulepayment-methodsvault

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.

Best Answer

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?

Related Topic