function mollie_payment_payment_recurring_stop in Mollie Payment 7.2
Same name and namespace in other branches
- 7 mollie_payment.module \mollie_payment_payment_recurring_stop()
Implements hook_payment_recurring_OPERATION() for stop.
File
- ./
mollie_payment.module, line 306 - 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'];
/** @var \Mollie\Api\Resources\Customer $customer */
$customer = $client->customers
->get($customer_id);
/** @var \Mollie\Api\Resources\Subscription $subscription */
$subscription = $client->subscriptions
->cancelFor($customer, $subscription_id);
drupal_set_message(t('The status of @subscription is @status.', array(
'@subscription' => $subscription->description,
'@status' => $subscription->status,
)));
}
}