Skip to content
Snippets Groups Projects
Commit 895611fa authored by Jonathan Sacksick's avatar Jonathan Sacksick
Browse files

Issue #3250069 by berdir, solene_ggd, jsacksick, damienmckenna, damienmo: List...

Issue #3250069 by berdir, solene_ggd, jsacksick, damienmckenna, damienmo: List offsite payment gateways that support stored payment methods directly, not grouped by payment type.
parent 41ea9def
No related branches found
No related tags found
1 merge request!317Issue #3250069 by berdir, solene_ggd, jsacksick, damienmckenna, damienmo: List...
Pipeline #265153 passed
......@@ -6,6 +6,7 @@ use Drupal\commerce\EntityHelper;
use Drupal\commerce_order\Entity\OrderInterface;
use Drupal\commerce_payment\Event\FilterPaymentOptionsEvent;
use Drupal\commerce_payment\Event\PaymentEvents;
use Drupal\commerce_payment\Plugin\Commerce\PaymentGateway\SupportsCreatingPaymentMethodsInterface;
use Drupal\commerce_payment\Plugin\Commerce\PaymentGateway\SupportsStoredPaymentMethodsInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
......@@ -119,9 +120,12 @@ class PaymentOptionsBuilder implements PaymentOptionsBuilderInterface {
}
foreach ($payment_gateways as $payment_gateway_id => $payment_gateway) {
$payment_gateway_plugin = $payment_gateway->getPlugin();
// 3) Add options to create new stored payment methods of supported types.
if (isset($payment_gateways_with_payment_methods[$payment_gateway_id])) {
$payment_gateway_plugin = $payment_gateway->getPlugin();
// Offsite gateways are handled below as they do not require
// per-payment methods forms.
if (isset($payment_gateways_with_payment_methods[$payment_gateway_id]) &&
$payment_gateway_plugin instanceof SupportsCreatingPaymentMethodsInterface) {
$payment_method_types = $payment_gateway_plugin->getPaymentMethodTypes();
foreach ($payment_method_types as $payment_method_type_id => $payment_method_type) {
......@@ -148,7 +152,7 @@ class PaymentOptionsBuilder implements PaymentOptionsBuilderInterface {
else {
$options[$payment_gateway_id] = new PaymentOption([
'id' => $payment_gateway_id,
'label' => $payment_gateway->getPlugin()->getDisplayLabel(),
'label' => $payment_gateway_plugin->getDisplayLabel(),
'payment_gateway_id' => $payment_gateway_id,
]);
}
......
......@@ -739,7 +739,7 @@ class PaymentCheckoutTest extends CommerceWebDriverTestBase {
$this->submitForm([], 'Add to cart');
$this->drupalGet('checkout/1');
$this->assertSession()->fieldNotExists('Visa ending in 1111');
$radio_button = $this->getSession()->getPage()->findField('Credit card (Example Stored Offsite)');
$radio_button = $this->getSession()->getPage()->findField('Example Stored Offsite');
$radio_button->click();
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertRenderedAddress($this->defaultAddress, 'payment_information[billing_information]');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment