Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #2870040 by mglaman: Remove payment method from order if there … #719

Open
wants to merge 3 commits into
base: 8.x-2.x
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ public function buildPaneForm(array $pane_form, FormStateInterface $form_state,
catch (DeclineException $e) {
$message = $this->t('We encountered an error processing your payment method. Please verify your details and try again.');
drupal_set_message($message, 'error');
$this->order->get('payment_gateway')->setValue(NULL);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bojanz If we do not remove this.. then the chain of logic here fails, which is another bug. Not sure if I should fix here or not.

    $default_option = NULL;
    if ($order_payment_method) {
      $default_option = $order_payment_method->id();
    }
    elseif ($order_payment_gateway && !($order_payment_gateway instanceof SupportsStoredPaymentMethodsInterface)) {
      $default_option = $order_payment_gateway->id();
    }

Returns payment gateway... which is not a method.

    $selected_option = $pane_form['payment_method'][$default_option];
    $payment_gateway = $payment_gateways[$selected_option['#payment_gateway']];
    if ($payment_gateway->getPlugin() instanceof SupportsStoredPaymentMethodsInterface) {

This supports no reconciliation for the fact we have a gateway ID. So I suppose the thing to do is remove returning gateway ID?

$this->order->get('payment_method')->setValue(NULL);
$this->redirectToPreviousStep();
}
catch (PaymentGatewayException $e) {
Expand Down