Lets look at the following in more detail:
<?php
$fields = 'name=Joe Bloggs';
$fields .= '&email=joe@example.com';
$fields .= '&prodID=1';
$fields .= '&licAmount=2';
$fields .= '&apiKey=AO2CN4UJGW3PR08YIVKB';
?>
The following may seem more familiar and be better to understand:
<?php
$fields = 'name=Joe Bloggs&email=joe@example.com&prodID=1&licAmount=2&apiKey=AO2CN4UJGW3PR08YIVKB';
?>
Both are exactly the same. The .= simply means the data is concatenated (ie, joined together). This string is called a 'Query String' with key/value pairs separated by an ampersand (&). The keys (name,email etc) as detailed at the top
of the page should NOT under any circumstances be renamed.
The API Key MUST match the key in your settings. This validates a genuine post. If the API Key does not match the system fails and an entry is logged.
The prodID value MUST be a valid ID from a product in your Maian Cube installation. On the product page the ID is shown next to the product. If the product code does not match the system fails and an entry is logged.
In the curl part of the code, you must include the full url to your Maian Cube index file and the concatenated string of values:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://www.example.com/cube/index.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$fields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_exec($ch);
curl_close($ch);
?>
Obviously when sending the data, you would replace the users name/email with the dynamic values from your system. So, lets say you are using Paypal for your payments and you have verified a
successful payment. Your license routine would possibly be:
<?php
$fields = 'name='.$_POST['first_name'].' '.$_POST['last_name'];
$fields .= '&email='.$_POST['payer_email'];
$fields .= '&prodID=1';
$fields .= '&licAmount=2';
$fields .= '&apiKey=AO2CN4UJGW3PR08YIVKB';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://www.example.com/cube/index.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$fields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_exec($ch);
curl_close($ch);
?>
This should be at the very
end of your payment routine. You could also use:
<?php
$fields = 'name='.$_POST['first_name'].' '.$_POST['last_name'].'&email='.$_POST['payer_email'].'&prodID=1&licAmount=2&apiKey=AO2CN4UJGW3PR08YIVKB';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://www.example.com/cube/index.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$fields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_exec($ch);
curl_close($ch);
?>
Product ID and license amount would also be dynamic depending on your system. Please make sure you sanitize any incoming POST data if required.