• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Payments Plugin for Stripe

Stripe payment plugins for your WordPress site

  • Home
  • Documentation
  • Addons
  • Login
    • Sign In
    • Edit Profile
    • Terms & Conditions
    • My Downloads
    • License Key
  • Support
    • Support Forum
    • Forum Search
    • Forum Login
    • Forum Registration
    • Email Support for Customers
  • Contact Us
  • Show Search
Hide Search
You are here: Home / Replies /

Reply To: I need to hook into the cancel subscription function

· ·

Home › Forums › Stripe Payments Plugin › I need to hook into the cancel subscription function › Reply To: I need to hook into the cancel subscription function

August 31, 2021 at 10:54 am #4235
alexanderfoxc
Participant

Hi Jesper.

There are two hooks related to subscription deletion – asp_subscription_ended and asp_subscription_canceled. The latter is what you need. Here’s how you can hook to it:


add_action ('asp_subscription_canceled', 'asp_subscription_canceled_handler', 10, 2);

function asp_subscription_canceled_handler ($sub_id, $event_data) {
   ASP_Debug_Logger::log(json_encode($event_data));
}

$sub_id is Stripe’s subscription ID
$event_data is event data received from Stripe’s hook.

This code dumps event data into plugin’s debug log (if it’s enabled). This way you would be able to see what kind of data is available.

To trigger the event, just create a subscription in test mode and then cancel it using cancel URL.

Primary Sidebar

Featured Addons and Extensions

  • Subscription Payments Addon
  • Additional Custom Fields
  • Secure Downloads Addon
  • Apple Pay, Google Pay, Afterpay

Addon Bundle

Stripe Payments Addon Bundle

A Simple & Lightweight Plugin

Our Philosophy with the Plugin

Support Links

  • Support Forum
  • Support Contact

Search

Copyright © 2025 | Stripe Plugins | A member of the Tips and Tricks HQ family.