How to get Payment Gateway token from the Vault Payment order Magento 2?

Get Payment Gateway token from the Order in Magento 2 will be useful in the future, if any payment related information needed for that specific transaction.

Vault payment method stores the payment’s gateway token for the order with saving credit card information for the future.

The customer has placed an order from the site with checked Save Credit Card details for the next transaction from the Payment step, Vault store the gateway token for the Payment.

You can retrieve the payment Gateway token from the Order object.

Load the Order Object from the link, Get order data by order id Magento 2

Add Code Snippet to in your class,


Fetch First Order Object by the Order id,  Load Payment method by the getPayment() check for the Extension Attributes from the loaded Object and based on that retreive Vault Payment token, that contains the Gateway token saved by the Order.

This is the best way to achieve payment gateway token from the Order.