Page 1 of 1

API Call to check status of subscription

PostPosted: February 3rd, 2011, 6:30 am
by MailBeez
hi,

am just evaluating s2member for my project and have been through the nice tutorial videos.

is there any way like this
Code: Select all
check_subscription($user_id)

to check the current status of a subscription?

Or would I need to use the notification API to store the current status per user by myself?

cheers
cord

Re: API Call to check status of subscription

PostPosted: March 4th, 2011, 10:02 pm
by Jason Caldwell
If you're using PayPal® Pro integration, you can do this in PHP.

Code: Select all
<?php
$user_id 
= "1";
$subscr_id = get_user_option("s2member_subscr_id", $user_id);
$paypal = array ("METHOD" => "GetRecurringPaymentsProfileDetails", "PROFILEID" => $subscr_id);
if (($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response ($paypal)) && !$paypal["__error"])
    $status = $paypal["STATUS"];
?>
* this code snippet requires s2Member Pro v1.5+

Possible values for $status are:
Code: Select all
ActiveProfile
PendingProfile
CancelledProfile
SuspendedProfile
ExpiredProfile

Other details about the Recurring Profile are also available in the $paypal array. The fields in this array are documented in the PayPal® Pro API guide, which is included with the latest version of s2Member Pro. Please check your account at s2Member.com for the /s2m-pro-extras.zip file. Inside the zip you will find the API doc. Its file name is: paypal-pro-api.pdf. In the PDF, you'll want to read the section on the Response Vars for "GetRecurringPaymentsProfileDetails".
Code: Select all
print_r($paypal); // spits out a full list of variables during testing.