static void Main() { SimplePayPaymentProcessor1 merchant_sender = new SimplePayPaymentProcessor1(); CaaS amazon = new CaaS(); AmazonSimplePayReturn1 merchant_receiver = new AmazonSimplePayReturn1(); Order init_order = p.NondetOrder(); GlobalState.order = new orderRecord(); canonicalRequestResponse res_placeorder = p.NodetReqres(); canonicalRequestResponse req_pay = p.NodetReqres(); canonicalRequestResponse res_pay = p.NodetReqres(); canonicalRequestResponse req_finish = p.NodetReqres(); // Computation on merchant - place order res_placeorder = merchant_sender.PostProcessPayment(init_order); assumeOrderProperties(res_placeorder); // Message: merchant -> client -> CaaS // is the msg encrypted? if so, then: req_pay = res_placeorder; GlobalState.MerchantPaymentEmail = req_pay.payee; GlobalState.order.gross = req_pay.gross; GlobalState.order.id = req_pay.orderID; // Computation on Amazon - pay res_pay = amazon.pay(req_pay); // Message: CaaS -> client -> merchant // is the msg encrypted? if so, then: req_finish = res_pay; merchant_receiver.Request = req_finish; Contract.Assume(res_pay.orderID == req_finish.orderID); GlobalState.CaaS_email_proxy = res_pay.payee; GlobalState.CaaS_gross_proxy = res_pay.gross; //we need this since boogie can't handle string concat // Computation on merchant - finish order merchant_receiver.Page_Load(null, null); res_pay.witness = GlobalState.witness; Contract.Assert(amazon.caas.payments[res_pay.witness].orderID == req_finish.orderID && amazon.caas.payments[res_pay.witness].gross == GlobalState.tstore.orders[req_finish.orderID].gross && amazon.caas.payments[res_pay.witness].payee == GlobalState.tstore.myDomain && amazon.caas.payments[res_pay.witness].status == CaasReturnStatus.Sucess); Contract.Assert(0 <= res_pay.witness && res_pay.witness < amazon.caas.payments.Length); Contract.Assert(Contract.Exists(0, amazon.caas.payments.Length, i => amazon.caas.payments[i].orderID == req_finish.orderID && amazon.caas.payments[i].gross == GlobalState.tstore.orders[req_finish.orderID].gross && amazon.caas.payments[i].payee == GlobalState.tstore.myDomain && amazon.caas.payments[i].status == CaasReturnStatus.Sucess )); }
static void Main() { SimplePayPaymentProcessor1 merchant_sender = new SimplePayPaymentProcessor1(); CaaS amazon = new CaaS(); AmazonSimplePayReturn1 merchant_receiver = new AmazonSimplePayReturn1(); Order init_order = p.NondetOrder(); GlobalState.order = new orderRecord(); canonicalRequestResponse res_placeorder = p.NodetReqres(); canonicalRequestResponse req_pay = p.NodetReqres(); canonicalRequestResponse res_pay = p.NodetReqres(); canonicalRequestResponse req_finish = p.NodetReqres(); // Computation on merchant - place order res_placeorder = merchant_sender.PostProcessPayment(init_order); // Message: merchant -> client -> CaaS // is the msg encrypted? if so, then: req_pay = res_placeorder; GlobalState.MerchantPaymentEmail = req_pay.payee; GlobalState.order.gross = req_pay.gross; GlobalState.order.id = req_pay.orderID; // Computation on Amazon - pay res_pay = amazon.pay(req_pay); // Message: CaaS -> client -> merchant // is the msg encrypted? if so, then: req_finish = res_pay; merchant_receiver.Request = req_finish; Contract.Assume(res_pay.orderID == req_finish.orderID); GlobalState.CaaS_email_proxy = res_pay.payee; GlobalState.CaaS_gross_proxy = res_pay.gross; //we need this since boogie can't handle string concat // Computation on merchant - finish order merchant_receiver.Page_Load(null, null); Contract.Assert(GlobalState.order.id == req_finish.orderID); Contract.Assert(GlobalState.MerchantPaymentEmail == req_finish.payee); Contract.Assert(GlobalState.order.gross == req_finish.gross); Contract.Assert(GlobalState.order.status == Global.OrderStatusEnum.Paid); }