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™

Can I add a member's purchase history to their profile page?

s2Member Plugin. A Membership plugin for WordPress®.

Can I add a member's purchase history to their profile page?

Postby s_d_p » July 27th, 2011, 4:14 pm

I'm using the s2Member Pro plugin in a Wordpress 3.2 installation. I'm wondering if there is an easy way to let users view their purchase history. Ideally, this would go on their profile page (when they click their name). I'm using the recommended setting in which they are redirected to s2Member's profile page (instead of the default Wordpress page). If a member has purchased access to a specific post/page, I'd really like them to see that in their profile. Any thoughts? Thanks in advance.
User avatar
s_d_p
Registered User
Registered User
 
Posts: 23
Joined: July 26, 2011

Re: Can I add a member's purchase history to their profile p

Postby Cristián Lávaque » July 27th, 2011, 5:18 pm

Purchase history for now is available with the payment gateway (e.g. PayPal). An account history is planned for a future release, no date for it yet, though.
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Can I add a member's purchase history to their profile p

Postby s_d_p » July 27th, 2011, 8:07 pm

If I understand correctly, the member could find their purchase history through their PayPal account if they use PayPal, but if they pay with a credit card they can't. Is that right?
User avatar
s_d_p
Registered User
Registered User
 
Posts: 23
Joined: July 26, 2011

Re: Can I add a member's purchase history to their profile p

Postby Cristián Lávaque » July 27th, 2011, 10:37 pm

Ah, I believe that is correct. :|
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Can I add a member's purchase history to their profile p

Postby s_d_p » August 11th, 2011, 10:30 pm

I'm still trying to figure out a work-around to achieve something like a purchase history (for specific post/page access). Are there any constants that I might be able to use to create something like this myself? I see a lot of options for membership levels, etc but nothing referring to specific posts/page access.
User avatar
s_d_p
Registered User
Registered User
 
Posts: 23
Joined: July 26, 2011

Re: Can I add a member's purchase history to their profile p

Postby Cristián Lávaque » August 11th, 2011, 10:48 pm

You could use the Notifications API to have a custom script save that information. WP Admin -> s2Member -> API / Notifications

http://www.s2member.com/api-tracking-no ... ons-video/
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Can I add a member's purchase history to their profile p

Postby s_d_p » August 15th, 2011, 4:25 pm

I'm making a go of this method, and I'm close to getting it to work. However, I can't get the %%cv1%% replacement code to work in the notifications url (everything else gets passed correctly). Here's the code I'm using in my template:

Code: Select all
global $current_user;
get_currentuserinfo();
$user_id = $current_user->ID;

<?php echo do_shortcode('[s2Member-Pro-PayPal-Form sp="1" ids="'.$guide_ID.'" exp="'.$time.'" desc="'.get_the_title($guide_ID).'" ps="paypal" lc="" cc="USD" dg="0" ns="1"'.
       'custom="'.$site_url.'|'.$user_id.'" '.
       'ra="'.$price.'" accept="paypal,visa,mastercard,amex,discover,maestro,solo" accept_via_paypal="paypal" coupon="" accept_coupons="0" default_country_code="" captcha="0" /]'); ?>


Do you see any reason why this shouldn't successfully pass the current user's id as cv1?

Here's the notification URL:
http://my_domain.com/log-payments/?secr ... ccess_url=%%sp_access_url%%&sp_access_exp=%%sp_access_exp%%&txn_id=%%txn_id%%&item_name=%%item_name%%&payer_email=%%payer_email%%&id=%%cv1%%
User avatar
s_d_p
Registered User
Registered User
 
Posts: 23
Joined: July 26, 2011

Re: Can I add a member's purchase history to their profile p

Postby s_d_p » August 16th, 2011, 5:01 pm

I never got a response on this, but in case it's useful to someone else, I seem to have solved the problem on my own...

The custom attribute in the shortcode requires the first item to be the site DOMAIN. I was inserting the site's url, which was causing the entire attribute (including the pipe delimited attributes that followed) to be ignored.

So to demonstrate, this WONT work apparently:
custom="http://www.example.com|custom_thing"

While this WILL:
custom="example.com|custom_thing"

I'm not exactly sure why this is. Even though the change seems to have solved my problem for the moment, I would love to hear a bit of explanation about how those custom parameters are supposed to work.
User avatar
s_d_p
Registered User
Registered User
 
Posts: 23
Joined: July 26, 2011

Re: Can I add a member's purchase history to their profile p

Postby Cristián Lávaque » August 17th, 2011, 3:52 am

That's correct. The first value in the custom attribute must be the value of $_SERVER['HTTP_HOST'].

WP Admin -> s2member -> PayPal Buttons -> Shortcode Attributes (Explained) -> custom
custom="cristian.websharks-inc.net" must start with your domain. Additional values can be piped in ( ex: custom="example.com|cv1|cv2|cv3|etc" ).


I hope that helps. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Can I add a member's purchase history to their profile p

Postby s_d_p » September 22nd, 2011, 1:33 pm

Hi Christian,

I successfully created a purchase history using the method described above. However, we've noticed an infrequent problem that confuses me.

Every now and then, the parameter sp_access_url gets passed as: Error#www.mydomain.com
Obviously this doesn't work. Strangely, most of the time, a working url gets passed that looks something like this: http://tinyurl.com/3lcfs39#www.mydomain.com

Any ideas why this might happen?
User avatar
s_d_p
Registered User
Registered User
 
Posts: 23
Joined: July 26, 2011

Re: Can I add a member's purchase history to their profile p

Postby Cristián Lávaque » September 25th, 2011, 5:50 pm

Could you show me the code you're using, please?

Also, why are you using do_shortcode? It'd be easier to work with the shortcode directly. viewtopic.php?f=36&t=1604
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Can I add a member's purchase history to their profile p

Postby s_d_p » September 25th, 2011, 6:44 pm

I'm using the notifications API to pass the access url variable.

My pro form is generated by this:

Code: Select all
$shortcode '[s2Member-Pro-PayPal-Form sp="1" ids="'.$guide_ID.'" exp="'.$time.'" desc="Purchase '.get_the_title($guide_ID).':" ps="paypal" lc="" cc="USD" dg="0" ns="1"'.
         
' custom="'.$domain.'|'.$current_user_id.'" '
         
'ra="'.$price.'" accept="paypal,visa,mastercard,amex,discover,maestro,solo" accept_via_paypal="paypal" coupon="" accept_coupons="1" default_country_code="" captcha="0" /]'


My notifications url looks like this:

Code: Select all
http://www.mydomain.com/log-payments/?secret_key=SECRET&sp_access_url=%%sp_access_url%%&sp_access_exp=%%sp_access_exp%%&txn_id=%%txn_id%%&item_name=%%item_name%%&payer_email=%%payer_email%%&id=%%cv1%%


The url parameters get sent to a page (/log-payments/) which contains this code:

Code: Select all
if ($_GET) {

$payer_email $_GET['payer_email'];
$guide_name $_GET['item_name'];
$expiration_date $_GET['sp_access_exp'];
$sp_access_url $_GET['sp_access_url'];
$txn_id $_GET['txn_id']; //s2member transaction id
$user_id $_GET['id'];
date_default_timezone_set('America/New_York');
$date date('Y-m-d H:i:s');
//$user_id = 5;

Last edited by Cristián Lávaque on September 27th, 2011, 11:34 pm, edited 1 time in total.
Reason: Improve code readability. http://www.primothemes.com/forums/viewtopic.php?f=36&t=2780
User avatar
s_d_p
Registered User
Registered User
 
Posts: 23
Joined: July 26, 2011

Re: Can I add a member's purchase history to their profile p

Postby Cristián Lávaque » September 27th, 2011, 11:36 pm

Your notification URL and the code in your script seem fine. I wonder why you're getting that odd sp_access_url. I'll ask Jason, but can you please post, x'ing out private info, the log entries related to this problem? WP Admin -> s2Member -> PayPal Options -> Account Details -> Enable Logging
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Can I add a member's purchase history to their profile p

Postby sgtcory » September 28th, 2011, 12:30 am

s_d_p wrote:Error#www.mydomain.com
Obviously this doesn't work. Strangely, most of the time, a working url gets passed that looks something like this: http://tinyurl.com/3lcfs39#www.mydomain.com

Any ideas why this might happen?


Just thought I would jump in here - since I was interested in using your method over my current solution. That second url is the correct url generated for specific post / pages. These urls are shortened via the Tinyurl api in :

/s2member/includes/classes/sp-access.inc.php

Code: Select all
$tinyurl . "#" . $_SERVER["HTTP_HOST"]


So it looks like there was an error when using the tinyurl api - which Jason did account for with an alternate filter to pass the long url - but it also failed.

Not particularly helpful in solving the issue - but might help better to understand that you can bypass the url shortening altogether.

Code: Select all
@param bool $shrink Optional. Defaults to true. If false, the raw link will NOT be processed by the tinyURL API.
Webmaster Services - http://rentedweb.com
User avatar
sgtcory
Experienced User
Experienced User
 
Posts: 24
Joined: May 28, 2011

Re: Can I add a member's purchase history to their profile p

Postby s_d_p » September 28th, 2011, 9:28 pm

@Christian: I'll post my log info the next chance I get.
@sgtcory: That's an interesting idea. Is there any security risk with giving access up front to the access url? It has special parameters tacked on that its best to shield from the user, right? But I guess those appear when they use the link anyway, so maybe it doesn't matter. I'm just throwing this concern out there. Is there any reason besides convenience to use the tinyurl api?
User avatar
s_d_p
Registered User
Registered User
 
Posts: 23
Joined: July 26, 2011

Re: Can I add a member's purchase history to their profile p

Postby sgtcory » September 28th, 2011, 9:43 pm

s_d_p - I suspect it's because the urls for sp_access are long. Looking at the headers for the link example you gave above gives a 301 to :

yoursiteurlhere?s2member_sp_access=fnIyOklndkNBNkRKS1JhREpXdHhQUkhIMGtZSUc4U2c0T1pPfLiA_6EWQAAqutZaN3DsEqD_OIo55fyvwRBD8DkCfIMep5YyCZXj0OjuKepdeyHxfECVhqK2NPs3-kyncVk_PM8

So after you pointed this out - this might not be such a good idea - particularly due to email message wrapping - which might cause the url to break - if sending out links.

Thanks for pointing that out.

I wonder if adding a hook in there via s2-hacks to use even another url shortner might be a better idea in the event that the initial service times out or fails.
Webmaster Services - http://rentedweb.com
User avatar
sgtcory
Experienced User
Experienced User
 
Posts: 24
Joined: May 28, 2011

Re: Can I add a member's purchase history to their profile p

Postby Jason Caldwell » October 1st, 2011, 5:01 pm

Thanks for the heads up on this thread.

It looks like tinyURL has changed the way their API returns on failure,
and this section of s2Member's code needs to be updated to correct the problem.
Code: Select all
else if ($shrink && ($tinyurl = c_ws_plugin__s2member_utils_urls::remote ("http://tinyurl.com/api-create.php?url=" . rawurlencode ($register_link))))
    return apply_filters ("ws_plugin__s2member_register_link_gen", $tinyurl . "#" . $_SERVER["HTTP_HOST"], get_defined_vars ()); 

Needs to be changed to this:
Code: Select all
else if ($shrink && ($tinyurl = c_ws_plugin__s2member_utils_urls::remote ("http://tinyurl.com/api-create.php?url=" . rawurlencode ($register_link))) && stripos ($tinyurl, "http") === 0)
    return apply_filters ("ws_plugin__s2member_register_link_gen", $tinyurl . "#" . $_SERVER["HTTP_HOST"], get_defined_vars ()); 

I'm having this fixed in the next release so the problem is not ongoing.
In addition, we'll add a built-in backup URL shortener as well, so that failures, if/when they do occur, don't result in a long URL all the time.
~ 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: Can I add a member's purchase history to their profile p

Postby Jason Caldwell » October 1st, 2011, 7:01 pm

Confirmed. Changes coming in the next release of s2Member.
* (s2Member) **tinyURL bug fix**. s2Member's handling of potential failures in the output of tinyURLs, generated by the tinyURL API; was NOT considering all possibilities. A symptom of this bug was to see URLs in your Signup Confirmation Email (occassionally, upon connection failure to the tinyURL API, when it was down for whatever reason) starting with: `Error#`. Corrected in this release.

* (s2Member) **URL Shortening API (Preference)**. s2Member now includes a class method dedicated to URL shortening service APIs. Currently, s2Member will use the tinyURL API first *(i.e. tinyurl.com )*, and then use Google's URL Shortening API *(i.e. goo.gl )* as a backup when/if the tinyURL API is down for whatever reason. In this release, a new configurable option is available, which allows advanced site owners to preference the Google Shortening API over tinyURL, if they desire. For further details, please check your Dashboard, under: `s2Member -> General Options -> URL Shortening API (Preference)`.
~ 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 s2Member Plugin

Who is online

Users browsing this forum: Google [Bot] and 4 guests

cron