Difference between revisions of "NATS4 REST API Set Payment Status"
From TMM Wiki
Jump to navigationJump to search (Created page with "{{NATS4 Manual | show_api_admin_section = true }} == '''PATCH /payments/setstatus'' == '''Description''' *The /payments/setstatus endpoint takes a single or set of payment i...") |
|||
(4 intermediate revisions by one other user not shown) | |||
Line 2: | Line 2: | ||
| show_api_admin_section = true | | show_api_admin_section = true | ||
}} | }} | ||
− | == '''PATCH /payments/setstatus'' == | + | == '''PATCH /payments/setstatus''' == |
'''Description''' | '''Description''' | ||
− | *The /payments/setstatus | + | *The /payments/setstatus action takes a single or set of payment ids and updates them to the status provided. |
'''Resource URL''' | '''Resource URL''' | ||
− | *<nowiki>http://domain/api | + | *<nowiki>http://domain/api/payments/setstatus</nowiki> |
*Replace domain with the nats domain | *Replace domain with the nats domain | ||
Line 48: | Line 48: | ||
'''PATCH''' | '''PATCH''' | ||
− | <nowiki>http://domain/api | + | <nowiki>http://domain/api/payments/setstatus</nowiki> |
*Response on success: | *Response on success: | ||
Line 89: | Line 89: | ||
$headers = array( | $headers = array( | ||
− | ' | + | 'api-key: 44b5498dbcb481a0d00b404c0169af62', |
− | ' | + | 'api-username: tmm1phrvezsbu' |
); | ); | ||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH"); | curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH"); | ||
Line 125: | Line 125: | ||
headers = { | headers = { | ||
− | ' | + | 'api-key': '44b5498dbcb481a0d00b404c0169af62', |
− | ' | + | 'api-username': 'tmm1phrvezsbu' |
} | } | ||
Line 153: | Line 153: | ||
json: true, | json: true, | ||
headers: { | headers: { | ||
− | ' | + | 'api-key': '44b5498dbcb481a0d00b404c0169af62', |
− | ' | + | 'api-username': 'tmm1phrvezsbu' |
} | } | ||
}; | }; | ||
Line 174: | Line 174: | ||
'''Curl''' | '''Curl''' | ||
<pre> | <pre> | ||
− | curl -X PATCH 'http://domain/api/payments/setstatus' -H " | + | curl -X PATCH 'http://domain/api/payments/setstatus' -H "api-key: 44b5498dbcb481a0d00b404c0169af62" -H "api-username: tmm1phrvezsbu" -H "Content-Type: application/x-www-form-urlencoded" -d 'paymentids=1%2C2&stored_date=2006-06-06&reference=2006-06-06&status=1' |
</pre> | </pre> | ||
[[Category:NATS4 API Articles]] | [[Category:NATS4 API Articles]] |
Latest revision as of 15:26, 31 March 2015
PATCH /payments/setstatus
Description
- The /payments/setstatus action takes a single or set of payment ids and updates them to the status provided.
Resource URL
- http://domain/api/payments/setstatus
- Replace domain with the nats domain
- PATCH
Response Format
- JSON
- HTTP headers
Parameters
Paremeters can be sent as url encoded params. See examples below.
- paymentids: comma separated string of payment ids to update
- type: string
- optional
- stored_date: desired stored date
- type: string
- optional
- paid_date: desired paid date
- type: string
- optional
- reference: paid reference message
- type: string
- optional
- status: desired status 0=open, 1=stored, 2=paid
- type: string
- optional
Example Request
PATCH
http://domain/api/payments/setstatus
- Response on success:
[ { "updateMessage": "No changes, preparing info updates. Payment info updated. ", "paymentid": "1", "stored_date": 1149566400, "paid_date": 0, "reference": "2006-06-06", "status": "1" }, { "updateMessage": "No changes, preparing info updates. Payment info updated. ", "paymentid": "2", "stored_date": 1149566400, "paid_date": 0, "reference": "2006-06-06", "status": "1" } ]
Example Code
PHP
<?php $curl = curl_init(); $data = array( 'paymentids' => '1,2', 'stored_date' => '2006-06-06', 'reference' => '2006-06-06', 'status' => '1' ); $url = 'http://domain/api/payments/setstatus'; $headers = array( 'api-key: 44b5498dbcb481a0d00b404c0169af62', 'api-username: tmm1phrvezsbu' ); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH"); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($curl, CURLOPT_URL, $url); $resp = curl_exec($curl); //makes an associative array representation of the json $result = json_decode($resp, true); //prints associative array representation of json result 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/setstatus' payload = { 'paymentids': '1,2', 'stored_date': '2006-06-06', 'reference': '2006-06-06', 'status': '1' } headers = { 'api-key': '44b5498dbcb481a0d00b404c0169af62', 'api-username': 'tmm1phrvezsbu' } res = requests.patch(url, data=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'); data = { 'paymentids': '1,2', 'stored_date': '2006-06-06', 'reference': '2006-06-06', 'status': '1' } var options = { url: 'http://domain/api/payments/setstatus', method: 'PATCH', form: data, json: true, headers: { 'api-key': '44b5498dbcb481a0d00b404c0169af62', 'api-username': 'tmm1phrvezsbu' } }; function callback(error, response, body) { if (!error && response.statusCode == 200) { console.log(body); } else{ console.log(body); } } request(options, callback);
Curl
curl -X PATCH 'http://domain/api/payments/setstatus' -H "api-key: 44b5498dbcb481a0d00b404c0169af62" -H "api-username: tmm1phrvezsbu" -H "Content-Type: application/x-www-form-urlencoded" -d 'paymentids=1%2C2&stored_date=2006-06-06&reference=2006-06-06&status=1'