Skip to content

Refund/Query/Others ​

Retrieve a SecurePay ​

Definition

shell
GET
https://api.nihaopay.com/v1.2/transactions/merchant/{reference}

Request

shell
$ 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

json
{
    "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.

PropertyDescription
id
string
Transaction ID.
status
string
Transaction status. Either success, failure, or pending.
type
string
Transaction type. Either charge, authorization, or capture.
vendor
string
Payment method. Include: unionpay, alipay, wechatpay or alipayhk.
vendor_id
string
Vendor’s transaction id, usually showed on customer’s payment receipt.
amount
int
Amount of the transaction in the minor unit of the currency. For example, cents in USD.
currency
string
The 3-letter currency code.
time
string
Timestamp of the transaction in UTC. Ex: 2015-01-01T01:01:00Z is Jan 1, 2015 1:01:00 UTC.
reference
string
AlphaNumeric string set in request to correspond transaction ID with your original transaction request.
note
string/null
If set in request, your transaction note to self. Else if not set, this will be null.

Look up a transaction ​

Definition

shell
GET
https://api.nihaopay.com/v1.2/transactions/{transaction_id}

Request

shell
$ 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

json
{
    "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.

PropertyDescription
id
string
Transaction ID.
status
string
Transaction status. Either success, failure, or pending.
type
string
Transaction type. Either charge, authorization, or capture.
vendor
string
Payment method. Include: unionpay, alipay, wechatpay or alipayhk.
vendor_id
string
Vendor’s transaction id, usually showed on customer’s payment receipt.
amount
int
Amount of the transaction in the minor unit of the currency. For example, cents in USD.
currency
string
The 3-letter currency code.
time
string
Timestamp of the transaction in UTC. Ex: 2015-01-01T01:01:00Z is Jan 1, 2015 1:01:00 UTC.
reference
string
AlphaNumeric string set in request to correspond transaction ID with your original transaction request.
note
string/null
If set in request, your transaction note to self. Else if not set, this will be null.

Refund a transaction ​

Definition

shell
POST
https://api.nihaopay.com/v1.2/transactions/refund/{transaction_id}

Request

shell
$ 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.

PropertyDescription
currency
Required
The 3-letter currency code. Currency must match the original transaction's currency.
amount
Conditional
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_amount
Conditional
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.
reason
Optional
Arbitrary string detailing the reason for refund.
reference
Optional
Merchant refund reference. Use a unique value for each refund to support merchant-side idempotency; it cannot be reused by the same merchant.
ipn_url
Optional
URL that receives asynchronous refund notifications. PayPal asynchronous refunds require this field to return pending and receive subsequent refund IPNs.

Response

json
{
    "id": "bn2345nb53454kjb",
    "status": "success",
    "refunded": true,
    "transaction_id": "jkh25jh1348fd89sg"   
}

Asynchronous Refund Response (PayPal with ipn_url)

json
{
    "id": "20260910114323034765",
    "status": "pending",
    "refunded": false,
    "transaction_id": "20260910114042101626"
}

Response ​

Returns a refund object.

PropertyDescription
id
string
Refund ID.
status
string
Refund status: success, failed, or pending. pending is returned only for PayPal refunds when the request includes ipn_url.
refunded
bool
Whether the refund completed successfully. true for status=success; false for status=pending.
transaction_id
string
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

shell
id = 20260910114323034765
status = success
currency = USD
amount = 100
time = 2026-09-10T11:45:12Z
reference = refund-001
verify_sign = <signature>
PropertyDescription
id
string
NihaoPay refund transaction ID.
status
string
Refund status: pending, success, or failed.
currency
string
Original payment transaction currency.
amount
int
Refund amount in the minor unit of the currency.
time
string
Notification creation time in UTC.
reference
string
Merchant refund reference from the refund request.
verify_sign
string
Notification signature.

Refund Query ​

shell
GET
https://api.nihaopay.com/v1.2/transactions/refunds/{transaction_id}/

Request

shell
$ 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

json
{
    "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 ​

PropertyDescription
id
string
Transaction ID.
status
string
Transaction status. Either success, failure, pending or closed
type
string
Transaction type. Either charge, authorization, or capture.
amount
int
Amount of the transaction in the minor unit of the currency. For example, cents in USD.
currency
string
Transaction currency.
time
string
Timestamp of the transaction in UTC.
reference
string
Merchant order number.
note
string
If set in request, your transaction note to self. Else if not set, this will be null.
vendor
string
Payment method. Include: unionpay, alipay, wechatpay or alipayhk.
vendor_id
string
Vendor’s transaction id, usually showed on customer’s payment receipt.
refunded_amount
int
Total refunded amount
refunds
list
Refund records
refund_time
string
Refund time
refund_id
string
Refund ID.
refunded_amount
int
refund amount
status
string
Refund status: success, failed, or pending.

List transactions ​

Definition

shell
GET
https://api.nihaopay.com/v1.2/transactions/

Request

shell
$ 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.

PropertyDescription
limit
Optional
Default: 10
Number of transactions returned for each request. Limit can range between 1 and 100.
starting_after
Optional
Time in UTC format yyyy-mm-ddThh:mm:ssZ. Used to retrieve transactions processed after the specified time.
ending_before
Optional
Time in UTC format yyyy-mm-ddThh:mm:ssZ. Used to retrieve transactions processed before the specified time.

Response

json
{
    "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.

PropertyDescription
id
string
Transaction ID.
status
string
Transaction status. Either success, failure, or pending.
type
string
Transaction type. Either charge, authorization, or capture.
amount
int
Amount of the transaction in the minor unit of the currency. For example, cents in USD.
currency
string
The 3-letter currency code.
time
string
Timestamp of the transaction in UTC. Ex: 2015-01-01T01:01:00Z is Jan 1, 2015 1:01:00 UTC.
reference
string
AlphaNumeric string set in request to correspond transaction ID with your original transaction request.
note
string/null
If set in request, your transaction note to self. Else if not set, this will be null.

Query exchange rate ​

shell
GET
https://api.nihaopay.com/v1.2/exchangerate

Exchange 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

shell
$ curl https://api.nihaopay.com/v1.2/exchangerate/?rate_date=20170308&currency=USD \
-H "Authorization: Bearer <TOKEN>"

Request ​

Properties as URL GET parameters.

PropertyDescription
rate_date
Required
Rate date, formatted as YYYYMMDD
currency
Required
Foreign currency,acceptable are USD, JPY, HKD, GBP,EUR
vendor
Optional
Vendor, acceptable are alipay, wechatpay, unionpay

Response

json
{
  "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.

PropertyDescription
rate_date
string
Rate date, formatted as YYYYMMDD
currency
string
Foreign currency
vendor
string
alipay, wechatpay or unionpay
rate
string
Foreign currency to Renminbi(RMB) exchange rate

Download transactions ​

shell
GET
https://api.nihaopay.com/v1.2/download/transactions

This interface enables the merchants to download the transaction list in a specific time span to reconcile transactions.

Request

shell
$ 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.

PropertyDescription
start_date
Required
The start date, formatted as YYYYMMDD
end_date
Required
The end date , formatted as YYYYMMDD

Response ​

Currently the interface only supports .CSV file to be downloaded.

Download billing file ​

shell
GET
https://api.nihaopay.com/v1.2/billing

This 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

shell
$ 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.

PropertyDescription
start_date
Required
The start date, formatted as YYYYMMDD
end_date
Required
The end date , formatted as YYYYMMDD

Response ​

Currently the interface only supports .CSV file to be downloaded.

Last Updated - 01/16/2025