Invoice API

Last modified by mjohnsonperl on Wed, April 29, 2009 01:53
Source|Old Revisions  

Allows create/export order invoices

Module: Mage_Sales

Resource: sales_order_invoice

Aliases:

  • order_invoice

Methods

sales_order_invoice.list

Retrieve list of invoices by filters

Return: array Arguments:

  • array filters - filters for invoices list (optional)

Aliases:

  • order_invoice.list

sales_order_invoice.info

Retrieve invoice information

Return: array

Arguments:

  • string invoiceIncrementId - invoice increment id

Aliases:

  • order_invoice.info

sales_order_invoice.create

Create new invoice for order

Return: string

Arguments:

  • string orderIncrementId - order increment id
  • array itemsQty - items qty to invoice
  • string comment - invoice comment (optional)
  • boolean email - send invoice on e-mail (optional)
  • boolean includeComment - include comments in e-mail (optional)

Aliases:

  • order_invoice.create

sales_order_invoice.addComment

Add new comment to shipment

Arguments:

  • string invoiceIncrementId - invoice increment id
  • string comment - invoice comment
  • boolean email - send invoice on e-mail (optional)
  • boolean includeComment - include comments in e-mail (optional)

Aliases:

  • order_invoice.addComment

sales_order_invoice.capture

Capture invoice

Return: boolean

Arguments:

  • string invoiceIncrementId - invoice increment id

Aliases:

  • order_invoice.capture

Notes:

You should check the invoice to see if can be captured before attempting to capture an invoice, otherwise the API call with generate an error.

Invoices have states as defined in the model Mage_Sales_Model_Order_Invoice:

  • STATE_OPEN = 1
  • STATE_PAID = 2
  • STATE_CANCELED = 3

Also note there is a method call in the model that checks this for you canCapture(), and it also verifies that the payment is able to be captured, so the invoice state might not be the only condition that’s required to allow it to be captured.

sales_order_invoice.void

Void invoice

Return: boolean

Arguments:

  • string invoiceIncrementId - invoice increment id

Aliases:

  • order_invoice.void

sales_order_invoice.cancel

Cancel invoice

Return: boolean

Arguments:

  • string invoiceIncrementId - invoice increment id

Aliases:

  • order_invoice.cancel

Faults

Fault Code Fault Message
100 Requested shipment does not exists.
101 Invalid filters given. Details in error message.
102 Invalid data given. Details in error message.
103 Requested order does not exists
104 Invoice status not changed.

Examples

Example 1. Basic working with invoices.

  1. $proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
  2. $sessionId = $proxy->login('apiUser', 'apiKey');
  3.  
  4. $notInvoicedOrderId  = '100000003';
  5.  
  6. // Create new invoice
  7. $newInvoiceId = $proxy->call($sessionId, 'sales_order_invoice.create', array($notInvoicedOrderId, array(), 'Invoice Created', true, true));
  8.  
  9. // View new invoice
  10. $invoice = $proxy->call($sessionId, 'sales_order_invoice.info', $newInvoiceId);
  11.  
  12. var_dump($invoice);
  13.  
  14. // Add Comment
  15. $proxy->call($sessionId, 'sales_order_invoice.addComment', array($newInvoiceId, 'Invoice comment, some text', true, false));
  16.  
  17. // View invoice with new comment
  18. $invoice = $proxy->call($sessionId, 'sales_order_invoice.info', $newInvoiceId);
  19.  
  20. var_dump($invoice);
  21.  
  22. $proxy->call($sessionId, 'sales_order_invoice.capture', $newInvoiceId);
  23.  
  24. // View captured invoice
  25. $invoice = $proxy->call($sessionId, 'sales_order_invoice.info', $newInvoiceId);
  26. var_dump($invoice);



 

Magento 2 GitHub Repository

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs