Skip to main content

Debit Order Collection Files

In order to process debit order collections, you will be required to upload collection files to Stitch's SFTP server. Stitch will validate the schema and data and send you a REPLY file containing validation results.

Once validation is completed, Stitch will process your valid collections. Once the processing is complete, Stitch will send you a final OUTPUT file detailing the results of the collections.

note

A collection initially marked with a status of SUCCESS may later be followed by an UNPAID record in a subsequent OUTPUT file.

Validation

All valid collections will be processed. Should you have any validation errors, Stitch will send back a REPLY file with the collection items being processed and the failed collection items and their failure reasons. You will be required to correct the issues and submit only the collection requests that had errors as a new batch ( the valid collections would have been previously processed).

Example:
If you submitted 3 collections and 2 failed validation, Stitch will notify you via a REPLY file like the example below:

| Record type   | CLIENT_ID                            | PRODUCT                  | CHANNEL                       | FILE_TYPE          |
|---------------|--------------------------------------|--------------------------|-------------------------------|--------------------|
| P | bf482d8d-0423-4a77-937b-a5b4d75bd734 | COLLECTIONS | DEBIT ORDER | REPLY |
|---------------|--------------------------------------|--------------------------|-------------------------------|--------------------|-----------|-----------------------|----------------------------|
| Record type | LINE | EXTERNAL_BATCH_REFERENCE | EXTERNAL_COLLECTION_REFERENCE | CONTRACT_REFERENCE | STATUS | STATUS_CODE | STATUS_REASON |
|---------------|--------------------------------------|--------------------------|-------------------------------|--------------------|-----------|-----------------------|----------------------------|
| D | 6 | Batch_reference_1 | COLLECTION_REF_1 | CONTRACT_REF_1 | FAILED | DATA_VALIDATION_ERROR | INVALID_BRANCH_CODE |
| D | 7 | Batch_reference_1 | COLLECTION_REF_2 | CONTRACT_REF_2 | FAILED | DATA_VALIDATION_ERROR | DUPLICATE_COLLECTION_NONCE |
| D | 8 | Batch_reference_1 | COLLECTION_REF_3 | CONTRACT_REF_3 | SUCCESS | | |
|---------------|--------------------------------------|--------------------------|-------------------------------|--------------------|-----------|-----------------------|----------------------------|
| Record type | TOTAL RECORDS |
|---------------|--------------------------------------|
| T | 3 |

The successful collection on line 8 will have been processed, while the other two collections that failed validation must be resubmitted as a new batch once the issues have been rectified.

In the case of no validation errors on submitted collections, you will receive a REPLY file as an acknowledgement containing all collection items being processed.

File Types and Validation

Collections involve 3 file types: Outgoing, Reply and Output. They will all be in CSV format and all files will have 4 record types. These can be seen below:

Record typeDescription
PProduct Header record detailing client ID, product information and file type
HHeader record detailing overall information about the collection
DData record that contains the collection request details. All other records are metadata
TTrailer record that houses summary information

Outgoing Collection File

This is the CSV file containing all your collection requests. You are required to send this to Stitch to process your collections. The file structure is as follows:

