Set Payvia Rule
NATS4 supports an API function to set (i..e add, update or remove) one or more payvia rules for a specific payvia type ID.
set_payvia_rule accepts the following input parameters:
• action ("add", "update", or "remove")
• 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")
• payvia_rule_id (the internal ID number of the Payvia Rule, if the action is "update" or "remove")
• loginid (to make the rule specific to an affiliate, the affiliate's login ID. If for ALL affiliates, the value will be 0 or just leave empty) *
• country (to make the rule specific to a country, it will be the 2 letter designation of that country. If for ALL countries, leave empty) **
• start_time (the starting date/time for when this rule is to be effective, format=YYYY-MM-DD HH:MM:SS)
• end_time (the ending date/time for when this rule is to be effective, format=YYYY-MM-DD HH:MM:SS, leave empty for "Never")
* If more than one affiliate needs to be specified, there will need to be a separate payvia rule for each affiliate ** Likewise, if more than one country needs to be specified, there will need to be a separate payvia rule for each country
set_payvia_rule will output the following:
• (If applicable, error messages such as: "Payvia type does not exists", "Invalid Login ID", "Country code doesn't exist", "Please set the action you want to perform for this rule", "Please set the type of rule you want to add", etc.)
• TRUE on successful result, or Error message on failure result
• On most actions and results, the above input parameters (and if the rule is specific to an affiliate, also output will be the affiliate's username that matches the given login ID)***
*** Not shown for either TRUE on update, or TRUE on remove
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. adding an affiliate specific "Disabled" Rule for Domestic Wire, which is Payvia type ID = 4), 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 add a "Disabled" Rule for Domestic Wire, which is Payvia type ID = 4 //It will be for all countries, to start on Sep 23, 2015 and run forever //But it will be specific for the affiliate with loginID = 2, who has a username of "IsendAlotOfTraffic" $values = array( 'payvia_type_id' => 4, 'action' => 'add', 'type' => "disabled", 'loginid' => 2, 'start_time' => '2013-09-15' ); $result = $client->call('set_payvia_rule', $values, 'natsapiadmin_wsdl'); echo '<HR><PRE>'; print_r($result); echo '</PRE>'; ?>
Set Payvia Rule output
The output will be a multi-dimensional array, as shown below:
Array ( [0] => TRUE [1] => Array ( [payviaid] => 4 [rule_type] => 2 [login] => Array ( [0] => IsendAlotOfTraffic ) [start_time] => 2013-09-15 [end_time] => NEVER [payvia_rule_id] => 22 ) )
Assuming there had been no prior Pay Via Rules for Domestic Wire previously set in NATS, then checking your NATS Admin after making the above API call, you should see this: