Presents
{ WishList Member }
Documentation for the
Generic 3rd Party System Integration
Requires WishList Member v2.18 or above
QUICK OVERVIEW
Integrating a 3rd party payment system or shopping cart with WishList member is now possible with WishList
Member v2.18 and higher. The integration process can be accomplished in four (4) steps, namely:
1. Generate POST data
2. Hash the data using a Secret Key
3. Send POST data to the POST URL
4. Process the returned data
5. Redirect customer to the returned URL if necessary
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 fo the specified transaction ID
lastname Member's lastname
firstname Member's firstname
email 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 : [email protected]
level : 1234567890
transaction_id : XYZ123456
The string to hash would be:
CREATE__MYsecretKEY__BAGGINS|FRODO|[email protected]|1234567890|XYZ123456
The MD5 hash of the above string is:
63b8040b5407eac097b86b73e2fe4523
RETURN VALUE
Upon a succesful 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
<?php
// 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'] = '
[email protected]';
$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
<?php
// 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
<?php
// 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');
}
?>
- EOF -