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™

Ashop Intergration to S2member

s2Member Plugin. A Membership plugin for WordPress®.

Ashop Intergration to S2member

Postby gregtampa » April 21st, 2011, 1:02 pm

Hi,
It appears that the function to generate registration links, which is required for the AShop integration, has been completely removed in newer versions of s2member. The version that was used for the AShop integration is 3.2.7. Using later versions will not currently work.


Below is the step by step guide on integrating with Ashop:
2.26.10 S2Member
The free s2member plugin for Wordpress can be used to run a membership site where some content is
only available to paying members. You can configure 4 different levels of memberships to give access to
different parts of your website depending on what type of membership your customers have bought.
AShop can be used to sell access to multiple s2member sites through the s2member fulfilment module.
Prepare the Wordpress site
First of all you need to install the s2member plugin on your Wordpress site and configure it. How to do
this is explained in the s2member documentation. Next, you need to prepare your Wordpress theme to
Installation & Setup make it accept calls from your AShop to register members. Inside the functions.php file for your Wordpress theme, insert a code like this:

Code: Select all
/* AShop remote registration payment */
add_action("init", "make_registrationlink");
function make_registrationlink(){
    $secretkey = "myownsecrectkey";
    if($_GET["make_registrationlink"]){
        $subscr_id = $_GET["orderid"];
        $custom = $_SERVER["HTTP_HOST"];
        $item_number = $_GET["item"];
        $reg = $_GET["reg"];
        $checkreg = md5($subscr_id.$item_number.$secretkey);
        if ($checkreg == $reg) {
            $link = ws_plugin__s2member_register_link_gen ($subscr_id, $custom,
            $item_number, TRUE);
            echo "<!-- StartAShopS2Member-$link-EndAShopS2Member -->";
            exit;
        }
    }
}
 


Make sure to change the $secretkey variable to your own personal key for this site.
Prepare your AShop
1. Add a fulfilment option on the page Configuration->Fulfilment in your AShop admin panel. Use the
S2Member Registration method.
2. Set the URL field to the URL of your s2member site.
3. Set the Password field to the value of your $secretkey, which you previously added to the functions.
php page of your s2member site.
4. Create or locate a product on the Edit Catalog page and click Attributes.
5. Add an attribute for the membership level, for example labeled "Level". If you want this to be customer
selectable so your customers can buy different membership levels through the same product, add 4
alternatives, otherwise add just 1.
6. Set the attribute alternative(s) to the s2member membership level(s), for example "1" or "4".
7. Click the Fulfilment button for the product you just prepared and select the s2member fulfilment option
you created previously.
8. Set the name of the level attribute to: level
Note: The name of the attribute on the fulfilment configuration page is case sensitive and must be
exactly "level", not "Level" or "LEVEL" or "membershiplevel".
Now your customers will be given a temporary link that allows them to sign up at your s2member site
when they buy
the product. It will be included in the receipt that is emailed to the customer after successful payment.
By setting up
multiple fulfilment options and/or products you can sell different membership levels or even memberships
at different s2member sites.


----------------------------------------------

here is the code for s2member.ff from ashop/admin/fulfilment

Code: Select all
<?php
// S2Member Registration...
$fulfilmentname = "S2Member Registration";
   
$ff_parameters
['fulfilemail'] = "false";
$ff_parameters['fulfilmessage'] = "false";
$ff_parameters['userid'] = "false";
$ff_parameters['password'] = "true";
$ff_parameters['url'] = "true";
$ff_parameters['parameternames'] = "false";
$ff_parameters['extrafields'] = "false";
$ff_parameters['returnresult'] = "true";
$ff_parameters['discount'] = "false";
$ff_parameters['ecardimage'] = "false";
$ff_parameters['ecardfont'] = "false";
$ff_parameters['ecardtextcolor'] = "false";
$ff_parameters['ecardtexttop'] = "false";
$ff_parameters['ecardtextleft'] = "false";
$ff_parameters['ecardtextright'] = "false";

