So, you can try this -
1. Assuming for each real time payment, front office user will open an API (using customer facing interface, assuming CRM webUI). Customer will confirm the contract account number. And then payment details will be entered. The payment details will be sent to the bank using secured communication channel (SFTP/PI-PO etc.). Once a successful message comes back from bank, it will generate a receipt number and at the same time invoke ERP system to call standard BAPI/function module to assign incoming payment method in the receivable. Custom logic needs to be written to determine the debit receivable document(s) based customer's entered payment amount.
At the end of business hours, an FPY1 batch needs to be processed with that payment method to create payment order number and assign the debit receivable with a truck sign. It would ensure that the document will not fall in to any debt recovery path.
2. At +2 days bank file will be received using SFTP/PI-PO. The file will need to be stored in some directory in application server.
There should be a processing program that will process each of the records in the file and call standard program for payment order lot. And then the lot will be posted and transferred. The transfer process will create payment clearing document and clear the debt.
Hope it helps.
Thanks
Bodhisattwa