We need to allow off-site payment gateways to generate payment methods and make payments with them.
Currently, only gateways which implement OnsiteInterface may create payments with payment methods, as the createPayment method exists on OnsiteInterface. This method actually performs a payment with an attached payment method. This means it can be moved to SupportsStoredPaymentMethodsInterface since it requires a payment method for payment.
This solves one problem. However, SupportsStoredPaymentMethodsInterface enforces the implementation of createPaymentMethod. This enforces payment method creation from a tokenized payment instrument before processing a payment transaction. Off-site payment gateways may process the payment transaction when returning to the checkout page or through their IPN/Webhook endpoint.
Here is a shuffling of the existing interfaces to make it feasible for an off-site payment gateway to generate payment method entities during onReturn or onNotify.
SupportsStoredPaymentMethodsInterface identifies that the payment gateway allows creating payments using an existing payment method. This moves createPayment from OnsiteInterface to this interface, so it may be shared. It also keeps the deletePaymentMethod method, as any gateway supporting payment methods must also allow removing them for a customer. (We discussed a UsePaymentMethodsInterface interface, but it requires still supporting the existing method, so avoid extra changes.)SupportsUpdatingPaymentMethodsInterface already exists and will remain, this identifies that a gateway allows updating a created payment method.SupportsCreatingPaymentMethodsInterface is a new interface that takes createPaymentMethod out of the original SupportsStoredPaymentMethodsInterface. Payment gateways that implement this interface identify that they allow creating payment methods outside of the process of creating a payment. We will then provide alternative add-payment-method forms for user-add-payment-method and checkout-add-payment-method, for existing implementations we will split add-payment-method into those values
user-add-payment-method plugin form handlerSupportsCreatingPaymentMethodsInCheckoutInterfaceSupportsCreatingPaymentMethodsOnUserInterfaceoff-session and on-session, which SCA uses. But that is more about when a payment method is used.