NATS4 supports an API function to get a list of payvia rules based on either a specific payvia type ID, and/or a certain type of payvia rule.
get_payvia_rule accepts the following input parameters:
• payvia_type_id (the ID number of the specific Payvia type, such as Check, Paxum, Domestic Wire, etc.)
• type (i.e. "enabled", "disabled", or "ignored")
get_payvia_rule will output the following parameters:
• payvia_rule_id (the internal ID number of the Payvia Rule)
• payvia_type_id (the ID number of the Payvia Type)
• rule_type (the type of rule it is: "enabled", "disabled", or "ignored")
• identid (the internal identifier of this particular payvia rule)
• start_time (the starting date/time for when this rule is/was effective, format=YYYY-MM-DD HH:MM:SS)
• end_time (the ending date/time for when this rule is/was effective, format=YYYY-MM-DD HH:MM:SS, or "Never")
• login (if the rule is specific to an affiliate, the affiliate's login ID. If for ALL affiliates, the value will be 0) *
• country (if a country is specified in the rule, it will be the 2 letter designation of that country. If for ALL countries, the value will be "All") **
* If more than one affiliate is specified in a given rule, there will be a separate payvia_rule_id and a separate identid for each affiliate
** Likewise, if more than one country is specified in a given rule, there will be a separate payvia_rule_id and a separate identid for each country
NOTE: Anytime a payvia rule is edited, both the payvia_rule_id and identid will be changed (i.e. incremented from previous values).
NuSOAP Example
This example continues from the main article NuSOAP Example:
To give a complete example of this (e.g. showing the Payvia "Enabled" Rules for Paxum, which is Payvia type ID = 9), this is how to call it:
<?php
require_once('nusoap/lib/nusoap.php');
$url = 'http://nats.site.com/admin_api.php'; // change to be the domain of your NATS install
$username = 'NATSADMIN'; // your admin username
$apikey = '3385e1b470b0864e27a9b648da6c0692'; // your api key
$client = new nusoap_client($url.'?wsdl', true);
$client->setCredentials($username,$apikey);
// Check for an error
$err = $client->getError();
if ($err) {
// Display the error
echo 'Constructor error' . $err . "\n";
exit; // At this point, you know the call that follows will fail
}
//This example will show the Payvia "Enabled" Rules for Paxum, which is Payvia type ID = 9
$values = array(
'payvia_type_id' => 9,
'type' => "enabled"
);
$result = $client->call('get_payvia_rule', $values, 'natsapiadmin_wsdl');
echo '<HR><PRE>';
print_r($result);
echo '</PRE>';
?>
Get Payvia Rule output
Assuming the following Pay Via Rules have been set in NATS:
The output will be a multi-dimensional array, as shown below:
Array
(
[0] => TRUE
[1] => Array
(
[0] => Array
(
[payvia_rule_id] => 17
[payvia_type_id] => 9
[rule_type] => enabled
[identid] => 6
[start_time] => 2015-10-16 00:37:11
[end_time] => Never
[login] => 0
[country] => All
)
[1] => Array
(
[payvia_rule_id] => 20
[payvia_type_id] => 9
[rule_type] => enabled
[identid] => 20
[start_time] => 2016-08-22 18:36:01
[end_time] => 2016-11-30 11:54:15
[login] => 2
[country] => HN
)
[2] => Array
(
[payvia_rule_id] => 18
[payvia_type_id] => 9
[rule_type] => enabled
[identid] => 21
[start_time] => 2016-08-22 18:36:01
[end_time] => 2016-11-30 11:54:15
[login] => 7
[country] => HN
)
[3] => Array
(
[payvia_rule_id] => 21
[payvia_type_id] => 9
[rule_type] => enabled
[identid] => 22
[start_time] => 2016-08-22 18:36:01
[end_time] => 2016-11-30 11:54:15
[login] => 2
[country] => US
)
[4] => Array
(
[payvia_rule_id] => 19
[payvia_type_id] => 9
[rule_type] => enabled
[identid] => 23
[start_time] => 2016-08-22 18:36:01
[end_time] => 2016-11-30 11:54:15
[login] => 7
[country] => US
)
)
)