Sales Order Credit Memo API¶
Introduction¶
The Sales Order Credit Memo API allows you to manage credit memos in your OpenMage store. You can retrieve credit memo information, create new credit memos, add comments, and cancel credit memos.
Available Methods¶
list¶
Retrieve list of credit memos with basic info.
Method Name: sales_order_creditmemo.list
Parameters:
filters
(object|array, optional) - Filters to apply to the list:creditmemo_id
(int|array) - Filter by credit memo ID(s)order_id
(int|array) - Filter by order ID(s)increment_id
(string|array) - Filter by increment ID(s)created_at
(string|array) - Filter by creation dateorder_increment_id
(string|array) - Filter by order increment ID(s)- Other attributes can also be used as filters
Return:
- (array) - Array of credit memos with the following structure:
increment_id
(string) - Credit memo increment IDcreditmemo_id
(int) - Credit memo IDorder_id
(int) - Order IDorder_increment_id
(string) - Order increment IDcreated_at
(string) - Creation datestate
(int) - Credit memo stategrand_total
(float) - Grand totalstore_id
(int) - Store ID
Example Request:
{
"jsonrpc": "2.0",
"method": "call",
"params": [
"session_id",
"sales_order_creditmemo.list",
[{"order_increment_id": "100000001"}]
],
"id": 1
}
Example Response:
{
"jsonrpc": "2.0",
"result": [
{
"increment_id": "100000001",
"creditmemo_id": 1,
"order_id": 1,
"order_increment_id": "100000001",
"created_at": "2023-01-17 09:45:20",
"state": 2,
"grand_total": 150.00,
"store_id": 1
}
],
"id": 1
}
Possible Errors:
filters_invalid
- Invalid filters provided
info¶
Retrieve detailed credit memo information.
Method Name: sales_order_creditmemo.info
Parameters:
creditmemoIncrementId
(string, required) - Credit memo increment ID
Return:
- (object) - Credit memo information with the following structure:
increment_id
(string) - Credit memo increment IDcreditmemo_id
(int) - Credit memo IDorder_id
(int) - Order IDorder_increment_id
(string) - Order increment IDcreated_at
(string) - Creation datestate
(int) - Credit memo stategrand_total
(float) - Grand totalsubtotal
(float) - Subtotaladjustment_positive
(float) - Positive adjustmentadjustment_negative
(float) - Negative adjustmentshipping_amount
(float) - Shipping amounttax_amount
(float) - Tax amountstore_id
(int) - Store IDbilling_address
(object) - Billing address informationshipping_address
(object) - Shipping address informationitems
(array) - Array of credit memo itemscomments
(array) - Array of credit memo comments
Example Request:
{
"jsonrpc": "2.0",
"method": "call",
"params": [
"session_id",
"sales_order_creditmemo.info",
"100000001"
],
"id": 1
}
Example Response:
{
"jsonrpc": "2.0",
"result": {
"increment_id": "100000001",
"creditmemo_id": 1,
"order_id": 1,
"order_increment_id": "100000001",
"created_at": "2023-01-17 09:45:20",
"state": 2,
"grand_total": 150.00,
"subtotal": 140.00,
"adjustment_positive": 0.00,
"adjustment_negative": 0.00,
"shipping_amount": 10.00,
"tax_amount": 0.00,
"store_id": 1,
"billing_address": {
"firstname": "John",
"lastname": "Doe",
"street": "123 Main St",
"city": "Anytown",
"region": "California",
"postcode": "12345",
"country_id": "US",
"telephone": "555-123-4567"
},
"shipping_address": {
"firstname": "John",
"lastname": "Doe",
"street": "123 Main St",
"city": "Anytown",
"region": "California",
"postcode": "12345",
"country_id": "US",
"telephone": "555-123-4567"
},
"items": [
{
"item_id": 1,
"parent_id": 1,
"sku": "product123",
"name": "Test Product",
"qty": 2.0000,
"price": 70.00,
"tax_amount": 0.00,
"row_total": 140.00,
"order_item_id": 1
}
],
"comments": [
{
"comment_id": 1,
"parent_id": 1,
"created_at": "2023-01-17 09:45:20",
"comment": "Credit memo created"
}
]
},
"id": 1
}
Possible Errors:
creditmemo_not_exists
- Credit memo does not exist
create¶
Create a new credit memo for an order.
Method Name: sales_order_creditmemo.create
Parameters:
orderIncrementId
(string, required) - Order increment IDcreditmemoData
(object, optional) - Credit memo data:items
(array, optional) - Array of items to refund:order_item_id
(int) - Order item IDqty
(float) - Quantity to refund
comment
(string, optional) - Credit memo commentadjustment_positive
(float, optional) - Positive adjustment amountadjustment_negative
(float, optional) - Negative adjustment amountshipping_amount
(float, optional) - Shipping amount to refundrefund_to_store_credit
(boolean, optional) - Whether to refund to store creditcomment
(string, optional) - Credit memo commentemail
(boolean, optional) - Whether to send email notification (default: false)includeComment
(boolean, optional) - Whether to include comment in email (default: false)
Return:
- (string) - Credit memo increment ID
Example Request:
{
"jsonrpc": "2.0",
"method": "call",
"params": [
"session_id",
"sales_order_creditmemo.create",
[
"100000001",
{
"items": {
"1": {"qty": 2}
},
"shipping_amount": 10.00
},
"Credit memo created",
true,
true
]
],
"id": 1
}
Example Response:
Possible Errors:
order_not_exists
- Order does not existorder_not_refundable
- Order cannot be refundeddata_invalid
- Invalid data provided
addComment
¶
Add a comment to a credit memo.
Method Name: sales_order_creditmemo.addComment
Parameters:
creditmemoIncrementId
(string, required) - Credit memo increment IDcomment
(string, required) - Comment textemail
(boolean, optional) - Whether to send email notification (default: false)includeInEmail
(boolean, optional) - Whether to include comment in email (default: false)
Return:
- (boolean) - True on success
Example Request:
{
"jsonrpc": "2.0",
"method": "call",
"params": [
"session_id",
"sales_order_creditmemo.addComment",
["100000001", "Refund processed", true, true]
],
"id": 1
}
Example Response:
Possible Errors:
creditmemo_not_exists
- Credit memo does not exist
cancel¶
Cancel a credit memo.
Method Name: sales_order_creditmemo.cancel
Parameters:
creditmemoIncrementId
(string, required) - Credit memo increment ID
Return:
- (boolean) - True on success
Example Request:
{
"jsonrpc": "2.0",
"method": "call",
"params": [
"session_id",
"sales_order_creditmemo.cancel",
"100000001"
],
"id": 1
}
Example Response:
Possible Errors:
creditmemo_not_exists
- Credit memo does not existcreditmemo_not_cancelable
- Credit memo cannot be canceled