Exemple #1
0
        private void InitializePayment(Payment payment)
        {
            Payment = new PaymentWrapper(payment);
            Payment.PropertyChanged += (s, e) =>
            {
                if (HasChanges == false)
                {
                    HasChanges = _paymentRepository.HasChanges();
                }
                if (e.PropertyName == nameof(Payment.HasErrors))
                {
                    ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged();
                }

                if (e.PropertyName == nameof(Payment.Date))
                {
                    SetTitle();
                }
            };
            ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged();

            if (Payment.ID == 0)                 //if a new payment was created
            {
                Payment.PaymentPurposeID = null; //little trick to set off the validation
                Payment.RecipientID      = null; //little trick to set off the validation
            }

            SetTitle();
        }
Exemple #2
0
        public static void BillUser(int ussdCampaignID, int menuID, long ussdTransactionID, string mobileNumber, int mobileNetworkID, decimal amount)
        {
            int     paymentTCPPort = 11757;
            string  configTCPPort;
            string  paymentTCPAddress;
            string  resultMessage = string.Empty;
            decimal billAmount;

            if (utility.CommonUtility.TryGetAppSettings("PaymentSystemTCPPort", true, out configTCPPort))
            {
                if (!int.TryParse(configTCPPort, out paymentTCPPort))
                {
                    paymentTCPPort = 11757;
                }
            }

            if (!utility.CommonUtility.TryGetAppSettings("PaymentSystemTCPAddress", true, out paymentTCPAddress))
            {
                paymentTCPAddress = "192.168.1.79";
            }

            PaymentWrapper.WrapperResponse paymentResponse = null;
            PaymentWrapper payment = null;

            try
            {
                if (!utility.CommonUtility.ReturnNearestChargeCodeAmount(mobileNetworkID, 1, amount, out billAmount))
                {
                    billAmount = amount;
                }

                payment         = new PaymentWrapper("ExactUSSD", paymentTCPAddress, paymentTCPPort, "Exactmobile", "ex@ctmobil3", 266, 228);
                paymentResponse = payment.Execute(mobileNumber, mobileNetworkID, "USSD OBSBilling", "ussdmenuobsbilling", billAmount);
            }
            finally
            {
                if (payment != null)
                {
                    payment.Close();
                }
            }
            if (paymentResponse != null)
            {
                if (paymentResponse.statusID != 1)
                {
                    if (!String.IsNullOrEmpty(paymentResponse.Exception))
                    {
                        resultMessage = paymentResponse.Exception;
                    }

                    resultMessage = resultMessage + String.Format(" StatusID:{0} Transaction ID: {1} Desc: {2}", paymentResponse.statusID, paymentResponse.transactionID, paymentResponse.statusDescription);
                }
                else
                {
                    resultMessage = paymentResponse.statusDescription;
                }

                OBSBilling.AddMenuOBSBillingTransaction(ussdCampaignID, menuID, ussdTransactionID, mobileNumber, paymentResponse.transactionID, billAmount, paymentResponse.statusID, resultMessage);
            }
        }
Exemple #3
0
        private bool BillUser(int paymentSystemClientID, int subscriptionID, string mobileNumber, int mobileNetworkID, decimal amount, bool initialBilling, string startDate, out int transactionId, out int statusID, out PaymentWrapper.WrapperResponse response)
        {
            response = null;

            statusID = 0;
            bool success = false;

            transactionId = 0;

            //hack for CellC
            if (mobileNetworkID == 3)
            {
                if (amount == 4.99m)
                {
                    amount = 5m;
                }

                if (amount == 3.99m)
                {
                    amount = 4m;
                }
            }

            try
            {
                PaymentWrapper payment = new PaymentWrapper(this.ToString(), this.billingEngineAddress, this.billingEnginePort, "Exactmobile", "ex@ctmobil3", paymentSystemClientID);
                //PaymentWrapper payment = new PaymentWrapper(ConfigurationSettings.AppSettings["billingEngineAddress"],"Exactmobile", "ex@ctmobil3", paymentSystemClientID);
                //payment.EnableRetry = true;
                //payment.MaxRetry = 120; // 120 * 5000 = 600sec (10 minutes)

                response = null;

                try
                {
                    //Common.Log.InfoWrite(string.Format("{0}", "+"), ConsoleColor.Green);
                    if (startDate != null && startDate != "")
                    {
                        response = payment.Execute(mobileNumber, mobileNetworkID, "SubscriptionService", "SUB" + subscriptionID, amount, initialBilling, true, DateTime.Parse(startDate));
                    }
                    else
                    {
                        response = payment.Execute(mobileNumber, mobileNetworkID, "SubscriptionService", "SUB" + subscriptionID, amount);
                    }
                    //Common.Log.InfoWrite(string.Format("{0}", "-"), ConsoleColor.Magenta);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("ERROR sending billing request: " + ex.Message);
                }
                finally
                {
                    payment.Close();
                }

                transactionId = payment.OldTransactionID;
                statusID      = response.statusID;

                switch (response.statusID)
                {
                case 1:
                    success = true;
                    break;

                case 37:    //Invalid MSISDN
                //case 172://Subscription not valid
                //case 115:
                //    unsubscribe = true;
                //    break;
                //case 120://Subscriber locked
                //    //					case 91://Subscriber barred
                //    unsubscribe = CanUnsubScribeLockedUser(subscriptionID);
                //    break;
                default:
                    success = false;
                    break;
                }

                AddBillingRequest(subscriptionID, payment.OldTransactionID, initialBilling, response.transactionID, response.statusID, amount);
            }
            catch (Exception ex)
            {
                success = false;
            }

            return(success);
        }