How does Magento 2 detect which module should handle a vault payment?

The vault_payment_token database table stores the relationship between the payment tokens and the payment modules in the payment_method_code column, e.g.:

entity_id 1
customer_id 1
public_hash beb166f1a00a8cf7c3088fccba1e5fc857acb6b842a582e3b94a0f70f5f5b354
payment_method_code braintree
type card
created_at 2017-06-06 01:35:35
expires_at 2017-08-01 03:00:00
gateway_token kpvhv8
details {"type":"MC","maskedCC":"4444","expirationDate":"07\/2017"}
is_active 1
is_visible 1

See also: