Store customers must have the ability to enable and disable credit cards details storing.
Magento out-of-the-box provides mechanisms for adding this ability, but your still need to add modifications in your payment method implementation.
These modifications are the following:
Adding vault enabling controls.
Modifying the payment component (updating of the additional_data property must be added).
Creating a request data builder.
The following paragraphs describe these points in details.
Add vault enabling controls
Add the vault enabling controls to the payment form. In the following example, a check box bound to the Vault enabler is added.
The payment component must process the state of the vault-enabling control and update payment additional_data before it is sent to the backend.
Magento has a default vault enabler UI component (Magento_Vault/js/view/payment/vault-enabler). In the payment component, you just need to call its visitAdditionalData to update the additional_data property. The rest is done by the \Magento\Vault\Observer\VaultEnableAssigner observer.