$ff_prodparameters['productid'] = "false";
$ff_prodparameters['productidlist'] = "false";
$ff_prodparameters['labelnumber'] = "false";
$ff_prodparameters['packagenumber'] = "false";
$ff_prodparameters['parameternames'] = "true";

if ($dofulfilment) {
    $returnmessages["$fulfilmentoptionid"] = "";
    if($productsinfo) foreach($productsinfo as $productnumber => $productinfo) {
        $quantity = $productinfo["quantity"];
        $paramquerystring = $productinfo["ffparamquerystring"];
        $paramarray = explode("&",$paramquerystring);
        if (!empty($paramarray) && is_array($paramarray)) foreach ($paramarray as $thisparameter) {
            $thisparameterarray = explode("=",$thisparameter);
            if ($thisparameterarray[0] == "level") $s2member_level = $thisparameterarray[1];
        }

        $s2member_reg = md5($parsed_invoice.$s2member_level.$fulfilmentpassword);
        $s2member_data = "make_registrationlink=1&orderid=$parsed_invoice&item=$s2member_level&reg=$s2member_reg";

        if (!empty($parsed_invoice) && !empty($s2member_level) && !empty($fulfilmenturl) && !empty($fulfilmentpassword)) {
            for ($item = 0; $item < $quantity; $item++) {
                $ch = curl_init ($fulfilmenturl);
                curl_setopt ($ch, CURLOPT_POST, true);
                curl_setopt ($ch, CURLOPT_POSTFIELDS, $s2member_data);
                curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
                $res = curl_exec ($ch);

                // Process return value...
                $res = explode("<!-- StartAShopS2Member-",$res);
                $res = explode("-EndAShopS2Member -->",$res[1]);
                $registrationurl = $res[0];

                // Check the result...
                if (!empty($registrationurl) && (strstr($registrationurl,"http://tinyurl.com") || strstr($registrationurl,$s2memberurl))) {
                    // Return message with URL...
                    if ($receiptformat == "html") $returnmessages["$fulfilmentoptionid"] .= "<tr><td colspan=\"2\"><table width=\"100%\" cellpadding=\"5\"><tr><td bgcolor=\"#ffffff\" align=\"left\"><font face=\"Arial, Helvetica, sans-serif\" size=\"2\"><a href=\"$registrationurl\">Click here</a> to activate your membership at: $fulfilmenturl</font></td></tr></table></td></tr>";
                    else $returnmessages["$fulfilmentoptionid"] .= "
                    Go to: $registrationurl to activate your membership.
                    "
;
                } else $returnmessages["$fulfilmentoptionid"] .= "The membership signup was unsuccessful! Call the shop owner to get your membership activated manually.";
            } 
        
} else $returnmessages["$fulfilmentoptionid"] .= "The membership signup was unsuccessful! Call the shop owner to get your membership activated manually.";
    }
}
?>



Any assistance in making a new method on doing this would be awesome!
Last edited by Cristián Lávaque on April 21st, 2011, 1:40 pm, edited 1 time in total.
Reason: Improve code readability. http://www.primothemes.com/forums/viewtopic.php?f=36&t=2780
User avatar
gregtampa
Registered User
Registered User
 
Posts: 7
Joined: April 21, 2011

Re: Ashop Intergration to S2member

Postby Cristián Lávaque » April 21st, 2011, 1:49 pm

Hi Greg. :)

I'm not familiar with Ashop, but I suggest you contact the developer that originally wrote that code you posted, so he updates it to work with the latest s2Member. Where was it posted originally? Tell him he can post in this thread if he has questions he'd like help with.
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: Ashop Intergration to S2member

Postby gregtampa » April 21st, 2011, 2:01 pm

Will do, I installed version 3.2.7 of your plugin and testing it now.
I will try to figure out whats going on code behind and provide a solution if the original developers of ashop can not. I will post a link to this thread on there forums.
User avatar
gregtampa
Registered User
Registered User
 
Posts: 7
Joined: April 21, 2011

Re: Ashop Intergration to S2member

