Work from #2838380: [META] Allow offsite payment gateways to create and use payment methods.

We should move OnsitePaymentGatewayInterface::createPayment to SupportsStoredPaymentMethodsInterface.

The createPayment method has the intent that the on-site gateway will create a payment transaction with the payment method attached to the payment entity. By moving this method we can allow any gateway that supports stored payment methods to also support creating a payment with them.

After reviewing the available contributed payment gateways, all seem to implement \Drupal\commerce_payment\Plugin\Commerce\PaymentGateway\OnsitePaymentGatewayInterface directly. So while this causes a breaking change in our interfaces, no one seems to be implementing \Drupal\commerce_payment\Plugin\Commerce\PaymentGateway\SupportsStoredPaymentMethodsInterface on their own (because you technically can't.)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mglaman created an issue. See original summary.

mglaman’s picture

Status: Active » Needs review
FileSize
2.67 KB

Here's the patch.

zaporylie’s picture

+++ b/modules/payment/src/Plugin/Commerce/PaymentGateway/OnsitePaymentGatewayInterface.php
@@ -29,20 +29,4 @@ use Drupal\commerce_payment\Entity\PaymentInterface;
-  public function createPayment(PaymentInterface $payment, $capture = TRUE);

Nitpick: That line makes use Drupal\commerce_payment\Entity\PaymentInterface; unused.

Otherwise, I think it's a good thing to move that particular method around. Giving it a new home in SupportsStoredPaymentMethodsInterface makes complete sense to me.

  • mglaman committed 55434c4 on 8.x-2.x
    Issue #3137116 by mglaman, zaporylie: Move createPayment to...
mglaman’s picture

Status: Needs review » Fixed

Thanks, @zaporylie. Remaining unused imports has been a bane of my process in these off-site payment methods development 🤣

Fixed and committed!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.