petshop-scene-fundShopWallet.spp
petshop/payment/petshop-scene-fundShopWallet.spp
Download original file · Petstore source contents
1domain petshop;23atomic check checkFundingAmount(WalletFundingAgreement) {4require(WalletFundingAgreement.amount > 0, "INVALID_FUNDING_AMOUNT");5}67atomic calculate prepareWalletFunding(Buyer, SettlementAccount, WalletFundingAgreement) {8SettlementAccount.accountNumber = "EXTERNAL-SETTLEMENT";9WalletFundingAgreement.buyer = Buyer;10WalletFundingAgreement.source = SettlementAccount;11}1213quantum update transferWalletFunds(Buyer, SettlementAccount, WalletFundingAgreement) {14SettlementAccount.balance -= WalletFundingAgreement.amount;15Buyer.wallet += WalletFundingAgreement.amount;16}1718Scenario serial fundShopWallet(Buyer, SettlementAccount, WalletFundingAgreement) {19checkBuyerCredential;20checkFundingAmount;21prepareWalletFunding;22parallel {23findBuyer;24findSettlementAccount;25}26identify(Buyer);27identify(SettlementAccount);28transaction {29transferWalletFunds bounds {30SettlementAccount.balance: [null, null];31Buyer.wallet: [0, null];32};33}34}