TABLE OF CONTENTS

Collecting Payments Automatically - Scheduled Job

Payments can be automatically collected against an existing authorisation by creating a payment record where the following conditions are true:


  • The payment record is set to “Awaiting submission”

  • The payment record is attached to an authorisation

  • The attached authorisation's status is “In force”



An overnight batch job will run and attempt to collect any payments that fulfil these above criteria.  This payment record can be created manually as above. However, more commonly in practice, it can also be created automatically as part of a Lightning flow, Process, Apex trigger or any other method Salesforce provides for automation.


Processing New Payment linked with Authorisation Record from code

A Flow is added with Release 2.17. This flow process a single payment immediately, from the linked authorisation, and can be called from code. The flow api name is asp04.Process_Immediate_Payment. This flow need "payment Id" as input.


Sample code to call this flow is below


Map<StringObject> params = new Map<StringObject>(); String paymentId = 'a040C000003pTXaQAM'//Replace with actual payment id. params.put('paymentId', paymentId); Flow.Interview calcFlow = new Flow.Interview.asp04.Process_Immediate_Payment(params); calcFlow.start();


Collecting a payment and an authorisation simultaneously

Many business cases require collecting an initial payment from a customer, and simultaneously collecting an authorisation so future payments can be collected seamlessly.


To do this:


  • Create a new payment record with the amount of the initial payment
  • Create a new authorisation record
  • Set the "Authorisation" field on the payment record to the authorisation created in the previous step
  • Hit the "Process payment" button to process the payment and authorisation from within Salesforce, or distribute the link contained in the "Ecommerce URL" to the customer for processing.
  • When the payment page has been filled in and processed, both the payment and authorisation record will be populated with the result of the transaction. The authorisation record can then be used to process any future payments as and when required.