InvoiceAPI Class

Global API Apex class for Salesforce Billing. Contains methods that you can call to cancel and rebill an invoice, or to credit an invoice.

blng

The InvoiceAPI class contains the creditInvoice method, which can be used to cancel and rebill an invoice, or to credit an invoice for a specified invoice ID.

Learn more about the methods available with the InvoiceAPI class.

The InvoiceAPI class includes these methods.

Use this method to cancel or rebill an invoice, or to credit an invoice.

global static String creditInvoice(Id invoiceId, String action)

invoiceId: Type: String ID of the invoice.

action: Type: String

Action to perform against the invoice. For example, Credit or Cancel and Rebill.

Valid values are:

  • Credit—The invoice must be in the Posted status.

  • Cancel and Rebill—

    If the invoice is in Posted status, then this action creates a credit note equal to the invoice’s total balance. The credit note contains credit note lines that are allocated in full to each of the invoice lines. This action also reverts the billing fields of an order product to their previous values. The status of the invoice is changed to Rebilled.

    If the invoice is in Draft status, then Salesforce Billing sets the status to Cancelled for the invoice and all invoice lines. This action also sets theInvoice Run Processing Status field of the order products to Pending Billing status.

    See Cancel and Rebill an Invoice.

Type: String

Keep these considerations in mind when using this method.

  • The invoice must not have any allocations before the credit invoice action is requested.
  • The associated CreditNote, CreditNoteLine, and CreditNoteAllocation records are created against the posted invoice for both Credit and Cancel and Rebill actions. The status of the invoice is changed to Credited.

For more information about Cancel and Rebill, as well as Credit actions, see Issuing Credits.