---
title: Create and Send
slug: payments/csfvxxsnqbqnf5dbtqzap
description: Learn how to create an invoice using Apex code with this informative document. Discover how to set invoice data and gather essential customer information, as well as specify item details such as price and quantity. Follow the step-by-step guide as the cod
docTags: 
createdAt: 2023-11-09T06:46:09.951Z
---

To create and send an Invoice in Stripe, use the action "CreateInvoice," set the invoiceStatus to "SEND\_TO\_CUSTOMER," and pass the Invoice data in the RequestJSON under "invoices."

:::hint{type="info"}
Note: You can only create one record at a time.
:::

The following is an example of Create and Send an Invoice, where we are setting every possible field (See [﻿](https://app.archbee.io/docs/-LIHUUnv_7XNQrtzHsKkC/hnjmkN99QxWdEafyYIFSq)[Invoice - Stripe](docId\:JG10UgmTnBrsw2A0WbE1K) for the available fields). The response will return the response from Stripe, which includes the new Stripe Invoice ID (*internalId*), plus the newly created Salesforce ﻿Invoice ID (*salesforceId*).

The following is an example of Create and Send an Invoice.

:::CodeblockTabs
```apex
Map<String, Object> invoiceData = new Map<String, Object>();
invoiceData.put('processorCustomerId', 'processorCustomerId');  
invoiceData.put('invoiceStatus', 'SEND_TO_CUSTOMER'); 
invoiceData.put('daysUntilDue', 2); 

List<object> items = new List<object>();
Map<String, Object> itemData = new Map<String, Object>();
itemData.put('processorPriceId', 'processorPriceId'); 
itemData.put('quantity', 2); 
items.add(itemData);
invoiceData.put('items', items); 

//  Initializing the RequestJSON Data to be passed.
Map<String, Object> requestJSONMap = new Map<String, Object>();
requestJSONMap.put('invoices', new List<Object>{invoiceData});
String reqJSON = JSON.serialize(requestJSONMap);

Map<String, Object> reqObj = new Map<String, Object>();
reqObj.put('version','1.0');
reqObj.put('action','CreateInvoice');
reqObj.put('processorId', 'processorId');
reqObj.put('requestJSON',reqJSON);

//  Placing a request to Breadwinner Global API
Map<String,Object> resp = bw_payments.BreadwinnerPaymentsAPI.call(reqObj);
System.debug(resp);
```

```json
{
  Action=CreateInvoice,
  statusCode=200,
  timestamp=1679050558749,
  validRequest=true
  Version=1.0,
  responseJSON={
    "invoices": [
      {
        "status": "Open",
        "salesforceId": "salesforceInvoiceId",
        "salesforceContact": null,
        "salesforceAccount": "salesforceAccountId",
        "processorPaymentMethodId": null,
        "processorOrgId": "processorOrgId",
        "processorInvoiceId": "processorInvoiceId",
        "processorCustomerId": null,
        "pendingInvoiceItemsBehavior": null,
        "metadataAsString": null,
        "lineItems": [
          {
            "unitAmountDecimal": 123.00,
            "unitAmount": 123.00,
            "salesforceSubscriptionId": null,
            "salesforcePriceId": "salesforcePriceId",
            "salesforceId": "salesforceLineItemId",
            "quantity": 2,
            "processorSubscriptionId": null,
            "processorPriceId": null,
            "processorInvoiceId": "processorInvoiceId",
            "processorId": "processorLineItemId",
            "name": null,
            "metadataAsString": null,
            "itemCurrency": null,
            "invoice": null,
            "errorMessage": null,
            "description": "One Time Prod",
            "deleted": null,
            "chargeCurrency": "USD",
            "amount": 246.00
          }
        ],
        "invoiceStatus": null,
        "footer": null,
        "errorMessage": null,
        "dueDate": "2023-03-19T10:55:56.000Z",
        "description": null,
        "daysUntilDue": null,
        "createdVia": "Breadwinner",
        "createdDateInProcessor": "2023-03-17T10:55:56.000Z",
        "coupon": null,
        "collectionMethod": "Send Invoice"
      }
    ]
  }
}
```
:::

