latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Can you see the price users paid through s2?

Home Forums Community Forum Can you see the price users paid through s2?

This topic contains 1 reply, has 2 voices. Last updated by  Bruce 3 years, 11 months ago.

Topic Author Topic
Posted: Saturday Feb 2nd, 2013 at 1:09 pm #40504

After searching through the forms it may appear I already have my answer.. although not the answering I was hoping for.

Is it possible to see how much a user paid using s2member? Our original price is constantly fluctuating based on coupons and discounts, etc.. but is there a way you can see how much a user paid. I’m not looking for a billing history simply a purchase price.

I checked the database and it doesn’t seem like this information is stored anywhere but before giving up I wanted to check.

And if this feature may be available soon will it be retroactive to show previous users payment as well? Any idea how long soon might be? :)

Thanks

List Of Topic Replies

Viewing 1 replies (of 1 total)
Author Replies
Author Replies
Posted: Sunday Feb 3rd, 2013 at 5:39 am #40543
Bruce
Username: Bruce
Staff Member

Thank-you for your inquiry.

s2Member currently does not store payment details on your site for security reasons. This information is stored securely by your payment gateway (i.e. PayPal, Authorize.net, etc.). However, if you’d like to store this information, s2Member does grant access to this information through API Notifications.

s2Member’s API Notifications are routines that will send data to specific URLs whenever certain events happen in your site. For this functionality you will only need to use Payment Notifications.

See: Dashboard -› s2Member® -› API / Notifications -› Payment Notifications

To use the information provided through s2Member’s API Notifications, you will need to set up an API Notification handler. This requires a bit of code to set up.

See: Knowledge Base » Building An API Notification Handler

To collect the payment amount for a user, you will need the user’s ID, as well as the amount that user paid. Both of these portions of data are available within s2Member’s Replacement Codes for Payment Notifications.

Your API Notification URL might look like this:

http://example.com?s2_payment_notification=yes&s2_amt=%%amount%%&s2_id=%%user_id%%

The above URL passes the amount that the user paid, and their ID as s2_amt, and s2_id, respectively. Now you can set up your API Notification handler. Using the code sample from Building An API Notification Handler as a guide, your handler might do something like the following:

Please create this directory and file:
/wp-content/mu-plugins/s2-payment-notification.php
(NOTE: these are MUST USE plugins, see: http://codex.wordpress.org/Must_Use_Plugins)
(See also: http://www.s2member.com/kb/hacking-s2member/)
<?php
add_action('init', 's2_payment_notification'); 
function s2_payment_notification()
	{
		if(!empty($_GET&#91;'s2_payment_notification'&#93;)) // In my URL, I have `?s2_payment_notification=yes`, that's what I'm looking for here.
			{
				if(!empty($_GET&#91;'s2_id'&#93;) && !empty($_GET&#91;'s2_amt'&#93;)) // In my URL, I have `&s2_id=%%user_id%%&s2_amt=%%amount%%`, that's what I'm looking for here.
					{
						$user_id = (integer)$_GET&#91;'s2_id'&#93;; // I'm expecting an integer in this value.
						$amount = (integer)$_GET&#91;'s2_amt'&#93;; // I'm expecting an integer in this value
						
						// Here I might perform any number of tasks related to this user. Such as creating a user option value in WordPress.
						update_user_option($user_id, 's2member_last_amount_paid', $amount);
					}
				exit; // We can exit here. There's no reason to continue loading WordPress® or my theme during an API Notification.
			}
	}
&#91;/hilite&#93;

The above uses the WordPress function <a href="http://codex.wordpress.org/Function_Reference/update_user_option">update_user_option()</a> to save the amount that this user paid as a User Meta value in your database. This information is saved into the meta field s2member_last_amount_paid

.

To access this information, you can use any of the methods outlined in s2Member’s Shortcode Conditionals with s2Get examples, or with get_user_option().

Example with shortcodes:

[s2Get user_option="s2member_last_amount_paid"]

Example in PHP with get_user_option():

<?php echo get_user_option('s2member_last_amount_paid'); ?>

See: Dashboard -› s2Member® -› API / Scripting -› Simple/Shortcode Conditionals

Please let us know if you have any further questions/concerns. :-)

Viewing 1 replies (of 1 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.