Retrieves the credit history transactions for a customer.
Retrieves the credit history transactions for one customer. Use it to see when credit was added, by whom, and for which order. Identify the customer by ID or login.
Before you begin#
- The API token needs
CustomerCreditHistoryList_Load_Query, either assigned directly under Functions or through a group. See Create an API token. - Requests must be signed if the token requires it. See Make a signed request with HMAC.
- You need the customer’s
Customer_ID,Customer_LoginorEdit_Customer.
Example requests#
Retrieve a customer’s credit history#
Returns every credit history transaction for the customer, newest first.
{
"Store_Code": "{{Store_Code}}",
"Miva_Request_Timestamp": "{{$timestamp}}",
"Function": "CustomerCreditHistoryList_Load_Query",
"Customer_Login": "{{Customer_Login}}",
"Count": 0,
"Offset": 0,
"Sort": "-id",
"Filter": []
}
Request parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
customer_idedit_customercustomer_login |
Number String String |
The customer id The customer login The customer login |
|
count |
Number | No | Maximum lines of data allowed to be returned in the response. This limit is used to prevent excessive amounts of data return |
filter |
String | No | A string for filtering returned data |
offset |
Number | No | Used with the Count parameter for paginating results of large datasets. Default 0 is no offset. |
sort |
String | No | The order for sorting returned data |
Example response#
{
"success": 1,
"data": {
"total_count": 4,
"start_offset": 0,
"data": [
{
"id": 6,
"user_id": 0,
"cust_id": 15,
"order_id": 0,
"txref": "12345",
"descrip": "Credit For Order 12345",
"amount": 10.5,
"formatted_amount": "$10.50",
"dtstamp": 1600968503,
"user_name": ""
},
{
"id": 5,
"user_id": 0,
"cust_id": 15,
"order_id": 0,
"txref": "12345",
"descrip": "Credit For Order 12345",
"amount": 10.5,
"formatted_amount": "$10.50",
"dtstamp": 1600968503,
"user_name": ""
},
{
"id": 4,
"user_id": 0,
"cust_id": 15,
"order_id": 0,
"txref": "12345",
"descrip": "Credit For Order 12345",
"amount": 10.5,
"formatted_amount": "$10.50",
"dtstamp": 1600968502,
"user_name": ""
},
{
"id": 3,
"user_id": 0,
"cust_id": 15,
"order_id": 0,
"txref": "12345",
"descrip": "Credit For Order 12345",
"amount": 10.5,
"formatted_amount": "$10.50",
"dtstamp": 1600968239,
"user_name": ""
}
]
}
}
Response parameters#
| Parameter | Type | Description |
|---|---|---|
total_count |
Number | total_count is the total number of records that match your search criteria. Note: this is not always the total products returned. Based on the Count and Offset parameters passed, the number of records returned could be different than the total_count. |
start_offset |
Number | Number of the starting offset number of products to return. Used in conjunction with the Count parameter for paginating results of large datasets. |
id |
Number | Credit History Transaction ID |
user_id |
Number | The Id of the Admin user who added the transaction. 0 if not placed by an Admin user |
cust_id |
Number | The Id of the Customer for the transaction list |
order_id |
Number | The Order ID the transaction references. If no order, it is 0 |
txref |
Number | Optional Transaction Reference |
descrip |
String | The description for the transaction list |
amount |
Number | The amount of customer credit for the transaction |
dtstamp |
Date Timestamp | The timestamp for when the transaction took place |
user_name |
String | The User name of the admin user if it was added by an Admin. If no admin, the string returns empty. |
Additional options#
Pagination#
Count and Offset page through results, and the response’s total_count says how many transactions match. See Pagination. List Load Query overview explains the Filter and Sort formats.
Related functions#
| Function | Use it to |
|---|---|
CustomerCreditHistory_Insert |
Add credit to a customer account |
CustomerCreditHistory_Delete |
Delete a credit history record |
CustomerList_Load_Query |
Find the customer and their current credit balance |
Try in Postman#
In the Miva: JSON API: Authenticated collection, open Customers > CustomerCreditHistoryList_Load_Query. See Set Up Postman.