S++Business systems language
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, "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 -= WalletFundingAgreement.amount;15    Buyer.wallet += WalletFundingAgreement.amount;16}1718Scenario serial fundShopWallet(Buyer, SettlementAccount, WalletFundingAgreement) {19    checkBuyerCredential;20    checkFundingAmount;21    prepareWalletFunding;22    parallel {23        findBuyer;24        findSettlementAccount;25    }26    identify(Buyer);27    identify(SettlementAccount);28    transaction {29        transferWalletFunds bounds {30            SettlementAccount.balance: [null, null];31            Buyer.wallet: [0, null];32        };33    }34}