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

[ENHANCEMENT] Use the pmpro_handle_subscription_cancellation_at_gateway() function #58

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,9 @@
case 'Cancellation':

$subscription_id = sanitize_text_field( $response['subscriptionId'] );

$morder = new MemberOrder();
$morder->getLastMemberOrderBySubscriptionTransactionID( $subscription_id );
$morder->getMembershipLevel();
$morder->getUser();

if(pmpro_ccbill_RecurringCancel($morder))
pmpro_ccbill_Exit();

pmpro_ccbill_webhook_log( pmpro_handle_subscription_cancellation_at_gateway( $subscription_id, 'ccbill', 'live' ) );
pmpro_ccbill_Exit();
break;

case 'RenewalSuccess':
Expand Down Expand Up @@ -341,7 +336,16 @@ function pmpro_ccbill_AddRenewal( array $response, $status = 'success' ) : void

}

/**
* Cancel level for a subscription. Deprecated, call pmpro_handle_subscription_cancellation_at_gateway instead.
*
* @param MemberOrder $morder The order object.
* return bool True if the cancellation was successful, false otherwise.
* @since TBD
* @deprecated TBD
*/
function pmpro_ccbill_RecurringCancel( $morder ) {
_deprecated_function( __FUNCTION__, 'TBD', 'pmpro_handle_subscription_cancellation_at_gateway' );

global $pmpro_error;
$worked = pmpro_cancelMembershipLevel( $morder->membership_level->id, $morder->user_id, 'inactive' );
Expand Down