Standard API - Advanced Setup

Overview
Once you have Maian Guardian installed you need to send data to it from your current payment routine. This creates an account for a user to log in and generate their license(s). The data is sent as a POST to Maian Guardian via the Curl functions (or any other methods that can send a HTTP POST).

It should be fairly easy to implement in any existing payment routine providing the option exists to manipulate the payment routine itself.

Please read this section carefully to correctly setup your license routine.

This section assumes you are familiar with the Easy Setup functions. If not, check there first to familiarise yourself with how this works before continuing.
Advanced Parameters - Optional
All advanced parameters are optional. They are as follows:

prodIDMulti = Comma delimited set of multiple purchases.
licAmountMulti = Comma delimited set of multiple amounts to match "prodIDMulti".
notes = Any notes or data related to the sale. Not seen by a user.
timeline = Timeline text. Replaces system text.
timezone = Users timezone. Key MUST exist in 'control/timezones.php' file. eg: Europe/London (If not set, default timezone in settings is used).
orderno = Order No or Invoice No for initial sale.
ip = Users IP address
Usage Example - Advanced with Multiple Products
<?php

$fields = 'name='.$_POST['first_name'].' '.$_POST['last_name'];
$fields .= '&email='.$_POST['payer_email'];
$fields .= '&prodIDMulti=1,5,7,9';
$fields .= '&licAmountMulti=2,0,1,3';
$fields .= '&apiKey=AO2CN4UJGW3PR08YIVKB';
$fields .= '&notes=These are some notes..blah blah';
$fields .= '&timeline=New sales created from website XX';
$fields .= '&ip='.$_SERVER['REMOTE_ADDR'];
$fields .= '&orderno=ABC123';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://www.example.com/guardian/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);

?>
Here, the user has purchased 4 products as follows:

2 licenses for product 1
Unlimited licenses for product 5
1 license for product 7
3 licenses for product 9

Both multi params should have a matching set. For example, if you have 4 comma delimited values for "prodIDMulti", there MUST be 4 for "licAmountMulti".
Usage Example - Advanced with Single Product
<?php

$fields = 'name='.$_POST['first_name'].' '.$_POST['last_name'];
$fields .= '&email='.$_POST['payer_email'];
$fields .= '&prodID=1';
$fields .= '&licAmount=2';
$fields .= '&apiKey=AO2CN4UJGW3PR08YIVKB';
$fields .= '&notes=These are some notes..blah blah';
$fields .= '&timeline=New sales created from website XX';
$fields .= '&ip='.$_SERVER['REMOTE_ADDR'];
$fields .= '&orderno=ABC123';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://www.example.com/guardian/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);

?>
Return Response - HTTP or JSON
If the API has accepted the request it will return a HTTP header (default) or JSON response, depending on your preference in the 'control/options.php' file. If a failure occurs check the API log entry in the 'logs' folder if enabled.

HTTP HEADER example:

HTTP/1.0 200 OK

or

HTTP/1.0 403 Forbidden
For JSON, the response will be a JSON array with a single key called 'status'. This will have one of two values, either 'OK' or 'ERR'. Example:

{
"status" : "OK"
}

or

{
"status" : "ERR"
}
Additional Triggers
If you want to create other operations after the license creation has run, add your custom code to the following file:

control/api/api-triggers.php

Jump to Easy Setup Options