Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regarding Cancel Subscription Function #41

Closed
knit-pay opened this issue Feb 11, 2021 · 3 comments · Fixed by #75
Closed

Regarding Cancel Subscription Function #41

knit-pay opened this issue Feb 11, 2021 · 3 comments · Fixed by #75

Comments

@knit-pay
Copy link
Contributor

I think in the handle_subscription_cancel function, we should call the cancel_subscription function of Gateway also. In some payment gateway, we need to make an API call to inform the gateway that the subscription is canceled. Apart from this, is there any other way to make an API call while executing the handle_subscription_cancel function? Or is there an action similar to pronamic_payment_status_update_ which we can use to execute a function when a subscription gets canceled? Please refer to the code mentioned below.

https://github.com/wp-pay/core/blob/88ac1e26ae754cb2366697023f38f6004dbd15bb/src/Subscriptions/SubscriptionsModule.php#L152

https://github.com/wp-pay/core/blob/88ac1e26ae754cb2366697023f38f6004dbd15bb/src/Core/Gateway.php#L431

@knit-pay
Copy link
Contributor Author

Hello Team

Is there an update on this?

@rvdsteege
Copy link
Member

Seems we don't use (and never have) the Gateway::update_subscription() and Gateway::cancel_subscription() methods ourselves. We might remove these, @remcotolsma?

/**
* Handle subscription update.
*
* @param Payment $payment The payment to handle subscription update for.
* @return void
*/
public function update_subscription( Payment $payment ) {
}
/**
* Handle subscription cancellation.
*
* @param Subscription $subscription The subscription to handle cancellation for.
* @return void
*/
public function cancel_subscription( Subscription $subscription ) {
}

@knit-pay you should be able to hook into subscription status updates through the status update actions.

/**
* Subscription status updated for plugin integration source from old to new status.
*
* [`{$source}`](https://github.com/pronamic/wp-pronamic-pay/wiki#sources)
* [`{$old_status}`](https://github.com/pronamic/wp-pronamic-pay/wiki#subscription-status)
* [`{$new_status}`](https://github.com/pronamic/wp-pronamic-pay/wiki#subscription-status)
*
* @param Subscription $subscription Subscription.
* @param bool $can_redirect Flag to indicate if redirect is allowed after the subscription update.
* @param null|string $previous_status Previous [subscription status](https://github.com/pronamic/wp-pronamic-pay/wiki#subscription-status).
* @param null|string $updated_status Updated [subscription status](https://github.com/pronamic/wp-pronamic-pay/wiki#subscription-status).
*/
do_action( 'pronamic_subscription_status_update_' . $source . '_' . $old_status . '_to_' . $new_status, $subscription, $can_redirect, $previous_status, $updated_status );
/**
* Subscription status updated for plugin integration source.
*
* [`{$source}`](https://github.com/pronamic/wp-pronamic-pay/wiki#sources)
*
* @param Subscription $subscription Subscription.
* @param bool $can_redirect Flag to indicate if redirect is allowed after the subscription update.
* @param null|string $previous_status Previous [subscription status](https://github.com/pronamic/wp-pronamic-pay/wiki#subscription-status).
* @param null|string $updated_status Updated [subscription status](https://github.com/pronamic/wp-pronamic-pay/wiki#subscription-status).
*/
do_action( 'pronamic_subscription_status_update_' . $source, $subscription, $can_redirect, $previous_status, $updated_status );
/**
* Subscription status updated.
*
* @param Subscription $subscription Subscription.
* @param bool $can_redirect Flag to indicate if redirect is allowed after the subscription update.
* @param null|string $previous_status Previous [subscription status](https://github.com/pronamic/wp-pronamic-pay/wiki#subscription-status).
* @param null|string $updated_status Updated [subscription status](https://github.com/pronamic/wp-pronamic-pay/wiki#subscription-status).
*/
do_action( 'pronamic_subscription_status_update', $subscription, $can_redirect, $previous_status, $updated_status );

@knit-pay
Copy link
Contributor Author

@knit-pay you should be able to hook into subscription status updates through the status update actions.

Thanks

remcotolsma added a commit that referenced this issue Sep 29, 2022
@remcotolsma remcotolsma linked a pull request Sep 29, 2022 that will close this issue
rvdsteege added a commit that referenced this issue Sep 29, 2022
…-function

Remove `Gateway->update_subscription()` and `Gateway->cancel_subscription()` methods.

#41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants