This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun verifyCustomPaymentRailSettlement(obligation: Obligation<TokenType>, payment: CustomPayment<TokenType>): VerifyResult { | |
| val oracleService = serviceHub.cordaService(MyPaymentRailService::class.java) | |
| val result = oracleService.hasPaymentSettled(payment, obligation) | |
| // .. check result status, etc.. | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @CordaService | |
| class MyPaymentRailService(val services: AppServiceHub) : SingletonSerializeAsToken() { | |
| // API Methods here | |
| // checkObligeeReceivedPayment(..) | |
| // hasPaymentSettled(..) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class VerifySettlement(private val otherSession: FlowSession) : FlowLogic<Unit>() { | |
| // .. omitting .. | |
| @Suspendable | |
| override fun call() { | |
| // .. omitting .. | |
| // 4. Handle different settlement methods. | |
| val verifyResult = when (settlementMethod) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| abstract class CustomMakeOffLedgerPayment<T: TokenType>( | |
| val amount: Amount<T>, | |
| private val obligationStateAndRef: StateAndRef<Obligation<*>>, | |
| open val settlementMethod: OffLedgerPayment<*>, | |
| override val progressTracker: ProgressTracker = MakeOffLedgerPayment.tracker() | |
| ): MakeOffLedgerPayment<T>(amount, obligationStateAndRef, settlementMethod, progressTracker) { | |
| @Suspendable | |
| override fun setup() { | |
| // Perform any setup tasks needed for your payment rail | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| abstract class CustomMakeOffLedgerPayment<T: TokenType>( | |
| val amount: Amount<T>, | |
| private val obligationStateAndRef: StateAndRef<Obligation<*>>, | |
| open val settlementMethod: OffLedgerPayment<*>, | |
| override val progressTracker: ProgressTracker = MakeOffLedgerPayment.tracker() | |
| ): MakeOffLedgerPayment<T>(amount, obligationStateAndRef, settlementMethod) { | |
| @Suspendable | |
| override fun setup() { | |
| // Perform any setup tasks needed for your payment rail | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data class CustomPayment<T : TokenType>( | |
| override val paymentReference: PaymentReference, | |
| override val amount: Amount<T>, | |
| override var status: PaymentStatus = PaymentStatus.SENT | |
| ) : Payment<T> { | |
| override fun toString(): String { | |
| return "Amount: $amount, Transaction ID: $paymentReference, Status: $status" | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data class CustomSettlementMethod( | |
| override val accountToPay: String, | |
| override val settlementOracle: Party, | |
| override val paymentFlow: Class<CustomMakeOffLedgerPayment<*>> = CustomMakeOffLedgerPayment::class.java | |
| ) : OffLedgerPayment<MakeCustomPayment<*>> { | |
| override fun toString(): String { | |
| return "Pay account $accountToPay and use $settlementOracle as settlement Oracle." | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @CordaService | |
| class MyPaymentRailService(val services: AppServiceHub) : SingletonSerializeAsToken() { | |
| // API methods here | |
| // makePayment() | |
| // checkBalance(), etc.. | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @CordaService | |
| class MyPaymentRailService(val services: AppServiceHub) : SingletonSerializeAsToken() { | |
| // API methods here | |
| // makePayment() | |
| // checkBalance(), etc.. | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @InitiatingFlow | |
| @StartableByRPC | |
| class IOUSettleFlow(val linearId: UniqueIdentifier, val amount: Amount<Currency>): FlowLogic<SignedTransaction>() { | |
| @Suspendable | |
| override fun call(): SignedTransaction { | |
| // Step 1. Retrieve the IOU state from the vault. | |
| val queryCriteria = QueryCriteria.LinearStateQueryCriteria(linearId = listOf(linearId)) | |
| val iouToSettle = serviceHub.vaultService.queryBy<IOUState>(queryCriteria).states.single() | |
| val counterparty = iouToSettle.state.data.lender |
NewerOlder