Пример #1
0
        private void reversePayment()
        {
            checkCredentials();

            try
            {
                var reverseContext = new ReversePaymentContext();
                dlgReverse.SetContextValues(reverseContext);
                reverseContext.ReceiptEmail = edt_Email.Text;
                reverseContext.ReceiptPhone = edt_Phone.Text;
                reverseContext.ExtID        = ExtID;

                if (cb_Purchases.Checked)
                {
                    List <Purchase> purchases = dlgPurchases.Purchases;

                    if (purchases == null)
                    {
                        MessageBox.Show("Couldn't parse purchases!");
                    }
                    else
                    {
                        foreach (Purchase p in purchases)
                        {
                            reverseContext.PutPurchase(p);
                        }
                    }
                }

                if (cb_Tags.Checked)
                {
                    var tags = dlgTags.Tags;

                    if (tags == null)
                    {
                        MessageBox.Show("Couldn't parse tags!");
                    }
                    else
                    {
                        foreach (var tag in tags)
                        {
                            reverseContext.PutInvoiceTag(tag.Key, tag.Value);
                        }
                    }
                }

                m_PaymentController.StartReverse(reverseContext);
                log(DIVIDER);
                log(string.Format("{0} PAYMENT : {1}{2}", reverseContext.Mode == ReverseMode.Cancel ? "CANCEL" : "RETURN", Environment.NewLine, reverseContext.TransactionID));
            }
            catch (InvalidOperationException e)
            {
                log(string.Format("ERROR : {0}", e.Message));
                return;
            }
        }
Пример #2
0
        public void SetContextValues(ReversePaymentContext reverseContext)
        {
            string      trID            = edt_ReverseID.Text;
            ReverseMode mode            = rb_Cancel.Checked ? ReverseMode.Cancel : ReverseMode.Return;
            decimal?    amountToReverse = string.IsNullOrEmpty(edt_ReverseAmount.Text) ? null : (decimal?)decimal.Parse(edt_ReverseAmount.Text);

            reverseContext.TransactionID   = trID;
            reverseContext.Mode            = mode;
            reverseContext.AmountToReverse = amountToReverse;
        }