You are here

function mollie_payment_payment_recurring_stop in Mollie Payment 7

Same name and namespace in other branches
  1. 7.2 mollie_payment.module \mollie_payment_payment_recurring_stop()

Implements hook_payment_recurring_OPERATION() for stop.

File

./mollie_payment.module, line 159
Provides Mollie integration for the Payment platform.

Code

function mollie_payment_payment_recurring_stop(Payment $payment) {

  // Initialize the client.
  $client = mollie_payment_get_client($payment);
  if ($payment && $client) {
    $customer_id = $payment->context_data['payment']['customer'];
    $subscription_id = $payment->context_data['payment']['subscription'];
    $subscription = $client->customers_subscriptions
      ->withParentId($customer_id)
      ->cancel($subscription_id);
    drupal_set_message(t('The status of @subscription is @status.', array(
      '@subscription' => $subscription->description,
      '@status' => $subscription->status,
    )));
  }
}