header

Magento 1.x Software Support Notice

For Magento Commerce 1, Magento is providing software support through June 2020. Depending on your Magento Commerce 1 version, software support may include both quality fixes and security patches. Please review our Magento Software Lifecycle Policy to see how your version of Magento Commerce 1 is supported.

For Magento Open Source 1.5 to 1.9, Magento is providing software security patches through June 2020 to ensure those sites remain secure and compliant. Visit our information page for more details about our software maintenance policy and other considerations for your business.

Memo Create

Module: Order Credit Memo API

Resource: sales_order_creditmemo

Aliases: order_creditmemo
Method:

Allows you to create a new credit memo for the invoiced order. Comments can be added and an email notification can be sent to the user email.

Arguments:

Type Name Description
string sessionId Session ID
string orderIncrementId Order increment ID
array creditmemoData Array of salesOrderCreditmemoData (optional)
string comment Comment text (optional)
int notifyCustomer Notify customer by email flag (optional)
int includeComment Include comment text into an email notification (optional)
string refundToStoreCreditAmount Payment amount to be refunded to the customer store credit (optional)

Return:

Type Name Description
string result Created credit memo increment ID

The salesOrderCreditmemoData content is as follows:

Type Name Description
array qtys
Array of orderItemIdQty
double shipping_amount
Refund shipping amount (optional)
double adjustment_positive
Adjustment refund amount (optional)
double adjustment_negative
Adjustment fee amount (optional)

The orderItemIdQty content is as follows:

Type Name Description
int order_item_id
Order item ID to be refunded
double qty
Items quantity to be refunded

Faults:

Fault Code Fault Message
102 Invalid data given. Details in error message.
103 Requested order does not exist.
105 Money can not be refunded to the store credit account as order was created by guest.
106 Credit memo for requested order can not be created.

Examples

Request Example SOAP V1
$client = new SoapClient('http://magentohost/api/soap/?wsdl');

// If somestuff requires API authentication,
// then get a session token
$session = $client->login('apiUser', 'apiKey');

$result = $client->call($session, 'order_creditmemo.create', '200000010');
var_dump ($result);
Request Example SOAP V2
$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl'); // TODO : change url
$sessionId = $proxy->login('apiUser', 'apiKey'); // TODO : change login and pwd if necessary

$result = $proxy->salesOrderCreditmemoCreate($sessionId, '200000010');
var_dump($result);
Request Example SOAP V2 (WS-I Compliance Mode)
$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl'); 

$sessionId = $proxy->login((object)array('username' => 'apiUser', 'apiKey' => 'apiKey')); 
 
$result = $proxy->salesOrderCreditmemoCreate((object)array('sessionId' => $sessionId->result, 'creditmemoIncrementId' => '200000010', 
'creditmemoData' => array(
'qtys' => array(
'order_item_id' => 3,
'qty' => '1'),
'shipping_amount' => null,
'adjustment_positive' => '0',
'adjustment_negative' => null),
'comment' => 'comment for credit memo',
'notifyCustomer' => null,
'includeComment' => 1,
'refundToStoreCreditAmount' => '1'
));   
var_dump($result->result);