Payment and payment calculations - smbc-digital/form-builder GitHub Wiki

Payment configuration

Any form that processes a payment must have a payment configuration set up for each environment in the payment-config folder in S3. You can only use one of the payment types, you cannot use set in the same configuration. You can use that same configuration for multiple forms by adding the baseUrl of the form to the formName array.

If CivicaServicePay is required, you must set a value for Settings.ServicePayReference AND Settings.ServicePayNarrative. You can use TagParsers for these, see the examples below.

If your form journey will hand off to Civica, why not use this customer address feature: The Settings.AddressReference must match to a questionID on an Address element within the form, but that element must currently have manual address disabled, this will allow the customer address details to be passed to Civica.

Static payment amount

Where a form only allows 1 item at a set cost to be ordered at a time, you can use the static amount in the payment-configuration. An example of this would be additional black bin.

Example static payment configuration:

{
  "formName": [ "pay-using-config" ],
  "PaymentProvider": "CivicaPay",
  "settings": {
    "accountReference": "123456",,
    "addressReference": "{{QUESTION:yourAddress}}",
    "servicePayReference": "{{CASEREFERENCE}}",
    "servicePayNarrative": "{{QUESTION:firstName}} {{QUESTION:lastName}}",
    "name": "{{QUESTION:firstName}} {{QUESTION:lastName}}",
    "email": "{{QUESTION:email}}",
    "amount": "1.20",
    "catalogueId": "F0",
    "description": "Pay using the config"
  }
}

Complex payment calculations

Where a form allows 1 or more items to be ordered at a time, or where the cost is dependent on question answers, you should use the complex calculation that uses the forms Service API. An example of this would be pest control.

Example complex calculation payment configuration:

{
  "formName": [ "pay-using-service" ],
  "PaymentProvider": "CivicaPay",
  "settings": {
    "accountReference": "123456",
    "addressReference": "{{QUESTION:yourAddress}}",
    "servicePayReference": "{{QUESTION:existingCaseReference}}",
    "servicePayNarrative": "{{QUESTION:firstName}} {{QUESTION:lastName}}",
    "catalogueId": "F0",
    "description": "Pay using the service",
    "CalculationSlug": {
      "URL": "https://localhost:44399/api/v1/Pay/fake-cost",
      "AuthToken": "the auth token"
    }
  }
}