Difference between revisions of "NATS4 REST API Get Payment Data"
From TMM Wiki
Jump to navigationJump to search(One intermediate revision by one other user not shown) | |||
Line 7: | Line 7: | ||
'''Resource URL''' | '''Resource URL''' | ||
− | *<nowiki>http://domain/api | + | *<nowiki>http://domain/api/payments/getpayments</nowiki> |
*Replace domain with the nats domain | *Replace domain with the nats domain | ||
Line 63: | Line 63: | ||
'''GET''' | '''GET''' | ||
− | <nowiki>http://domain/api | + | <nowiki>http://domain/api/payments/getpayments</nowiki> |
*Response on success: | *Response on success: | ||
Line 140: | Line 140: | ||
$headers = array( | $headers = array( | ||
− | ' | + | 'api-key: 44b5498dbcb481a0d00b404c0169af62', |
− | ' | + | 'api-username: tmm1phrvezsbu' |
); | ); | ||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); | curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); | ||
Line 174: | Line 174: | ||
headers = { | headers = { | ||
− | ' | + | 'api-key': '44b5498dbcb481a0d00b404c0169af62', |
− | ' | + | 'api-username': 'tmm1phrvezsbu' |
} | } | ||
Line 198: | Line 198: | ||
json: true, | json: true, | ||
headers: { | headers: { | ||
− | ' | + | 'api-key': '44b5498dbcb481a0d00b404c0169af62', |
− | ' | + | 'api-username': 'tmm1phrvezsbu' |
} | } | ||
}; | }; |
Latest revision as of 15:26, 31 March 2015
GET /payments/getpayments
Description
- The /payments/getpayments endpoint/action allows you to get the open, stored, and paid payments for affiliates
Resource URL
- http://domain/api/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
- type: string
- optional
- end_date: The end date
- 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/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'