Refund/Query/Others
Retrieve a SecurePay
Definition
GET
https://api.nihaopay.com/v1.2/transactions/merchant/{reference}Request
$ curl https://api.nihaopay.com/v1.2/transactions/merchant/{reference} \
-H "Authorization: Bearer <TOKEN>"Provide reference that was requested for a SecurePay transactions in order to retrieve corresponding transaction’s details.
Applicable to SecurePay transactions that do not receive asynchronous notifications
Request
reference as URL parameter.
Response
{
"id": "bn2345nb53454kjb",
"status": "success",
"type": "charge",
"amount": 1111,
"currency": "USD",
"time": "2015-01-01T01:01:01Z",
"reference": "jkh25jh1348fd89sg",
"note": "sample note"
}Response
Returns a transaction object.
| Property | Description |
|---|---|
idstring | Transaction ID. |
statusstring | Transaction status. Either success, failure, or pending. |
typestring | Transaction type. Either charge, authorization, or capture. |
vendorstring | Payment method. Include: unionpay, alipay, wechatpay or alipayhk. |
vendor_idstring | Vendor’s transaction id, usually showed on customer’s payment receipt. |
amountint | Amount of the transaction in the minor unit of the currency. For example, cents in USD. |
currencystring | The 3-letter currency code. |
timestring | Timestamp of the transaction in UTC. Ex: 2015-01-01T01:01:00Z is Jan 1, 2015 1:01:00 UTC. |
referencestring | AlphaNumeric string set in request to correspond transaction ID with your original transaction request. |
notestring/null | If set in request, your transaction note to self. Else if not set, this will be null. |
Look up a transaction
Definition
GET
https://api.nihaopay.com/v1.2/transactions/{transaction_id}Request
$ curl https://api.nihaopay.com/v1.2/transactions/{transaction_id} \
-H "Authorization: Bearer <TOKEN>"Returns details of a previously created transaction.
Provide a unique transaction ID that was returned from a previous response in order to retrieve corresponding transaction’s details. Only SecurePay transaction details can be found through this endpoint. For details on Released, Cancelled, and Refunded transactions, please use TMS.
Request
transaction_id as URL parameter.
Response
{
"id": "bn2345nb53454kjb",
"status": "success",
"type": "charge",
"amount": 1111,
"currency": "USD",
"time": "2015-01-01T01:01:01Z",
"reference": "jkh25jh1348fd89sg",
"note": "sample note"
}Response
Returns a transaction object.
| Property | Description |
|---|---|
idstring | Transaction ID. |
statusstring | Transaction status. Either success, failure, or pending. |
typestring | Transaction type. Either charge, authorization, or capture. |
vendorstring | Payment method. Include: unionpay, alipay, wechatpay or alipayhk. |
vendor_idstring | Vendor’s transaction id, usually showed on customer’s payment receipt. |
amountint | Amount of the transaction in the minor unit of the currency. For example, cents in USD. |
currencystring | The 3-letter currency code. |
timestring | Timestamp of the transaction in UTC. Ex: 2015-01-01T01:01:00Z is Jan 1, 2015 1:01:00 UTC. |
referencestring | AlphaNumeric string set in request to correspond transaction ID with your original transaction request. |
notestring/null | If set in request, your transaction note to self. Else if not set, this will be null. |
Refund a transaction
Definition
POST
https://api.nihaopay.com/v1.2/transactions/refund/{transaction_id}Request
$ curl https://api.nihaopay.com/v1.2/transactions/refund/{transaction_id} \
-H "Authorization: Bearer <TOKEN>" \
-d amount=100 \
-d currency="USD" \
-d reference="refund-001" \
-d ipn_url="https://merchant.example.com/refund-ipn"To issue a full or partial refund, you must create a Refund Object based on an existing transaction.
Full refunds can only be created once per transaction by specifying amount as the full amount of the transaction. Partial refunds can be created multiple times untill total refund amount reaches amount of the Transaction.
You cannot refund more than the amount of the original transaction.
PayPal refunds, including PayPal Crypto refunds, may be processed asynchronously. When ipn_url is provided, the synchronous response may return status=pending and refunded=false. Use the subsequent refund IPN or Refund Query status as the final result. Existing requests without ipn_url retain their original synchronous-success response behavior.
Request
transaction_id as URL Parameter.
| Property | Description |
|---|---|
currencyRequired | The 3-letter currency code. Currency must match the original transaction's currency. |
amountConditional | Amount to be funded in the minor unit of the currency. Must be equal to or less than the amount of the original transaction. |
rmb_amountConditional | If original transaction Amount as a positive integer of the minor unit of the currency. Use this parameter to replace amount if merchant wish to price their product in RMB. If amount is used, rmb_amount should not be set. They are mutual exclusive. See Parameters Description. |
reasonOptional | Arbitrary string detailing the reason for refund. |
referenceOptional | Merchant refund reference. Use a unique value for each refund to support merchant-side idempotency; it cannot be reused by the same merchant. |
ipn_urlOptional | URL that receives asynchronous refund notifications. PayPal asynchronous refunds require this field to return pending and receive subsequent refund IPNs. |
Response
{
"id": "bn2345nb53454kjb",
"status": "success",
"refunded": true,
"transaction_id": "jkh25jh1348fd89sg"
}Asynchronous Refund Response (PayPal with
ipn_url)
{
"id": "20260910114323034765",
"status": "pending",
"refunded": false,
"transaction_id": "20260910114042101626"
}Response
Returns a refund object.
| Property | Description |
|---|---|
idstring | Refund ID. |
statusstring | Refund status: success, failed, or pending. pending is returned only for PayPal refunds when the request includes ipn_url. |
refundedbool | Whether the refund completed successfully. true for status=success; false for status=pending. |
transaction_idstring | ID of the transaction that was refunded. |
Refund IPN
For PayPal asynchronous refunds with an ipn_url, NihaoPay sends refund status notifications to this URL using HTTP POST. A notification may contain pending and will be sent again when the status changes to success or failed. Use the refund transaction ID id together with the status for idempotent processing. The signature follows the Instant Payment Notification rules. Return HTTP 200 after successfully processing the notification.
Refund IPN Example
id = 20260910114323034765
status = success
currency = USD
amount = 100
time = 2026-09-10T11:45:12Z
reference = refund-001
verify_sign = <signature>| Property | Description |
|---|---|
idstring | NihaoPay refund transaction ID. |
statusstring | Refund status: pending, success, or failed. |
currencystring | Original payment transaction currency. |
amountint | Refund amount in the minor unit of the currency. |
timestring | Notification creation time in UTC. |
referencestring | Merchant refund reference from the refund request. |
verify_signstring | Notification signature. |
Refund Query
GET
https://api.nihaopay.com/v1.2/transactions/refunds/{transaction_id}/Request
$ curl https://api.nihaopay.com/v1.2/transactions/refunds/{transaction_id}/ \
-H "Authorization: Bearer <TOKEN>"Request
transaction_id Original transaction ID as URL parameter.
Response
{
"note": null,
"amount": 2,
"type": "charge",
"refunded_amount": 2,
"refunds": [
{
"refund_time": "2021-11-29T05:42:33Z",
"refund_id": "20211129054233008405",
"refunded_amount": 1,
"status": "success"
},
{
"refund_time": "2021-11-29T05:41:55Z",
"refund_id": "20211129054155008404",
"refunded_amount": 1,
"status": "success"
}
],
"reference": "20211129134105329326",
"vendor": "unionpay",
"vendor_id": "512111291341178330258",
"currency": "USD",
"id": "20211129054117043676",
"time": "2021-11-29T05:41:17Z",
"status": "success"
}Response
| Property | Description |
|---|---|
idstring | Transaction ID. |
statusstring | Transaction status. Either success, failure, pending or closed |
typestring | Transaction type. Either charge, authorization, or capture. |
amountint | Amount of the transaction in the minor unit of the currency. For example, cents in USD. |
currencystring | Transaction currency. |
timestring | Timestamp of the transaction in UTC. |
referencestring | Merchant order number. |
notestring | If set in request, your transaction note to self. Else if not set, this will be null. |
vendorstring | Payment method. Include: unionpay, alipay, wechatpay or alipayhk. |
vendor_idstring | Vendor’s transaction id, usually showed on customer’s payment receipt. |
refunded_amountint | Total refunded amount |
refundslist | Refund records |
refund_timestring | Refund time |
refund_idstring | Refund ID. |
refunded_amountint | refund amount |
statusstring | Refund status: success, failed, or pending. |
List transactions
Definition
GET
https://api.nihaopay.com/v1.2/transactions/Request
$ curl https://api.nihaopay.com/v1.2/transactions/?starting_after=2015-01-01T01:01:00Z \
-H "Authorization: Bearer <TOKEN>"Returns a list of previously created transactions. Transactions are returned with the most recent transactions appearing first. By default, only 10 transactions are returned at a time. This can be adjusted by providing a limit argument.
Only SecurePay transactions can be returned. For details on Released, Cancelled, and Refunded transactions, please use TMS.
By providing starting_after argument, you can retrieve transactions that were processed after the specified time.
By providing ending_before argument, you can retrieve transactions that were processed before the specified time.
By providing both, starting_after and ending_before arguments, you can retrieve transactions that were processed within the specified range.
Request
Properties as URL GET parameters.
| Property | Description |
|---|---|
limitOptionalDefault: 10 | Number of transactions returned for each request. Limit can range between 1 and 100. |
starting_afterOptional | Time in UTC format yyyy-mm-ddThh:mm:ssZ. Used to retrieve transactions processed after the specified time. |
ending_beforeOptional | Time in UTC format yyyy-mm-ddThh:mm:ssZ. Used to retrieve transactions processed before the specified time. |
Response
{
"transactions": [
{
"id": "bn2345nb53454kjb",
"status": "success",
"type": "charge",
"amount": 1111,
"currency": "USD",
"time": "2015-01-01T01:05:0Z",
"reference": "jkh25jh1348fd89sg",
"note": "sample note"
},
{
"id": "16zfmK2eZvKYlo2C6X3",
"status": "success",
"type": "authorization",
"amount": 1111,
"currency": "USD",
"time": "2015-01-01T01:01:01Z",
"reference": "6LJDMbC6Ybqlt7fd",
"note": "sample note"
}
]
}Response
Returns a transactions array of transaction objects. If no transactions are available, returns an empty array.
| Property | Description |
|---|---|
idstring | Transaction ID. |
statusstring | Transaction status. Either success, failure, or pending. |
typestring | Transaction type. Either charge, authorization, or capture. |
amountint | Amount of the transaction in the minor unit of the currency. For example, cents in USD. |
currencystring | The 3-letter currency code. |
timestring | Timestamp of the transaction in UTC. Ex: 2015-01-01T01:01:00Z is Jan 1, 2015 1:01:00 UTC. |
referencestring | AlphaNumeric string set in request to correspond transaction ID with your original transaction request. |
notestring/null | If set in request, your transaction note to self. Else if not set, this will be null. |
Query exchange rate
GET
https://api.nihaopay.com/v1.2/exchangerateExchange rate updates 10:30am China Standard Time(UTC+8), once a day (Frequency limit: 1 time per minute, it is recommended to query only once a day).
Response
$ curl https://api.nihaopay.com/v1.2/exchangerate/?rate_date=20170308¤cy=USD \
-H "Authorization: Bearer <TOKEN>"Request
Properties as URL GET parameters.
| Property | Description |
|---|---|
rate_dateRequired | Rate date, formatted as YYYYMMDD |
currencyRequired | Foreign currency,acceptable are USD, JPY, HKD, GBP,EUR |
vendorOptional | Vendor, acceptable are alipay, wechatpay, unionpay |
Response
{
"rates": [
{
"rate_date": "20170308",
"currency": "usd",
"vendor": "unionpay",
"rate": "6.948700"
},
{
"rate_date": "20170308",
"currency": "usd",
"vendor": "alipay",
"rate": "6.921791"
},
{
"rate_date": "20170308",
"currency": "usd",
"vendor": "wechatpay",
"rate": "6.921911"
}
]
}Response
Returns exchange rate list.
| Property | Description |
|---|---|
rate_datestring | Rate date, formatted as YYYYMMDD |
currencystring | Foreign currency |
vendorstring | alipay, wechatpay or unionpay |
ratestring | Foreign currency to Renminbi(RMB) exchange rate |
Download transactions
GET
https://api.nihaopay.com/v1.2/download/transactionsThis interface enables the merchants to download the transaction list in a specific time span to reconcile transactions.
Request
$ curl https://api.nihaopay.com/v1.2/download/transactions/?start_date=20170101&end_date=20170105 \
-H "Authorization: Bearer <TOKEN>"Request
Properties as URL GET parameters.
Note: The starting and end dates should be within a 10-day interval.
| Property | Description |
|---|---|
start_dateRequired | The start date, formatted as YYYYMMDD |
end_dateRequired | The end date , formatted as YYYYMMDD |
Response
Currently the interface only supports .CSV file to be downloaded.
Download billing file
GET
https://api.nihaopay.com/v1.2/billingThis interface enables the merchants to download the transaction list in a specific time span to reconcile the transactions.
Closed, failed or cancelled transactions do not appear in the download file.
Request
$ curl https://api.nihaopay.com/v1.2/billing/?start_date=20170101&end_date=20170105 \
-H "Authorization: Bearer <TOKEN>"Request
Properties as URL GET parameters.
Note: The starting and end dates should be within a 10-day interval.
| Property | Description |
|---|---|
start_dateRequired | The start date, formatted as YYYYMMDD |
end_dateRequired | The end date , formatted as YYYYMMDD |
Response
Currently the interface only supports .CSV file to be downloaded.