FieldRecord typeDescriptionTypeExample value
CLIENT_IDPClient ID as issued during onboardingUUID399a7ed1-0617-40f1-a9b7-d66f07b3a29d
PRODUCTPProduct that the file is for. In this case, it will always be COLLECTIONSStringCOLLECTIONS
CHANNELPChannel within a specific product that the file is for. This will always be DEBIT ORDERStringDEBIT ORDER
FILE_TYPEPType of file indicating what contents should be expected. This will be COLLECTIONStringCOLLECTION
EXTERNAL_BATCH_REFERENCE
required
HClient specified reference to uniquely identify a collection batch.
(Maximum permissible length: 4096 characters)
StringMY_REF
SUBMISSION_DATETIME
required
HThe datetime the collection was submitted.ISO 86012023‐08‐31T12:11:20+07:00
NONCE
required
DA unique string per collection request.
(Minimum permissible length: 8 characters.
Maximum permissible length: 36 characters)
String14lji0cpjloigq
EXTERNAL_COLLECTION_REFERENCE
required
DClient specified reference to uniquely identify a collection.
(Maximum permissible length: 4096 characters)
StringMY_COLL_01
VALUE
required
DThe amount to be collectedDecimal3000.00
COLLECTION_DATE
required
DThe collection date for the debit order.ISO 86012023-09-25
CONTRACT_REFERENCE
required
DContract reference for the authorised mandate as specified on the Payment Consent.StringMY_CONTRACT_REF
DEBTOR_NAME
required
DThe name on the account of the debtor for the collectionStringJohn Doe
DEBTOR_ACCOUNT_NUMBER
required
DThe account number to be collected fromInteger97834567890
DEBTOR_BRANCH_CODE
required
DThe branch code for the account number suppliedInteger050001
DEBTOR_ACCOUNT_TYPE
required
DThe debtor's account type. Possible values are Current, Savings, Transmission, Bond and SubscriptionStringCurrent
TOTAL_RECORDS
required
TTotal number of collection items within the fileInteger25
TOTAL_VALUE
required
TThe total value of all the collectionsDecimal10000.00

Sample Incoming Debit Order Collection File

Download sample incoming file

Reply File

A REPLY file will inform you of validation results on your collection request and and will indicate which items within the collection batch were submitted, and which were not. Once you have submitted a collection batch file, Stitch will perform two types of validation:

Here are the columns in the REPLY file. The REPLY file communicates the outcome of all of the entries within the submitted collection file, both successes and failures.

FieldDescriptionTypeExample value
RECORD_TYPEThe type of record it is. Values can be P, H, D, or TStringD
LINEWhich line in the file this error pertains toInteger4
EXTERNAL_BATCH_REFERENCEIn the case of a data validation error, the batch reference of the incoming collection fileStringMY_BATCH_01
EXTERNAL_COLLECTION_REFERENCEIn the case of a data validation error, the collection reference for the collection line itemStringMY_COLL_01
CONTRACT_REFERENCEIn the case of a data validation error, the Contract reference for the collection line itemStringMY_CONTRACT_REF
STATUSThe status result from the validation. Value can be SUCCESS and FAILEDStringFAILED
STATUS_CODEIndicates whether the collection was submitted or not. In the case that it wasn't, indicates why the collection was not submitted. In the case of failure, the code can be either SCHEMA_VALIDATION_FAILED or DATA_VALIDATION_FAILED.StringSCHEMA_VALIDATION_FAILED
STATUS_REASONProvides detail information about the STATUS_CODEStringHEADER_RECORD_REQUIRED

Schema Validation

Schema validation will involve validating that the file that was sent to Stitch abides by the expected schema.

Failure would result in a SCHEMA_VALIDATION_FAILED error reason in the REPLY file header and, where possible, the data records that failed schema validation. When a file fails schema validation, no collections in that file will be processed.

The table below details possible values for STATUS_REASON in the case of a failure, indicating which part of the schema failed validation:

