Skip to content

Instantly share code, notes, and snippets.

@raj-saxena
Last active June 29, 2019 20:44
Show Gist options
  • Save raj-saxena/c39a679a49c0aa27fbb108c1f4426738 to your computer and use it in GitHub Desktop.
Save raj-saxena/c39a679a49c0aa27fbb108c1f4426738 to your computer and use it in GitHub Desktop.
// BacsPayment
/*
----,
SQS ) => Received => AccountCheck => MandateCheck => Withdraw => Succeeded
----'
*/
fun processPayment(payment: BacsPayment<Received>) {
try {
val acccountCheck: BacsPayment<AccountChecked> = accountCheck(payment)
val mandateCheck: BacsPayment<MandateChecked> = mandateCheck(acccountChecked)
val debit: BacsPayment<DebitAttempted> = debit(currencyCheck)
completeProcessing(debit)
} catch(e: BacsPaymentException) {
}
}
fun accountCheck(payment: BacsPayment<Received>): BacsPayment<AccountChecked> = TODO()
fun mandateCheck(payment: BacsPayment<AccountCheckPassed>): BacsPayment<MandateChecked> = TODO()
fun debit(payment: BacsPayment<CurrencyCheckPassed>): BacsPayment<DebitAttempted> = TODO()
fun completeProcessing(payment: BacsPayment<DebitSuccessful>): BacsPayment<Succeeded> = TODO()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment