S++Core systems, human-reviewable
DEMO SOURCE · SPP / APP / PHYRead the book

petshop-scene-fundShopWallet.spp

petshop/payment/petshop-scene-fundShopWallet.spp

Download original file · Petstore source contents

1domain petshop;23atomic check checkFundingAmount(WalletFundingAgreement) {4    require(walletFundingAgreement.amount > 0, RejectionCode.INVALID_FUNDING_AMOUNT);5}67atomic calculate prepareWalletFunding(Buyer, SettlementAccount, WalletFundingAgreement) {8    settlementAccount.accountNumber = "EXTERNAL-SETTLEMENT";9    walletFundingAgreement.buyer = buyer;10    walletFundingAgreement.source = settlementAccount;11}1213quantum update transferWalletFunds(Buyer, SettlementAccount, WalletFundingAgreement) {14    settlementAccount.balance -> buyer.wallet : walletFundingAgreement.amount;15}1617Scenario serial fundShopWallet(Buyer, SettlementAccount, WalletFundingAgreement) {18    checkBuyerCredential;19    checkFundingAmount;20    prepareWalletFunding;21    parallel {22        findBuyer;23        findSettlementAccount;24    }25    identify(buyer);26    identify(settlementAccount);27    transaction {28        transferWalletFunds bounds {29            settlementAccount.balance: [null, null];30            buyer.wallet: [0, null];31        };32    }33}