FieldRuleStatus reasonDescription
Product Header recordsProduct Header record requiredPRODUCT_HEADER_RECORD_REQUIREDProduct Header record required
Product Header recordsNumber of header record fieldsINVALID_PRODUCT_HEADER_RECORDIncorrect number of product header record fields provided
Product Header recordsValidate the titles of the product header rowsINVALID_PRODUCT_HEADER_RECORD_TITLEIncorrect product header titles provided
Header recordsHeader record requiredHEADER_RECORD_REQUIREDHeader record required
Header recordsValidate the titles of the header rowsINVALID_HEADER_RECORD_TITLEIncorrect header titles provided
Header recordsNumber of header record fieldsINVALID_HEADER_RECORDIncorrect number of header record fields provided
Data recordsValidate the titles of the detail rowsINVALID_DETAIL_RECORD_TITLEIncorrect detail titles provided
Data recordsNumber of detail record fieldsINVALID_DETAIL_RECORDIncorrect number of detail record fields provided
Data recordsAt least one detail record requiredDETAIL_RECORD_REQUIREDDetails record required
Trailer recordsValidate the titles of the trailer rowsINVALID_TRAILER_RECORD_TITLEIncorrect trailer titles provided
Trailer recordsTrailer record requiredTRAILER_RECORD_REQUIREDTrailer record required
Trailer recordsNumber of trailer record fieldsINVALID_TRAILER_RECORDIncorrect number of trailer record fields provided
GeneralIncorrect record type specified in the record type fieldINCORRECT_RECORD_TYPEIncorrect record type specified. This may be due to an unexpected ordering of the provided record types.
Formatting and Data Validation Rules for header, product header and trailer record
FieldRecord typeRuleStatus reasonDescription
CLIENT_IDPClient ID as provided during onboardingINVALID_CLIENT_IDProvided Client ID doesn't match expected Client ID
PRODUCTPAlways COLLECTIONSINVALID_PRODUCTUnexpected product provided
FILE_TYPEPAlways COLLECTIONINVALID_FILE_TYPEInvalid file type provided
CHANNELPAlways DEBIT ORDERINVALID_CHANNELInvalid channel provided
EXTERNAL_BATCH_REFERENCEHBatch references should be unique for batches that pass schema validationDUPLICATE_BATCH_REFERENCEA batch with this reference already exists
EXTERNAL_BATCH_REFERENCEHBatch reference requiredBATCH_REFERENCE_REQUIREDMissing batch reference
SUBMISSION_DATETIMEHISO 8601 format for submission datetimeINVALID_SUBMISSION_DATEInvalid submission date provided
TOTAL_RECORDSTShould be equal to the total count of the D recordsMISMATCHED_TOTAL_RECORDSTotal records does not match total details records provided
TOTAL_VALUETShould be equal to the sum of the value of the D recordsMISMATCHED_TOTAL_VALUETotal value does not match the sum of the value of the details records provided
Example Invalid Reply File

Download sample REPLY file - Schema validation failure

Schema Validation failure
  • If the product header or header records of a collection file fail schema validation, the remainder of the collection file is not processed. The corresponding REPLY file may contain only validation results for the P and H records, omitting validation results for D records.
  • Multiple validation results for the same line may be present in the REPLY file, so there may be multiple lines referencing the same line in the collection file.

Data Validation

Data validation is carried out on all "Data" (D) record types within the file.

  • Formatting rules are used to validate if the format or schema of the file adheres to the format rules.
  • Data rules are used to validate whether the data of each item in the file adheres to the data rules.

A validation failure would result in a DATA_VALIDATION_FAILED status code in the REPLY file header with each data validation status reason appearing alongside each collection row.

Formatting Rules for data record
FieldRecord typeRuleStatus reasonDescription
Data recordsDAt least one detail record requiredDETAIL_RECORD_REQUIREDDetails record required
EXTERNAL_COLLECTION_REFERENCEDCollection reference requiredINVALID_VALUEMissing collection reference
NONCEDUnique nonce requiredINVALID_VALUEMissing nonce
CONTRACT_REFERENCEDContract reference requiredINVALID_VALUEMissing contract reference
COLLECTION_DATEDISO 8601 format for dateINVALID_COLLECTION_DATEInvalid date provided
VALUEDDecimal format for valueINVALID_VALUEInvalid value provided
DEBTOR_NAMEDDebtor name is requiredINVALID_VALUEMissing debtor name
DEBTOR_ACCOUNT_NUMBERDDebtor account number is requiredINVALID_VALUEMissing account number
DEBTOR_BRANCH_CODEDDebtor branch code is requiredINVALID_VALUEMissing branch code
DEBTOR_ACCOUNT_TYPEDDebtor account type is requiredINVALID_VALUEMissing account type
Data rules
FieldRuleStatus reasonDescription
SUBMISSION_DATETIMEDate must be current dateINVALID_SUBMISSION_DATEInvalid submission date provided
NONCENonce should be unique per collectionINVALID_NONCECollection with this nonce already exists or has incorrect length
COLLECTION_DATEDate should be a date in the future (at least 3 days in the future)INVALID_COLLECTION_DATEInvalid collection date provided
COLLECTION_DATEDate should match the frequency and day as per mandate.INVALID_COLLECTION_DATEInvalid collection date provided
COLLECTION_DATEOnly one collection attempt can be created per mandate cycle (configured during onboarding).DUPLICATE_COLLECTION_ACTION_DATECollection with same collection date already exists
VALUEValue should match what's on the mandateINVALID_VALUEInvalid value provided
DEBTOR_NAMEPermitted upto 35 characters long.INVALID_NAMEAccount name has incorrect length
DEBTOR_ACCOUNT_NUMBERShould be a vaild account number.INVALID_ACCOUNTInvalid account number
DEBTOR_ACCOUNT_NUMBERShould be a valid branch code.INVALID_BRANCH_CODEInvalid branch code provided
DEBTOR_ACCOUNT_TYPEShould be a valid account type. One of Current, Savings, Transmission, Bond and SubscriptionINVALID_ACCOUNT_TYPEInvalid branch code provided
Sample Reply File

