You are here

protected function RecurringJobTypeBase::handleFailedOrder in Commerce Recurring Framework 8

Handles an order whose payment has definitively failed.

Parameters

\Drupal\commerce_order\Entity\OrderInterface $order: The order.

bool $save_order: Whether the order should be saved after the operation.

2 calls to RecurringJobTypeBase::handleFailedOrder()
RecurringJobTypeBase::handleDecline in src/Plugin/AdvancedQueue/JobType/RecurringJobTypeBase.php
Handles a declined order payment.
RecurringOrderClose::process in src/Plugin/AdvancedQueue/JobType/RecurringOrderClose.php
Processes the given job.

File

src/Plugin/AdvancedQueue/JobType/RecurringJobTypeBase.php, line 125

Class

RecurringJobTypeBase
Provides a base class for recurring job types.

Namespace

Drupal\commerce_recurring\Plugin\AdvancedQueue\JobType

Code

protected function handleFailedOrder(OrderInterface $order, $save_order = TRUE) {
  $order
    ->getState()
    ->applyTransitionById('mark_failed');

  /** @var \Drupal\commerce_recurring\Entity\BillingScheduleInterface $billing_schedule */
  $billing_schedule = $order
    ->get('billing_schedule')->entity;
  $unpaid_subscription_state = $billing_schedule
    ->getUnpaidSubscriptionState();
  if ($unpaid_subscription_state != 'active') {
    $this
      ->updateSubscriptions($order, $unpaid_subscription_state);
  }
  if ($save_order) {
    $order
      ->save();
  }
}