Set Payvia Rule

From TMM Wiki
Jump to navigationJump to search
Members Admin
The Members Admin
View Member Details
Add Member
MySQL Auth
Mod Authn DB
Multisite Access
Member Logging
Member Password Retrieval
OpenID Connect
Mod Auth OpenIDC
ID Numbers
API Best Practices
WSDL Cache
Add Affiliate
Add Member Note
Admin Get Adtools
Adtool Categories
Adtool Types
Affiliate Get Campaigns
Bulk Import Adtools
Decode Natscode
Expire Manual Member
Get Affiliate Campaigns
Get Affiliate Hit Data
Get Affiliate Loginids
Get Affiliate Nats Codes
Get Affiliate Payout
Get Affiliate Program Campaign List
Get Member Details
Get Member Instant Upgrade String
Get Member Package Upgrade String
Get Member Token Rebuy String
Get Member Upsell String
Get Payment Data
Get Payvia Rule
Get Profit Loss Report
Record Member Login
Search Affiliate Info
Search Member Info
Send Email API Function
Set Affiliate Admin Settings
Set Affiliate Customs
Set Affiliate Defaults
Set Affiliate Information
Set Affiliate Settings
Set Member Details
Set Payment Status
Set Payvia Rule
API Overview
API Best Practices
GET /adtools/admin
GET /adtools/categories
GET /adtools/types
POST /adtools/importdump
GET /affiliate/campaigns
GET /affiliate/hitdata
GET /affiliate/payout
GET /affiliate/searchinfo
POST /affiliate/addaffiliate
POST /affiliate/invoice
PATCH /affiliate/setadminsettings
PATCH /affiliate/setcustoms
PATCH /affiliate/setdefaults
PATCH /affiliate/setinformation
PATCH /affiliate/setpayviainfo
PATCH /affiliate/setsettings
PATCH /affiliate/status
GET /member/authstring
GET /member/details
GET /member/searchinfo
GET /suggestedcanceloffers
PATCH /member/setdetails
PATCH /member/setexpiration
POST /member/addnote
POST /member/recordlogin
PUT /member/expiremanual
PATCH /member/forget
GET /option/options
GET /option/rule
PATCH /option/rule
POST /option/rule
GET /payments/getpayments
GET /payviarule
PATCH /payments/setstatus
PATCH /payviarule
GET /profitlossreport
Get /transactionpayouts
GET /report/transaction
GET /service/decodenatscode
GET /service/ping
POST /service/sendemail

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:


$url = ''; // 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);
// 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>';


echo '</PRE>';

Set Payvia Rule output

The output will be a multi-dimensional array, as shown below:

    [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:

Display Rule Added