NATS For Networks REST API Approve Pending Transaction

From TMM Wiki
Revision as of 20:51, 28 August 2018 by TMMNick (talk | contribs) (Created page with "{{NATS For Networks Manual | show_rest_api_section = true }} == '''POST transaction/approve_pending_transaction''' == <font color="red">* COMING SOON *</font> '''Description'...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Template:NATS For Networks Manual

POST transaction/approve_pending_transaction

* COMING SOON *

Description

  • This REST API resource is used to approve a pending transaction

Resource URL

  • http://domain/api/transaction/approve_pending_transaction
  • Replace domain with your NATS For Networks network domain

Request Method

  • POST

Response Format

  • JSON

Authentication

  • HTTP headers

Parameters

Must pass at least one of the following:

  • transaction_hash: The click_hash/transaction_hash of the pending transaction you want to approve.
    • type: string
    • optional
  • orderid: The transaction identifier you want to approve. (sent on the pending conversion as orderid)
    • type: string
    • optional
  • transactionid: The NATS For Networks generated transaction identifier you want to approve
    • type: string
    • optional

Example Request

POST

http://domain.com/api/transaction/approve_pending_transaction

  • Response:
Success
{
   "result": "success",
   "message": "Transaction approved successfully."
}

Failure
{
   "result": "error",
   "message": "Invalid transaction."
}

Example Code

PHP

<?php
$curl = curl_init();

$data = array(
    'transaction_hash' => '156097c947ece92.38318951',
);
$url = 'http://domain/api/transaction/approve_pending_transaction';
$headers = array(
    'api-key: 44b5498dbcb481a0d00b404c0169af62',
    'api-username: productsupport'
);
curl_setopt($curl, CURLOPT_POST, 1);
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);
//dumps an associative array representation of the json response
$output = json_decode($resp, true);
if($output !== NULL) {
	//json was valid. Dump the decoded array
	print_r($output);
}
else {
	//invalid json, just dump the raw response
	print_r($resp);
}
// Close request to clear up some resources
curl_close($curl);
?>