Difference between revisions of "NATS4 REST API Get Payment Data"
From TMM Wiki
Jump to navigationJump to search (Created page with "{{NATS4 Manual | show_api_admin_section = true }} == '''PUT /payments/getpayments'' == '''Description''' *The /payments/getpayments endpoint allows you to get the open, stor...") |
|||
(5 intermediate revisions by one other user not shown) | |||
Line 2: | Line 2: | ||
| show_api_admin_section = true | | show_api_admin_section = true | ||
}} | }} | ||
− | == ''' | + | == '''GET /payments/getpayments''' == |
'''Description''' | '''Description''' | ||
− | *The /payments/getpayments endpoint allows you to get the open, stored, and paid payments for affiliates | + | *The /payments/getpayments endpoint/action allows you to get the open, stored, and paid payments for affiliates |
'''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 31: | Line 31: | ||
**'''optional ''' | **'''optional ''' | ||
− | *'''start_date''': The start date | + | *'''start_date''': The start date |
**'''''type: string''''' | **'''''type: string''''' | ||
**'''optional ''' | **'''optional ''' | ||
− | *'''end_date''': The end date | + | *'''end_date''': The end date |
**'''''type: string''''' | **'''''type: string''''' | ||
**'''optional ''' | **'''optional ''' | ||
Line 58: | Line 58: | ||
**'''''type: string''''' | **'''''type: string''''' | ||
**'''optional ''' | **'''optional ''' | ||
− | |||
== '''Example Request''' == | == '''Example Request''' == | ||
Line 64: | Line 63: | ||
'''GET''' | '''GET''' | ||
− | <nowiki>http://domain/api | + | <nowiki>http://domain/api/payments/getpayments</nowiki> |
*Response on success: | *Response on success: | ||
Line 138: | Line 137: | ||
$data_string = http_build_query($data); | $data_string = http_build_query($data); | ||
− | $url = 'http:// | + | $url = 'http://domain/api/payments/getpayments?'.$data_string; |
$headers = array( | $headers = array( | ||
− | ' | + | 'api-key: 44b5498dbcb481a0d00b404c0169af62', |
− | ' | + | 'api-username: tmm1phrvezsbu' |
); | ); | ||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); | curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); | ||
Line 167: | Line 166: | ||
import json | import json | ||
− | url = 'http:// | + | url = 'http://domain/api/payments/getpayments' |
payload = { | payload = { | ||
Line 175: | Line 174: | ||
headers = { | headers = { | ||
− | ' | + | 'api-key': '44b5498dbcb481a0d00b404c0169af62', |
− | ' | + | 'api-username': 'tmm1phrvezsbu' |
} | } | ||
Line 191: | Line 190: | ||
var options = { | var options = { | ||
− | url: 'http:// | + | url: 'http://domain/api/payments/getpayments', |
method: 'GET', | method: 'GET', | ||
qs: { | qs: { | ||
Line 199: | Line 198: | ||
json: true, | json: true, | ||
headers: { | headers: { | ||
− | ' | + | 'api-key': '44b5498dbcb481a0d00b404c0169af62', |
− | ' | + | 'api-username': 'tmm1phrvezsbu' |
} | } | ||
}; | }; | ||
Line 220: | Line 219: | ||
'''Curl''' | '''Curl''' | ||
<pre> | <pre> | ||
− | curl -X GET -H "API_key: 44b5498dbcb481a0d00b404c0169af62" -H "api_userNAme: tmm1phrvezsbu" 'http:// | + | curl -X GET -H "API_key: 44b5498dbcb481a0d00b404c0169af62" -H "api_userNAme: tmm1phrvezsbu" 'http://domain/api/payments/getpayments?payvia_type_id=1&stored=1' |
</pre> | </pre> | ||
[[Category:NATS4 API Articles]] | [[Category:NATS4 API Articles]] |
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'