Set Payvia Rule

From TMMwiki
Jump to: navigation, search
NATS 4
SOAP API
API
WSDL Cache
Add Affiliate
Add Member Note
Admin Get Adtools
Adtool Categories
Adtool Types
Affiliate Get Campaigns
Bulk Import Adtools
Caching
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_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
Ping
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
REST API
API Overview
REST API PATH UPDATES
Adtools
GET /adtools/admin
GET /adtools/categories
GET /adtools/types
POST /adtools/importdump
Affiliate
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
Member
GET /member/upsellstring
GET /member/tokenrebuystring
GET /member/instantupgradestring
GET /member/packageupgradestring
GET /member/signupplusstring
GET /member/cancelstring
GET /member/details
GET /member/searchinfo
GET /suggestedcanceloffers
PATCH /member/setdetails
PATCH /member/setexpiration
POST /member/addnote
POST /member/recordlogin
PUT /member/expiremanual
Option
GET /option/getrule
PATCH /option/editrule
POST /option/addrule
PUT /option/edittext
Payments
GET /payments/getpayments
GET /payviarule
PATCH /payments/setstatus
PATCH /payviarule
Report
GET /profitlossreport
Service
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:

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

Display Rule Added