Download sample REPLY file - Data validation failure for the product header

Download sample REPLY file - Data validation failure for the header

Download sample REPLY file - Data validation failure for the data and trailer

Data Validation failure
  • If the product header or header records of a collection file fail data validation, the remainder of the collection is not processed. The corresponding REPLY file may contain only validation results for the P and H records, omitting validation results for D records.
  • If the product header and header records of a collection file pass data validation, but some data records fail data validation, the header will be processed and the data records that pass data validation will be processed.
  • The data records that fail data validation will be sent back for correction and resubmission in the REPLY file with a status of FAILED. Any data records that passed data validation will also be included with a status of SUCCESS.
  • Multiple validation results for the same line may be present in the REPLY file, so there may be multiple lines referencing the same line in the collection file.

Output File

An OUTPUT file will be used to inform you of the collection results for all the valid collections that were submitted. You will receive this file daily, and it will reflect any updates to collections that were processed during the day.

FieldRecord typeDescriptionTypeExample value
RECORD_TYPEP,H,D,TDenotes the record type. Either P,H,D or TStringD
CLIENT_IDPClient ID as issued during onboardingUUID399a7ed1-0617-40f1-a9b7-d66f07b3a29d
PRODUCTPProduct that the file is for. In this case, it will always be COLLECTIONSStringCOLLECTIONS
CHANNELPChannel within a specific product that the file is for. This will always be DEBIT ORDERStringDEBIT ORDER
FILE_TYPEPType of file indicating what contents should be expected. This will be either REPLY, OUTPUT, DISPUTEStringREPLY
EXTERNAL_BATCH_REFERENCEDThe client specified batch reference, as it was supplied in the original collection file.StringMY_COLL_03
EXTERNAL_COLLECTION_REFERENCEDThe original external collection reference for the collection, as supplied by you in the Incoming fileStringMY_COLL_03
CONTRACT_REFERENCEDContract reference of the mandateStringcontractRefernce1
COLLECTION_IDDThe unique ID for the collectionStringZGUxZGM5NDItMGNkYS00ZDgzLTkxYzctMzY0N2MxODJlNGE5
COLLECTION_DATEDDate on which the funds were collected, in ISO 8601 formatISO 86012023-09-25
VALUEDCollection valueDecimal653.04
COLLECTION_STATUSDThe status of the collection from the debtorStringFAILED
COLLECTION_REASONDReason for the associated failed collection statusStringIncorrect collection date
BANK_CODEDUnderlying bank response code for the collectionString900001
BANK_CODE_DESCRIPTIONDUnderlying bank response description for the collectionStringMandate is Suspended
SETTLEMENT_STATUSDThe status of the settlement to the clientStringPENDING
SETTLEMENT_REFERENCEDThe reference for the settlement payment to the client (case-insensitive)StringHJ24GNBZC
TOTAL_RECORDSTTotal # of collection items within the fileInteger25
TOTAL_COLLECTION_VALUETTotal value of the collections within the fileDecimal10000.00
TOTAL_COLLECTION_SUCCESS_RECORDSTTotal number of successful collectionsInteger15
TOTAL_COLLECTION_SUCCESS_VALUETTotal value of successful collectionsDecimal7856.00
TOTAL_COLLECTION_FAILED_RECORDSTTotal number of failed collectionsInteger10
TOTAL_COLLECTION_FAILED_VALUETTotal value of failed collectionsDecimal0.00
TOTAL_COLLECTION_PENDING_RECORDSTTotal number of collections in pending stateInteger2
TOTAL_COLLECTION_PENDING_VALUETTotal value of collections in pending stateDecimal0.00
Sample Output file

