class DunningSubscriber in Commerce Recurring Framework 8
Sends an email when the payment is declined for a recurring order.
Hierarchy
- class \Drupal\commerce_recurring\EventSubscriber\DunningSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of DunningSubscriber
1 string reference to 'DunningSubscriber'
1 service uses DunningSubscriber
File
- src/
EventSubscriber/ DunningSubscriber.php, line 13
Namespace
Drupal\commerce_recurring\EventSubscriberView source
class DunningSubscriber implements EventSubscriberInterface {
/**
* The payment declined mail service.
*
* @var \Drupal\commerce_recurring\Mail\PaymentDeclinedMail
*/
protected $paymentDeclinedMail;
/**
* Constructs a new DunningSubscriber object.
*
* @param \Drupal\commerce_recurring\Mail\PaymentDeclinedMail $payment_declined_mail
* The payment declined mail service.
*/
public function __construct(PaymentDeclinedMail $payment_declined_mail) {
$this->paymentDeclinedMail = $payment_declined_mail;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events = [
RecurringEvents::PAYMENT_DECLINED => [
'sendPaymentDeclinedEmail',
-100,
],
];
return $events;
}
/**
* Sends a payment declined email.
*
* @param \Drupal\commerce_recurring\Event\PaymentDeclinedEvent $event
* The event we subscribed to.
*/
public function sendPaymentDeclinedEmail(PaymentDeclinedEvent $event) {
if (empty($event
->getOrder()
->getEmail())) {
return;
}
$this->paymentDeclinedMail
->send($event
->getOrder(), $event
->getRetryDays(), $event
->getNumRetries(), $event
->getMaxRetries());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DunningSubscriber:: |
protected | property | The payment declined mail service. | |
DunningSubscriber:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
DunningSubscriber:: |
public | function | Sends a payment declined email. | |
DunningSubscriber:: |
public | function | Constructs a new DunningSubscriber object. |