NATS4 REST API Get Payment Data
From TMM Wiki
Revision as of 16:24, 17 March 2015 by Tmmtobias0185 (talk | contribs)
GET /payments/getpayments
Description
- The /payments/getpayments endpoint allows you to get the open, stored, and paid payments for affiliates
Resource URL
- http://domain/api/v1/payments/getpayments
- Replace domain with the nats domain
- GET
Response Format
- JSON
- HTTP headers
Parameters
Paremeters can be sent as url encoded params. See examples below.
- loginid: The affiliate loginid
- type: string
- optional
- filter_inhouse: Filter inhouse affiliates. Can be set to 1 or 0
- type: string
- optional
- start_date: The start date YYYY-M-D format
- type: string
- optional
- end_date: The end date YYYY-M-D format
- type: string
- optional
- payvia_type_id: The payvia type id
- type: string
- optional
- payment_type: The payment type
- type: string
- optional
- open: Whether the payment is open or not
- type: string
- optional
- stored: Whether the payment is stored or not
- type: string
- optional
- paid: Whether the payment is paid
- type: string
- optional
Example Request
GET
http://domain/api/v1/payments/getpayments
- Response on success:
[ { "2": { "loginid": "2", "stored": [ { "paymentid": "1", "loginid": "2", "payvia_type_id": "1", "payvia_type_nice": "Check ($0.00)", "start": "1426564800", "end": "1426564800", "type": "5", "type_nice": "Manual Invoice", "amount": "66600", "stored": "1426564800", "paid": "0", "paid_reference": "", "received": "0" } ] }, "6": { "loginid": "6", "stored": [ { "paymentid": "2", "loginid": "6", "payvia_type_id": "1", "payvia_type_nice": "Check ($0.00)", "start": "1426564800", "end": "1426564800", "type": "5", "type_nice": "Manual Invoice", "amount": "66599", "stored": "1426564800", "paid": "0", "paid_reference": "", "received": "0" } ] } } ]
- Response on failure
[ [ [ "No Payments Found" ] ] ]
Example Code
PHP
<?php $curl = curl_init(); $data = array( 'payvia_type_id' => 1, 'stored' => '1' ); $data_string = http_build_query($data); $url = 'http://domain/api/payments/getpayments?'.$data_string; $headers = array( 'api_key: 44b5498dbcb481a0d00b404c0169af62', 'api_username: tmm1phrvezsbu' ); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_URL, $url); $resp = curl_exec($curl); //decodes json response and converts it to a php associative array $result = json_decode($resp, true); //prints the associative array representation of the JSON var_dump($result); // Close request to clear up some resources curl_close($curl); ?>
Python
- This example requires pip and the request library which can be installed via pip by: 'pip install requests'
import requests import json url = 'http://domain/api/payments/getpayments' payload = { 'payvia_type_id': 1, 'stored': '1' } headers = { 'api_key': '44b5498dbcb481a0d00b404c0169af62', 'api_username': 'tmm1phrvezsbu' } res = requests.get(url, params=payload, headers=headers) print res.json()
node.js
- This example requires npm and the request module which can be installed via npm by: 'npm install request'
var request = require('request'); var options = { url: 'http://domain/api/payments/getpayments', method: 'GET', qs: { 'payvia_type_id': 1, 'stored': 1 }, json: true, headers: { 'api_key': '44b5498dbcb481a0d00b404c0169af62', 'api_username': 'tmm1phrvezsbu' } }; function callback(error, response, body) { if (!error && response.statusCode == 200) { console.log(JSON.stringify(body)); } else{ console.log(body); } } request(options, callback)
Curl
curl -X GET -H "API_key: 44b5498dbcb481a0d00b404c0169af62" -H "api_userNAme: tmm1phrvezsbu" 'http://domain/api/payments/getpayments?payvia_type_id=1&stored=1'