Download sample OUTPUT file - OUTPUT file type

Daily files

OUTPUT files will be generated daily. They will include collections that were processed by the end of that specific day, as well as any collections whose settlement statuses have changed. An OUTPUT file can reflect collection results across different collection batches.

Below are the possible collection reason codes that can be received in an OUTPUT file per collection line item:

COLLECTION_STATUSRECORD_TYPECOLLECTION_REASONDescription
SUCCESSDPROCESSEDCollection was successful
FAILEDDPAYMENT_SUSPENDEDPayment stopped by account holder
FAILEDDINSUFFICIENT_FUNDSInsufficient funds in the debtors account
FAILEDDBANK_ERRORA system error occurred at the bank
FAILEDDBANK_PROCESSING_ERRORCreditor bank unable to process due to problem
FAILEDDINACTIVE_ACCOUNTAccount frozen, account in liquidation, account closed, account holder deceased or account in sequesterian
FAILEDDINVALID_ACCOUNTDebits not allowed on this account, account not found, or debtor account number fails CDV routine
FAILEDDBENEFICIARY_BANK_PROCESSING_ERRORCreditor bank unable to process due to problem
FAILEDDINVALID_BRANCH_CODEBranch code is invalid
PENDINGDPENDINGCollection has been submitted to partner bank for collection and will be actioned on collection date
DISPUTEDDDISPUTEDCollection has been disputed by the customer and has been reversed by the bank. Amount will be deducted from the settlement.

Below are the possible settlement statuses that can be received in an OUTPUT file per collection line item:

StatusRecord typeDescription
PENDINGDSettlement will be submitted to the bank after funds have been successfully collected from the debtor. No action required.
SUCCESSDSettlement was successfully submitted, and confirmation has been received by the bank.

File naming

Outgoing

These are files you send to Stitch.

In order to easily distinguish between different files, you will be required to follow the below naming conventions for any files you send to Stitch via SFTP. You will be placing your files in the Collections folder.
The complete file name will be : <product>/<datettime>_<index>.csv.

note
  • The product value corresponds with the PRODUCT value provided within the file as a part of the Product Header
  • The fileType value corresponds with the FILE_TYPE value provided within the file as a part of the Product Header
Collections Folder

Your files must be placed in the Collections folder. If your files aren't placed here, they will not be picked up.

Testing Collection Scenarios

When submitting collections using your test client, certain amounts can be specified as the collection amount in the outgoing collection file to simulate different collection success and failure scenarios. These scenarios will be reported in the output file.

The table below shows the supported amounts, status and collection reason mappings:

AmountStatusCollection reason
70.00-79.99FAILEDINVALID_BRANCH_CODE
60.00-69.99FAILEDBENEFICIARY_BANK_PROCESSING_ERROR
50.00-59.99FAILEDINVALID_ACCOUNT
40.00-49.99FAILEDINACTIVE_ACCOUNT
30.00-39.99FAILEDBANK_PROCESSING_ERROR
20.00-29.99FAILEDBANK_ERROR
10.00–19.99FAILEDINSUFFICIENT_FUNDS
0.01–9.99FAILEDPAYMENT_SUSPENDED
OtherSUCCESSPROCESSED
Note:

This only applies to test clients.