Last active
April 9, 2021 18:43
-
-
Save robertstaddon/ad8fcea51b2942718b4ded40f4092781 to your computer and use it in GitHub Desktop.
Restrict Content Pro Authorize.net Integration Handle Failed Payments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Subscription payment failed. | |
* | |
* 'payload' => array ( | |
* 'name' => '', // Subscription name | |
* 'amount' => 00.00, // Subscription price | |
* 'status' => 'suspended', // Subscription status | |
* 'profile' => array ( | |
* 'customerProfileId' => 123, | |
* 'customerPaymentProfileId' => 123, | |
* ), | |
* 'transactionDetails" => array ( | |
* 'transId': 123, | |
* 'error': 'This transaction has been declined.', // Transaction error | |
* 'submitTimeUTC": "2021-04-09T09:29:27.257" // Transaction time | |
* ), | |
* 'entityName' => 'subscription', | |
* 'id' => '123', // Subscription ID. | |
* ) | |
* | |
*/ | |
case 'net.authorize.customer.subscription.failed' : | |
$subscription_id = 'anet_' . $event_json['payload']['id']; | |
$membership = rcp_get_membership_by( 'gateway_subscription_id', $subscription_id ); | |
rcp_log( sprintf( 'Processing net.authorize.customer.subscription.failed event type for subscription ID %s.', $subscription_id ) ); | |
if ( empty( $membership ) ) { | |
rcp_log( 'Exiting Authorize.net webhook - unable to find membership.' ); | |
die(); | |
} | |
if ( ! $membership->is_active() ) { | |
rcp_log( sprintf( 'Exiting Authorize.net webhook - membership #%d is not active.', $membership->get_id() ) ); | |
die(); | |
} | |
$member = $this->membership->get_customer()->get_member(); | |
do_action( 'rcp_recurring_payment_failed', $member, $this ); | |
do_action( 'rcp_authorizenet_silent_post_error', $member, $this ); | |
break; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment