Page 1 of 1

Buy Now download fails

PostPosted: March 14th, 2011, 7:33 pm
by adherent
Thank you for the great plugin. Each time I install a new functionality I sort out my failures until I get the desired result. I set up my first Buy Now button. When visitors not logged-in are shown the Member Option page they are given a choice to buy an ebook at retail price.

When the Buy Now button is clicked, the visitor is sent to paypal, completes the transaction, an email with a link to the download page is sent, and the customer is redirected to the download page right after the transaction. So far so good all works as desired.

Problem is, when the download button is clicked, instead of getting the download the customer is redirected to the Member Options page.

When I log-in as a free member I can access the download page and get the product but that defeats the option of buying without having to sign up.

Any ideas what can be done to get the download to work without signing up?

I'm using WP 3.1 and s2Member 3.5.2 in a multi-site environment.

Brian

Re: Buy Now download fails

PostPosted: March 14th, 2011, 8:25 pm
by Cristián Lávaque
You could have the file not be protected from download by s2Member, just host it normally and give the download link through the protected page only.

If you have an Amazon S3 account, you could try a plugin like Amazon S3 Expiring URL Generator to make it harder for the person to hotlink to the file, or share the file's URL. Although, if someone's to share a file, he can share the file itself.

Does this help you?

Re: Buy Now download fails

PostPosted: March 15th, 2011, 11:06 am
by adherent
Thanks for your response Christian. The pages I sell access to are member download pages. The download pages contain multi-part video courses with ebooks and use s2member to manage access and specifically protect those files from hotlinking.

One option I thought of is to use a store plugin to manage retail sales but that would complicate and duplicate a lot of work.

The s2Member buy now button appears to present a more functional alternative except the download requires a customer to log-in. Although the site is set-up for level#0 free subscriber access, subscription would defeat the option of buying without having to sign up.

Before I accept the download protection limitation, (and limits to my fuzzy logic) I'd appreciate any ideas about what can be done to keep page and file protection the way they are and offer retail customers the option to buy access to protected downloads without signing up.

Re: Buy Now download fails

PostPosted: March 15th, 2011, 8:18 pm
by Jason Caldwell
Thanks for bringing this to my attention Cristián.
What you'll want to do is use s2Member's Advanced Download Restrictions. Which is to say, you'll want to use a Download Key on the end of your download links. You'll find further details on this in your Dashboard under: s2Member -> Download Options -> Advanced Download Restrictions.
This is recommended when your Customers are NOT logged-in.
By default, s2Member uses your Basic Download Restrictions. However, you can force s2Member to allow file downloads, using an extra query string parameter ( s2member_file_download_key ). A file download `Key` is passed through this parameter, and it tells s2Member to allow the download of a particular file, regardless of Membership Level; and WITHOUT a Customer login being required.

When s2member_file_download_key = a valid Key, it works independently from Member Level Access. That is, a visitor does NOT have to be logged in to receive access; they just need a valid Key. Using this advanced technique, you could extend s2Member's file protection routines, or even combine them with Specific Post/Page Access, and more. The possibilities are limitless really.

Code: Select all
http://localhost/wordpress/?s2member_file_download=example-file.zip&s2member_file_download_key=<?php echo s2member_file_download_key("example-file.zip"); ?>
* Note. In order for this to work, you will also need to have a PHP Execution plugin installed so the s2Member Download Key can be generated from within a Post or Page. Please see: http://wordpress.org/extend/plugins/php ... on-plugin/

Re: Buy Now download fails

PostPosted: March 16th, 2011, 11:15 am
by adherent
Thank you Jason, here is my experience so far..

I upgraded s2Member plugin yesterday to v 3.5.4

I applied the advanced download restriction but get - 503 ( Invalid Key ): Sorry, your access to this file has expired. Please contact Support for assistance.

I am developing the site on a mac using firefox so payment and download cookies are set in my firefox browser

Behavior noted so far:

