Esempio n. 1
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);
            }
        }
Esempio n. 2
0
        public SubscriptionResponse Subscribe(string mobileNumber, InputMechanisms inputMechanism, string keyword, string shortCode, int reference)
        {
            SubscriptionResponse response = new SubscriptionResponse
            {
                MobileNumber = mobileNumber,
                Service      = this.service,
                NetworkID    = CUtility.GetNetworkID(mobileNumber)
            };

            if (IsSubscribed(mobileNumber, this.service.ID))
            {
                response.Status = ServiceMessages.AlreadySubscribed;
                return(response);
            }

            response.SubscriptionID = AddSubscription(service.ID, mobileNumber, response.NetworkID, reference, shortCode, keyword);
            SendSubscribeResponse(service, response.SubscriptionID, mobileNumber, reference, CSubscriptionEngineCapsule.RequestResults.Success);

            AddSubscriptionInteraction(response.SubscriptionID, (int)inputMechanism, InteractionTypes.Subscribe);
            AddSubscriptionInteraction(response.SubscriptionID, (int)inputMechanism, InteractionTypes.Confirmation);

            PaymentWrapper.WrapperResponse paymentResponse = null;
            bool result = Execute(service.PaymentSystemClientID, service.ID, response.SubscriptionID, mobileNumber, response.NetworkID, service.BillingAmount, true, reference, out paymentResponse);

            if (!result)
            {
                response.Exception = string.Format("{0}: {1}", paymentResponse.statusDescription, paymentResponse.Exception);
                response.Status    = ServiceMessages.FailedBillings;
                return(response);
            }

            response.Status = ServiceMessages.SubscriptionActivated;

            return(response);
        }
Esempio n. 3
0
        private bool Execute(int paymentSystemClientId, int subscriptionServiceId, int subscriptionId, string mobileNumber, int mobileNetworkId, decimal amount, bool initialBilling, int reference, out PaymentWrapper.WrapperResponse response)
        {
            int transactionID = 0;
            int statusID      = 0;

            bool success = BillUser(paymentSystemClientId, subscriptionId, mobileNumber, mobileNetworkId, amount, initialBilling, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), out transactionID, out statusID, out response);

            if (success)
            {
                ExtendSubscription(subscriptionServiceId, subscriptionId, mobileNumber, mobileNetworkId, 5, reference);
            }
            else
            {
                AddBillingRetry(subscriptionId, false, amount);
                SendUpdate(this.service, subscriptionId, DateTime.MinValue, Statuses.DoesNotExist, reference, CSubscriptionEngineCapsule.RequestResults.Success, false);
            }

            return(success);
        }
Esempio n. 4
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);
        }