WishList Member includes a generic integration option which can be used with a payment provider.
Please Note: More info on generic integration can be found in the Generic Integration Summary article.
The integration process can be accomplished in four (4) steps:
POST Values
WishList Member expects a certain set of variables and a hash key to be sent to it via HTTP POST. These variables are:
Variable | Value |
cmd | CREATE – creates a new account DEACTIVATE – deactivates the membership levels of the specified transaction ID ACTIVATE – reactivates the membership levels for the specified transaction ID |
lastname | Member's lastname |
firstname | Member's firstname |
Member's email address | |
level | Membership Level SKU |
transaction_id | Transaction ID. When deactivating or reactivating membership levels, this variable has to contain the value that was used when the membership level was created |
hash | Hash key. View instructions below on how to create the hash key. |
Generating the Hash Key
The hash key is just an MD5 hash of the following string:
cmd__secretkey__UppercasePipeDelimitedPostdata
Example:
secretkey : MysecretKEY
cmd : CREATE
lastname : Baggins
firstname : Frodo
email : frodo@shire.com
level : 1234567890
transaction_id : XYZ123456
The string to hash would be:
CREATE__MYsecretKEY__BAGGINS|FRODO|FRODO@SHIRE.COM|1234567890|XYZ123456
The MD5 hash of the above string is:
63b8040b5407eac097b86b73e2fe4523
Return Value
Upon a successful transaction, WishList Member will return a plain text message that will have the same value as the cmd variable that was passed. If the cmd variable's value is CREATE then the return value will have a second line containing the URL to which your script must send your customer to.
If the first line of the return value is not the same as the cmd variable that was passed, then the either the hash was incorrect or cmd contains an invalid value.
Sample PHP Code
Below is a set of sample PHP code that shows how easy it is to integrate with WishList Member:
Creating an Account
// the post URL $postURL = 'http://www.domain.com/index.php/register/GJMYz7'; // the Secret Key $secretKey = 'MYsecretKEY'; // prepare the data $data = array (); $data['cmd'] = 'CREATE'; $data['transaction_id'] = 'XYZ123456'; $data['lastname'] = 'Baggins'; $data['firstname'] = 'Frodo'; $data['email'] = 'frodo@shire.com'; $data['level'] = '1234567890'; // generate the hash $delimiteddata = strtoupper (implode ('|', $data)); $hash = md5 ($data['cmd'] . '__' . $secretKey . '__' . $delimiteddata); // include the hash to the data to be sent $data['hash'] = $hash; // send data to post URL $ch = curl_init ($postURL); curl_setopt ($ch, CURLOPT_POST, true); curl_setopt ($ch, CURLOPT_POSTFIELDS, $data); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); $returnValue = curl_exec ($ch); // process return value list ($cmd, $url) = explode ("\n", $returnValue); // check if the returned command is the same as what we passed if ($cmd == 'CREATE') { header ('Location:' . $url); exit; } else { die ('Error'); }
Deactivating an Account
// the post URL $postURL = 'http://www.domain.com/index.php/register/GJMYz7'; // the Secret Key $secretKey = 'MYsecretKEY'; // prepare the data $data = array (); $data['cmd'] = 'DEACTIVATE'; $data['transaction_id'] = 'XYZ123456'; // generate the hash $delimiteddata = strtoupper (implode ('|', $data)); $hash = md5 ($data['cmd'] . '__' . $secretKey . '__' . $delimiteddata); // include the hash to the data to be sent $data['hash'] = $hash; // send data to post URL $ch = curl_init ($postURL); curl_setopt ($ch, CURLOPT_POST, true); curl_setopt ($ch, CURLOPT_POSTFIELDS, $data); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); $returnValue = curl_exec ($ch); // process return value list ($cmd, $url) = explode ("\n", $returnValue); // check if the returned command is the same as what we passed if ($cmd == 'DEACTIVATE') { die ('Success'); } else { die ('Error'); }
Activating an Account
// the post URL $postURL = 'http://www.domain.com/index.php/register/GJMYz7'; // the Secret Key $secretKey = 'MYsecretKEY'; // prepare the data $data = array (); $data['cmd'] = 'ACTIVATE'; $data['transaction_id'] = 'XYZ123456'; // generate the hash $delimiteddata = strtoupper (implode ('|', $data)); $hash = md5 ($data['cmd'] . '__' . $secretKey . '__' . $delimiteddata); // include the hash to the data to be sent $data['hash'] = $hash; // send data to post URL $ch = curl_init ($postURL); curl_setopt ($ch, CURLOPT_POST, true); curl_setopt ($ch, CURLOPT_POSTFIELDS, $data); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); $returnValue = curl_exec ($ch); // process return value list ($cmd, $url) = explode ("\n", $returnValue); // check if the returned command is the same as what we passed if ($cmd == 'ACTIVATE') { die ('Success'); } else { die ('Error'); }