rcp_membership_payment_profile_cancelled

Filters whether or not a gateway subscription has been successfully cancelled. Third party gateways should use this to process cancellations and return true if the cancellation was successful, or WP_Error if not.

Parameters:

  • $success (true|WP_Error) - True if the cancellation was successful, WP_Error object if not.
  • $gateway (string) - Gateway slug. Make sure to only process cancellations if this value matches your gateway slug.
  • $gateway_subscription_id (string) - Gateway subscription ID. This is the subscription to cancel in the gateway.
  • $membership_id (int) - ID of the membership being cancelled.
  • $membership (RCP_Membership) - Membership object.

Example:

function rcp_elements_cancel( $success, $gateway, $gateway_subscription_id, $membership_id, $membership ) {
	// If it was already cancelled or not Stripe Elements gateway, bail.
	if ( $success || $gateway !== 'stripe_elements' ) {
		return $success;
	}

	return rcp_stripe_cancel_membership( $gateway_subscription_id );
}
add_filter( 'rcp_membership_payment_profile_cancelled', 'rcp_elements_cancel', 10, 5 );