The s2m Billing Update Form allows a member to update the credit-card in his Paypal billing profile. But this alone does not actually:
1) re-activate his subscription profile at Paypal, nor
2) un-demote him on my site.
TO RE-ACTIVATE THE PROFILE AT PAYPAL
According to the Paypal Website Payments Pro API documentation pdf (pg68), we need to:
- first, use UpdateRecurringPaymentsProfile to increase the Maximum number of Failed Payments.
- then, use ManageRecurringPaymentsProfileStatus to change his paypal billing Status from Suspended to Active.
TO UN-DEMOTE THE MEMBER ON MY SITE
Then s2m needs to un-demote / revert his Role from "Suspended" (the name of my Level-0 / Demoted role), to the role he originally had on my site (either Individual or Group), to restore his access to my protected content.
Paypal does not send an IPN for status changes (see pdf pg71-72), so I can't use s2m api Notifications. Instead I need to make s2m do it based only on a success response from the final api call (ManageRecurringPaymentsProfileStatus), after the member submits the Billing Update form.
I actually was able to accomplish all this -- by directly editing an s2m file (s2member-pro/includes/classes/gateways/paypal/paypal-update-in.inc.php) -- but obviously "hacking" s2m is a bad idea, since i'll lose my changes on the next update. Unfortunately there are NO HOOKS there (yet?!) to use instead. Here's the idea, pretty simple really:
- Code: Select all
# RE-ACTIVATE PAYPAL BILLING PROFILE
// place below on line 101, after ZIP.
$paypal["MAXFAILEDPAYMENTS"] = 3;
// place below on line 111, after sending updated billing info to paypal.
$paypal = array (); /* Reset the PayPal® array. */
$paypal["METHOD"] = "ManageRecurringPaymentsProfileStatus";
$paypal["PROFILEID"] = $cur__subscr_id;
$paypal["ACTION"] = "Reactivate";
$paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response ($paypal); // ToDo: put back the if() and __error check .
#UNDEMOTE MEMBER IN SITE / S2M
//ToDo: get user's original Role (stored in s2m field 'custom' as 'cv1'), put in $orig_role;
$member_obj = new WP_User($user_id);
$member_obj->set_role($orig_role);
* NOTE -- This code is draft / proof-of-concept only; still needs error handling, another level of if() nesting, and a conditional to run it only if member is suspended and has not cancelled.
So.. I think this would basically work, and would be great functionality for my site, so I'd love to be able to use this approach. But without the necessary Hook(s), I shouldn't do it.
* JASON -- ANY CHANCE OF ADDING THESE HOOKS TO THE COMING RELEASE ? *
ALTERNATIVE APPROACH
Another approach to enabling a member to re-activate himself, is not fully-automatic. I think I can use a Success URL (Custom Return URLs on Success) in my ShortCode for the Billing Update Form, so a successful submission hits a url for a wp page that uses a custom template file, with the same php above to UnDemote the member, and then also send an email to the site owner to notify him to go into Paypal and MANUALLY Re-Activate the billing profile. Not an ideal situation, since it's not fully automated, but maybe better than hacking s2m files.