Postby Cristián Lávaque » April 21st, 2011, 2:19 pm

Great. :)

By the way, the latest release of s2Member is 3.5.8. https://wordpress.org/extend/plugins/s2 ... changelog/
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: Ashop Intergration to S2member

Postby gregtampa » April 22nd, 2011, 10:35 am

I understand, that is the version that the registration function was changed to a class. I re-installed the downgraded version since Ashop pretty much told me I need to use that version.
here is the email that they sent me
"Hi,
It appears that the function to generate registration links, which is required for the AShop integration, has been completely removed in newer versions of s2member. The version that was used for the AShop integration is 3.2.7. Using later versions will not currently work.

I will check with Primo Themes (the makers of s2member) if they have added a new way to do this to their software and try to get it running in AShop as soon as possible.

Thank you for bringing this to my attention!

Best regards,
Andreas Rimheden
www.ashopsoftware.com
"
User avatar
gregtampa
Registered User
Registered User
 
Posts: 7
Joined: April 21, 2011

Re: Ashop Intergration to S2member

Postby Cristián Lávaque » April 22nd, 2011, 1:42 pm

I did a quick search in s2Member 3.5.8's files for "registration link" and got these results back:

Code: Select all
"s2member\includes\classes\register-access.inc.php"(22,15):            Generates registration links.
"s2member\includes\classes\register-in.inc.php"(22,13):            Handles registration links.
"s2member\includes\classes\register.inc.php"(22,13):            Handles registration links.


Tell them about that, maybe that's what they want.

Let me know if 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: Ashop Intergration to S2member

Postby gregtampa » April 22nd, 2011, 1:51 pm

Will do, the developer of AShop said this
"I am looking into using their new IPN Proxy Key feature instead to integrate with AShop. This should make it much cleaner and easier to use and will hopefully be kept in future versions of s2member as well."
User avatar
gregtampa
Registered User
Registered User
 
Posts: 7
Joined: April 21, 2011

Re: Ashop Intergration to S2member

Postby Cristián Lávaque » April 22nd, 2011, 2:58 pm

Cool. :)
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: Ashop Intergration to S2member

Postby ashopsoftware » April 22nd, 2011, 8:57 pm

I originally used a method I found on this forum where you could manually generate a registration link, which didn't have to go through PayPal, but this appears to have been completely removed in later versions of s2member. Is there an alternative to the old make_registrationlink()?

Anyway, I read about the new proxy key IPN feature and have been trying to make that one work. According to my logs, my own custom IPNs have been accepted by my s2member and I got a confirmation email for the first one I sent, but it had this text:

Complete your registration here:
Error#www.domain.com

(where "www.domain.com" actually was the domain I run my test installation on) instead of a proper registration link. Subsequent tries with different customer details have not generated any confirmation emails at all, though the IPN log still tells me that it should have been sent. It has a message about the registration being added to a Transient Queue. Could this queue have been messed up somehow? Where do I look for it in the database so I can reset it and start over fresh? What am I missing that causes the registration link in the confirmation to become that "Error#" text?

Best regards,
Andreas Rimheden
Lead developer of AShop
User avatar
ashopsoftware
Registered User
Registered User
 
Posts: 2
Joined: April 22, 2011

Re: Ashop Intergration to S2member

Postby ashopsoftware » April 22nd, 2011, 9:16 pm

I solved the problem. I had probably run too many tests on my s2member installation. Uninstalling and reinstalling s2member made it work. The "Error#" seems to be related to a problem with tinyurl, since that's what was supposed to be there. Probably just a temporary connection issue between my server and tinyurl. It's working just fine now, so I will go ahead and add this new method to AShop for s2member shopping cart integration.
User avatar
ashopsoftware
Registered User
Registered User
 
Posts: 2
Joined: April 22, 2011

Re: Ashop Intergration to S2member

Postby Cristián Lávaque » April 22nd, 2011, 9:34 pm

Awesome! :)
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


Return to s2Member Plugin

Who is online

Users browsing this forum: No registered users and 1 guest

cron