3

I have an order id. On basis of that I need to send the already created invoice to the customer.

1
  • 1
    You need to create your own rest API and add your code to trigger invoice email. Jun 24 '19 at 9:04
3
+50

Well since you have 'an already created invoice', I am assuming that you already know its ID. Moreover, I am assuming that you created that invoice via API also, that's how I know you know the ID :)

So that being said, besides all was mentioned above with the custom API endpoint where you add the order ID and it sends the invoice email, you could:

  1. use the Magento OOTB endpoint which sends the invoice email based on the invoice ID POST /rest/default/V1/invoices/{id}/emails (Redoc reference https://magento.redoc.ly/2.3.6-admin/tag/invoicesidemails)

  2. create the invoice via API all-together and send the email in the same step by using the endpoint POST /rest/default/V1/order/{orderId}/invoice (Redoc reference https://magento.redoc.ly/2.3.6-admin/tag/invoicesidemails#operation/salesInvoiceOrderV1ExecutePost)

1

If you Don't want to create an API for invoice then you can do one thing using order ID you can get all the invoice list using API and then from the response you can get all Invoice ID and call other api for send invoice for that particular invoice ID. Here are the API's with example which you can use.

  1. Get all Invoices from Order number

http://magento-host/rest/all/V1/invoices?searchCriteria[filterGroups][0][filters][0][field]=order_id&searchCriteria[filterGroups][0][filters][0][value]={your-order-id}&searchCriteria[filterGroups][0][filters][0][conditionType]=eq

Pass your order ID (Order entity_id) [value]={your-order-id} in this parameter in url.

In Response you will get the array of invoice with all the invoice details. You can get the invoice id from that array and store in variable and pass that in another API which is for sending invoice email.

  1. Send Invoice Email

http://magento-host/rest/all/V1/invoices/{invoice-id}/emails

pass your invoice id in {invoice-id} parameter

Hope this will help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.