Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Module: Order Credit Memo API

Resource: sales_order_creditmemo

Aliases: order_creditmemo
Method:
  • order_creditmemo.create (SOAP V1)
  • salesOrderCreditmemoCreate (SOAP V2)

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:

TypeNameDescription
stringsessionIdSession ID
stringorderIncrementIdOrder increment ID
arraycreditmemoDataArray of salesOrderCreditmemoData (optional)
stringcommentComment text (optional)
intnotifyCustomerNotify customer by email flag (optional)
intincludeCommentInclude comment text into an email notification (optional)
stringrefundToStoreCreditAmountPayment amount to be refunded to the customer store credit (optional)

Return:

TypeNameDescription
stringresultCreated credit memo increment ID

The salesOrderCreditmemoData content is as follows:

TypeNameDescription
arrayqtysArray of orderItemIdQty
doubleshipping_amountRefund shipping amount (optional)
doubleadjustment_positiveAdjustment refund amount (optional)
doubleadjustment_negativeAdjustment fee amount (optional)

The orderItemIdQty content is as follows:

TypeNameDescription
intorder_item_idOrder item ID to be refunded
doubleqtyItems quantity to be refunded

Faults:

Fault CodeFault Message
102Invalid data given. Details in error message.
103Requested order does not exist.
105Money can not be refunded to the store credit account as order was created by guest.
106Credit 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);