When logged in as admin in Firefox a key is generated for the advanced download restriction but when clicked returns a 503 ( Invalid Key ) error. Other links on the page appear to work as specified. When I access the download page as a customer without logging in I get the same 503 message.

For Opera and Chrome when I logged in as admin different keys are generated for the advanced download restriction but return the 503 ( Invalid Key ) error when clicked. Other links on the page appear to work as specified.

Oddest behavior occurs in Safari when logged in as admin and I try to access the download page it redirects to the member option page. Other pages appear to work to specification.

Although the advanced download restriction code appears to be generating different access keys I am not getting the desired result.

Any ideas on what can be done next are sincerely appreciated.

Re: Buy Now download fails

PostPosted: March 18th, 2011, 7:04 pm
by Jason Caldwell
Maybe it will help to explain what a Download Key actually is.
The function `s2member_file_download_key()`, is part of the s2Member API. It produces a time-sensitive File Download Key that is unique to each and every visitor. Each Key it produces ( at the time it is produced ), will be valid for the current day, and only for a specific IP address and User-Agent string; as detected by s2Member. This makes it possible for you to create links on your site, which provide access to protected file downloads; and without having to worry about one visitor sharing their link with another. So let's take a quick look at what s2member_file_download_key() actually produces.

This recommended ( secure ) method of creating a Download Key:
Code: Select all
<?php echo s2member_file_download_key ("example-file.zip"); ?>
 = A Download Key ( i.e. a site-specific hash ) of:
s2member_xencrypt(date("Y-m-d") . $_SERVER["REMOTE_ADDR"] . $_SERVER["HTTP_USER_AGENT"] . $file)


An undocumented feature also exists for this API function. ( note the second function argument )
Code: Select all
<?php echo s2member_file_download_key ("example-file.zip", "universal"); ?> 
 = A Universal Download Key that provides open access to everyone and anyone;
regardless of time, date, browser, or IP address. In other words, this Key variation is NOT secure.


When logged in as admin in Firefox a key is generated for the advanced download restriction but when clicked returns a 503 ( Invalid Key ) error. Other links on the page appear to work as specified. When I access the download page as a customer without logging in I get the same 503 message.
Hmm. Can you please post the full code snippet of your link and the call to the s2member_file_download_key() function please?
I'll be happy to have a look for you.

Re: Buy Now download fails

PostPosted: March 19th, 2011, 4:27 pm
by adherent
The problem now appears resolved.

Four days ago I set a Buy Now button on a Member Options page. Everything worked as indicated above. I also set code [below] on the restricted member download page to test download of one of the products.
Code: Select all
<a href="http://www.mysite.com/?s2member_file_download=member-subdirectory/product-subdirectory/product-filename.zip&s2member_file_download_key=<?php echo s2member_file_download_key("product-filename"); ?>"><img height="52" width="150" src="http://www.mysite.com/image/image-filename.png" title="Product File Name" alt="" /></a>


Three things have changed since I last posted 4 days ago...
1. I updated s2Member to v 3.5.5
2. The cookie for the first test transaction expired
3. I removed the download key from my test link

After updating s2member and making another test purchase I noticed:
1. I could access the protected page without logging in and
2. The code [above] I used to test the download still generated the 503 error.
3. Other products on the restricted page could be downloaded as desired

So, I removed the download key and returned the test download link to its original setting similar to the other products on the page.

The page is now protected by membership and members can download. When access to the protected download page is purchased, a time limited secure access is emailed to customer, the customer gets immediate access to download page without logging in and customer can return to the download page within the time limit and without logging in to download. Now everything works as expected.

As for Safari users, it appears that unlike other browsers, cookies need to be manually removed in order to notice changes to updated code.

Thank you Jason and crew for code that works and support that helps us to get it to work.

Re: Buy Now download fails

PostPosted: March 21st, 2011, 8:14 pm
by Jason Caldwell
Thanks for reporting back on this topic.
~ Much appreciated!