PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

How can I get current billing info and billing history?

Common Questions/Problems/Tips. Posted by Administrators & Support Reps.

How can I get current billing info and billing history?

Postby Zachary » March 23rd, 2011, 2:08 pm

Hello,

We use s2member with pro module and Authorize.NET for subscriptions.

We want to show users their billing history and also current subscription status.

So, questions are:

Is it possible to get current billing information like:
- date and time when user paid last time
- date and time when subscription expires
- amount billed

And history of previous bills with amounts, dates and probably something else is available?

Can't find much info in scripting doc supplied with s2member. Please advice where to look or what functions to use.

Thanks in advance!
User avatar
Zachary
Registered User
Registered User
 
Posts: 1
Joined: March 23, 2011

Re: How can I get current billing info and billing history?

Postby Jason Caldwell » March 23rd, 2011, 5:40 pm

Thanks for the excellent question.

Just to clarify. All financial details, such as pricing, trial periods, subscription lengths, refunds, and other Customer service issues; should be handled through your Payment Gateway account, and not through WordPress®. This is recommend by most Payment Gateways as a "Best Practice" for security; and s2Member follows suit by not storing any financial information in your WordPress® database. If you're using Authorize.Net® you should have an Authorize.Net® account where these details are stored.

Now, to answer your question. While it IS possible to pull extended details through the PayPal® Pro API, Authorize.Net® unfortunately does not provide much detail in this regard. The Authorize.Net® API will only supply you with a general status of the Recurring Profile in your Authorize.Net® account.

Here is a code sample ( requires s2Member Pro v1.5+ )
Code: Select all
<?php
$user 
= wp_get_current_user ();
$subscription_id = get_user_option ("s2member_subscr_id");
$authnet = array ("x_method" => "status", "x_subscription_id" => $subscription_id);
if (($authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_arb_response ($authnet)) && !$authnet["__error"] && $authnet["subscription_status"])
    {
        echo $authnet["subscription_status"];
    /* Possible values: active, expired, suspended, canceled, terminated */
    }
?>
* Inside your s2Member.com account, you can download the s2m-pro-extras.zip file, which contains API docs for the Authorize.Net® ARB service. You may find it helpful to review their API methods.


PayPal®, on the other hand, DOES provide quite a bit of detail.
Code: Select all
<?php
$user 
= wp_get_current_user ();
$subscription_id = get_user_option ("s2member_subscr_id");
$paypal = array ("METHOD" => "GetRecurringPaymentsProfileDetails", "PROFILEID" => $subscription_id);
if (($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response ($paypal)) && !$paypal["__error"])
    {
        print_r($paypal); /* A full list of details during development. */
        /* Please consult the `/s2m-pro-extras/paypal-pro-api.pdf` file. */
    }
?>
* Inside your s2Member.com account, you can download the s2m-pro-extras.zip file, which contains API docs for PayPal® Pro. You may find it helpful to review their API response vars for: GetRecurringPaymentsProfileDetails.
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: How can I get current billing info and billing history?

Postby Jason Caldwell » March 23rd, 2011, 5:44 pm

Is it possible to get current billing information like:
- date and time when user paid last time

Yes, s2Member does record payment times.

These API functions might be helpful:
Code: Select all
<?php
$time 
= s2member_registration_time (); // ... first registration time ( free or otherwise ).
$time = s2member_paid_registration_time (); // ... first "paid" registration and/or upgrade time.
$time = s2member_paid_registration_time ("level1"); // ... first "paid" registration or upgrade time at Level#1.
$time = s2member_paid_registration_time ("level2"); // ... first "paid" registration or upgrade time at Level#2.
$time = s2member_paid_registration_time ("level3"); // ... first "paid" registration or upgrade time at Level#3.
$time = s2member_paid_registration_time ("level4"); // ... first "paid" registration or upgrade time at Level#4.
?>
* You will find further details on these functions in your Dashboard, under:
s2Member -> API Scripting -> Content Dripping.
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: How can I get current billing info and billing history?

Postby Jason Caldwell » March 23rd, 2011, 5:51 pm

s2Member also stores the last payment time.
You can retrieve the timestamp like this.
Code: Select all
<?php $time = get_user_option ("s2member_last_payment_time"); ?>

If you want to pull this information for a specific User ID.
Code: Select all
<?php
$user_id 
= 234;
$time = get_user_option ("s2member_last_payment_time", $user_id);
?>
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA


Return to Common Questions/Problems/Tips

Who is online

Users browsing this forum: No registered users and 2 guests

cron