示例#1
0
        public int Page_Load(object sender, EventArgs e, int checkedOut_orderID)
        {
            int            tx = Convert.ToInt32(CommonHelper.QueryStringInt("tx"));
            int            witness;
            payment_record payment;

            orderRecord order;

            Dictionary <string, string> values = null;

            if ((witness = PayPalStandardPaymentProcessor1.getPDTDetails(tx, out payment)) >= 0)
            {
                string orderNumber = string.Empty;
                values.TryGetValue("custom", out orderNumber);
                Guid orderNumberGuid = Guid.Empty;

                try
                {
                    orderNumberGuid = new Guid(orderNumber);
                }
                catch { }
                //Order order = OrderManager.GetOrderByGuid(orderNumberGuid);

                //payment.orderID is essentially the custom field in PDT
                Contract.Assume(checkedOut_orderID == payment.orderID);      //this should be an assignment  "checkedOut_orderID = payment.orderID", but the support for "out parameter" is wierd
                order = GlobalState.tstore.orders[checkedOut_orderID];
                Contract.Assume(order.id == checkedOut_orderID);

                if (order != null)
                {
                    decimal total = decimal.Zero;
                    try
                    {
                        total = decimal.Parse(values["mc_gross"], new CultureInfo("en-US"));
                    }
                    catch (Exception exc)
                    {
                    }
                    if (order.gross != total)
                    {
                        Contract.Assume(false);
                    }

                    string payer_status = string.Empty;
                    values.TryGetValue("payer_status", out payer_status);
                    string payment_status = string.Empty;
                    values.TryGetValue("payment_status", out payment_status);
                    string pending_reason = string.Empty;
                    values.TryGetValue("pending_reason", out pending_reason);
                    string mc_currency = string.Empty;
                    values.TryGetValue("mc_currency", out mc_currency);
                    string txn_id = string.Empty;
                    values.TryGetValue("txn_id", out txn_id);
                    string payment_type = string.Empty;
                    values.TryGetValue("payment_type", out payment_type);
                    string payer_id = string.Empty;
                    values.TryGetValue("ayer_id", out payer_id);
                    string receiver_id = string.Empty;
                    values.TryGetValue("receiver_id", out receiver_id);
                    string invoice = string.Empty;
                    values.TryGetValue("invoice", out invoice);
                    string payment_fee = string.Empty;
                    values.TryGetValue("payment_fee", out payment_fee);

                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("Paypal PDT:");
                    sb.AppendLine("total: " + total);
                    sb.AppendLine("Payer status: " + payer_status);
                    sb.AppendLine("Payment status: " + payment_status);
                    sb.AppendLine("Pending reason: " + pending_reason);
                    sb.AppendLine("mc_currency: " + mc_currency);
                    sb.AppendLine("txn_id: " + txn_id);
                    sb.AppendLine("payment_type: " + payment_type);
                    sb.AppendLine("payer_id: " + payer_id);
                    sb.AppendLine("receiver_id: " + receiver_id);
                    sb.AppendLine("invoice: " + invoice);
                    sb.AppendLine("payment_fee: " + payment_fee);

                    OrderManager.InsertOrderNote(order.id, sb.ToString(), false, DateTime.UtcNow);
                }

                if (order.gross != payment.gross)
                {
                    Contract.Assume(false);
                }

                if (payment.status != CaasReturnStatus.Sucess)
                {
                    Contract.Assume(false);
                }
                order.status = Global.OrderStatusEnum.Paid;
            }
            else
            {
                Contract.Assume(false);
            }
            return(witness);
        }
示例#2
0
        public void Page_Load(object sender, EventArgs e)
        {
            int tx = Convert.ToInt32(CommonHelper.QueryStringInt("tx"));
            Dictionary <string, string> values = null;
            string response;
            string digest_paypal;

            if (PayPalStandardPaymentProcessor1.getPDTDetails(tx, out GlobalState.payment))
            {
                string orderNumber = string.Empty;
                values.TryGetValue("custom", out orderNumber);
                Guid orderNumberGuid = Guid.Empty;
                try
                {
                    orderNumberGuid = new Guid(orderNumber);
                }
                catch { }
                Order order = OrderManager.GetOrderByGuid(orderNumberGuid);
                if (order != null)
                {
                    decimal total = decimal.Zero;
                    try
                    {
                        total = decimal.Parse(values["mc_gross"], new CultureInfo("en-US"));
                    }
                    catch (Exception exc)
                    {
                    }
                    if (order.OrderTotal != total)
                    {
                        Contract.Assume(false);
                    }

                    string payer_status = string.Empty;
                    values.TryGetValue("payer_status", out payer_status);
                    string payment_status = string.Empty;
                    values.TryGetValue("payment_status", out payment_status);
                    string pending_reason = string.Empty;
                    values.TryGetValue("pending_reason", out pending_reason);
                    string mc_currency = string.Empty;
                    values.TryGetValue("mc_currency", out mc_currency);
                    string txn_id = string.Empty;
                    values.TryGetValue("txn_id", out txn_id);
                    string payment_type = string.Empty;
                    values.TryGetValue("payment_type", out payment_type);
                    string payer_id = string.Empty;
                    values.TryGetValue("payer_id", out payer_id);
                    string receiver_id = string.Empty;
                    values.TryGetValue("receiver_id", out receiver_id);
                    string invoice = string.Empty;
                    values.TryGetValue("invoice", out invoice);
                    string payment_fee = string.Empty;
                    values.TryGetValue("payment_fee", out payment_fee);

                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("Paypal PDT:");
                    sb.AppendLine("total: " + total);
                    sb.AppendLine("Payer status: " + payer_status);
                    sb.AppendLine("Payment status: " + payment_status);
                    sb.AppendLine("Pending reason: " + pending_reason);
                    sb.AppendLine("mc_currency: " + mc_currency);
                    sb.AppendLine("txn_id: " + txn_id);
                    sb.AppendLine("payment_type: " + payment_type);
                    sb.AppendLine("payer_id: " + payer_id);
                    sb.AppendLine("receiver_id: " + receiver_id);
                    sb.AppendLine("invoice: " + invoice);
                    sb.AppendLine("payment_fee: " + payment_fee);

                    OrderManager.InsertOrderNote(order.OrderId, sb.ToString(), false, DateTime.UtcNow);
                }

                if (GlobalState.payment != null)
                {
                    if (GlobalState.order.gross != GlobalState.payment.gross)
                    {
                        Contract.Assume(false);
                    }
                    if (GlobalState.MerchantPaymentEmail != GlobalState.payment.payee)
                    {
                        Contract.Assume(false);
                    }
                    if (GlobalState.order.id == GlobalState.payment.id)
                    {
                        GlobalState.order.status = Global.OrderStatusEnum.Paid;
                    }
                    else
                    {
                        Contract.Assume(false);
                    }
                }
            }
            else
            {
                Contract.Assume(false);
            }
        }