Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

To initiate a scheduled invoice generation, an Autolaunched Flow invoking the Invoice API invocable class should be created where the flow will be called in a Batch Job.

Here are the necessary steps to follow:

  1. Create a new Autolaunched Flow (No Trigger).

  2. Add a new input variable that will serve as the unique identifier for each record to process. This input variable is necessary for the Batch Job creation.

    1. Click the New Resource button.

    2. Provide the following details:

      1. Resource Type = Variable

      2. API Name = Desired API Name of the input variable

      3. Data Type = Text

      4. Available for input (under the Availability Outside the Flow) = TRUE

  3. Add a Get Records element to retrieve the exact record where an invoice will be generated.

    1. Make sure to provide the exact object of the record.

    2. Filter the records to be processed based on the stored record in the input variable.

  4. Add a Get Records element to retrieve the Gateway Account of the retrieved record from the previous action as it will be necessary to generate an invoice.

    1. Select Gateway Account as the Object

    2. Filter the records to retrieve ONLY the Gateway Account of the to-be-processed record

  5. Add an Action element to invoke the Invoice API invocable class.

    1. Filter by Type and select Apex Action

    2. Find and select the Invoice API invocable class.

    3. Provide the necessary details:

      1. Amount (required) = The amount of the record

      2. Currency (required) = The preferred currency to be used

      3. Gateway Account Record (required) = The Gateway Account of the record

      4. Related Record To (optional) = The record ID of the record you want to be linked in the Gateway Invoice. In this case, you can link the to-be-processed record to Gateway Invoice which will be created after the invoice generation.

      5. Related Record To - Field (optional) = The custom lookup field under the Gateway Invoice object that will be populated with the record ID of the linked record.

      6. Token (required) = The token that will be used in the payment processing during the invoice generation. You can use the Token from the Payment Source if your organization is using PosiPay’s Payment Source.

Note: This is a test setup on how to set up Invoice API in Schedule Flow

Note: The required batch size would be 60 only to prevent hitting a governor limit.

  1. Set up Flow

  • Create a Schedule Trigger Flow

  • Set Schedule

  • Select Object (ex. Opportunity)

Drag Get Records to the screen and select Gateway Account as Object and map the ID to the Opportunity Gateway Account

·        Drag Action to the Screen. Filter by Type and select Apex Action and select Invoice API as Action

·        Configure the apex action to pass the following Opportunity’s details to the invocable variables:

·   Gateway Account = Opportunity’s Gateway Account (custom field)

·   Amount = Opportunity’s Amount

·   Currency = Opportunity’s Currency

·   Token = Opportunity’s Payment Source (custom field) → Token

·   Relate Record To = Opportunity record ID

·  Relate Record To - Field = custom lookup field under the Gateway Invoice object that looks up to the Opportunity object

·        And Click Done

·   And after that, your flow should look like these

  • No labels