Beispiel #1
0
        public void RegisterOptin(JObject data)
        {
            Exception innerEx = null;

            try
            {
                RegisterSubscriptionNotification(data);

                if (subscription_operation_status.ToUpper() == "SUBSCRIBED")
                {
                    DataSet dsData = get_subscription_data();

                    if (dsData.Tables[0].Rows.Count == 0)
                    {
                        ErrorAssignation(ERROR_CODE.Mobiera_OperatorProduct_Not_Registered,
                                         "Mobiera Operator_product not registered",
                                         string.Format("WRONG INFORMATION [operator_product_id={0}]",
                                                       JsonUtil.AsInteger(data, "subscriptionId")), data.ToString());

                        throw new Exception();
                    }

                    else
                    {
                        package_id = DataUtil.AsInteger(dsData.Tables[0].Rows[0], "package_id", false);


                        if (dsData.Tables[1].Rows.Count == 0)
                        {
                            RegisterSuscription();
                        }
                    }
                }

                else
                {
                    UpdateSubscription();
                }
            }
            catch (Exception ex)
            {
                innerEx = ex;

                if (errorCode == ERROR_CODE.OK)
                {
                    //ErrorAssignation(ERROR_CODE.GENR_Unidentified, ex.Message, ex.StackTrace, data.ToString());
                    ErrorAssignation(ERROR_CODE.Mobiera_NoDataInTable, " Faltan datos en la tabla  ", ex.StackTrace, data.ToString());
                }
            }
            finally
            {
                if (errorCode != ERROR_CODE.OK)
                {
                    Insert_Error_log();
                }
            }
        }
Beispiel #2
0
        public void RegisterNotification(JObject data)
        {
            string PROC_NOTIFY = "spu_insert_mobiera_payment_notification";

            fullDateFormat  = "yyyy-MM-dd HH:mm:ss";
            shortDateFormat = "yyyy-MM-dd HH:mm";

            JObject joAmountTransaction = JsonUtil.AsJObject(data, "amountTransaction");

            msisdn                = JsonUtil.AsString(joAmountTransaction, "endUserId", "");
            msisdn                = msisdn.Substring(8, msisdn.Length - 8);
            endUserId             = JsonUtil.AsString(joAmountTransaction, "endUserId", "");
            mandate_id            = JsonUtil.AsInteger64(joAmountTransaction, "mandateId");
            identifier_id         = JsonUtil.AsInteger64(joAmountTransaction, "identifierId");
            identifier_label      = JsonUtil.AsString(joAmountTransaction, "identifierLabel", "");
            identifier_class      = JsonUtil.AsString(joAmountTransaction, "identifierClass", "");
            service_identifier_id = JsonUtil.AsInteger(joAmountTransaction, "serviceIdentifierId");
            JObject joPaymentAmount = JsonUtil.AsJObject(joAmountTransaction, "paymentAmount");

            JObject joChargingInformation = JsonUtil.AsJObject(joPaymentAmount, "chargingInformation");

            amount               = JsonUtil.AsDouble(joChargingInformation, "amount");
            currency             = JsonUtil.AsString(joChargingInformation, "currency", "");
            charging_description = JsonUtil.AsString(joChargingInformation, "description", "");

            total_amount_charged = JsonUtil.AsDouble(joPaymentAmount, "totalAmountCharged");
            JObject joCchargingMetaData = JsonUtil.AsJObject(joPaymentAmount, "chargingMetaData");

            channel        = JsonUtil.AsString(joCchargingMetaData, "channel", "");
            tax_amount     = JsonUtil.AsDouble(joCchargingMetaData, "taxAmount");
            charging_event = JsonUtil.AsString(joCchargingMetaData, "chargingEvent", "");

            server_reference_code        = JsonUtil.AsInteger64(joAmountTransaction, "serverReferenceCode");
            resource_url                 = JsonUtil.AsString(joAmountTransaction, "resourceURL", "");
            transaction_operation_status = JsonUtil.AsString(joAmountTransaction, "transactionOperationStatus", "");
            charging_service_exception   = JsonUtil.AsString(joAmountTransaction, "chargingServiceException", "");
            charging_policy_exception    = JsonUtil.AsString(joAmountTransaction, "chargingPolicyException", "");



            try
            {
                SqlParameter[] parameters = new SqlParameter[21];

                parameters[0]           = new SqlParameter("@mobiera_payment_notification_id", DbType.Int64);
                parameters[0].Direction = ParameterDirection.Output;
                parameters[1]           = new SqlParameter("@endUserId", DbType.String);
                parameters[1].Value     = endUserId;
                parameters[2]           = new SqlParameter("@msisdn", DbType.String);
                parameters[2].Value     = msisdn;
                parameters[3]           = new SqlParameter("@mandate_id", DbType.Int64);
                parameters[3].Value     = mandate_id;
                parameters[4]           = new SqlParameter("@identifier_id", DbType.Int64);
                parameters[4].Value     = identifier_id;
                parameters[5]           = new SqlParameter("@identifier_label", DbType.String);
                parameters[5].Value     = identifier_label;
                parameters[6]           = new SqlParameter("@identifier_class", DbType.String);
                parameters[6].Value     = identifier_class;
                parameters[7]           = new SqlParameter("@service_identifier_id", DbType.Int32);
                parameters[7].Value     = service_identifier_id;
                parameters[8]           = new SqlParameter("@amount", DbType.Decimal);
                parameters[8].Value     = amount;
                parameters[9]           = new SqlParameter("@currency", DbType.String);
                parameters[9].Value     = currency;
                parameters[10]          = new SqlParameter("@charging_description", DbType.String);
                parameters[10].Value    = charging_description;
                parameters[11]          = new SqlParameter("@total_amount_charged", DbType.Decimal);
                parameters[11].Value    = total_amount_charged;
                parameters[12]          = new SqlParameter("@channel", DbType.String);
                parameters[12].Value    = channel;
                parameters[13]          = new SqlParameter("@tax_amount", DbType.Decimal);
                parameters[13].Value    = tax_amount;
                parameters[14]          = new SqlParameter("@charging_event", DbType.String);
                parameters[14].Value    = charging_event;
                parameters[15]          = new SqlParameter("@server_reference_code", DbType.Int64);
                parameters[15].Value    = server_reference_code;
                parameters[16]          = new SqlParameter("@resource_url", DbType.String);
                parameters[16].Value    = resource_url;
                parameters[17]          = new SqlParameter("@transaction_operation_status", DbType.String);
                parameters[17].Value    = transaction_operation_status;
                parameters[18]          = new SqlParameter("@created_by", DbType.Int32);
                parameters[18].Value    = 1;
                parameters[19]          = new SqlParameter("@charging_service_exception", DbType.String);
                parameters[19].Value    = charging_service_exception;
                parameters[20]          = new SqlParameter("@charging_policy_exception", DbType.String);
                parameters[20].Value    = charging_policy_exception;

                ExecuteNonQuery(InstanceName, CommandType.StoredProcedure, PROC_NOTIFY, parameters);
                mobiera_payment_notification_id = DataUtil.AsInteger64(parameters[0].Value, false);
            }
            catch (Exception ex)
            {
                ErrorAssignation(ERROR_CODE.GENR_NewIDNotGenerated, ex.Message, ex.StackTrace, url);

                throw ex;
            }

            finally
            {
                if (errorCode != ERROR_CODE.OK)
                {
                    Insert_Error_log();
                }
            }

            //return mobiera_payment_notification_id;
        }