示例#1
0
        public TelkomModels.TelkomPaymentResponse PaymentTelkom(ref TelkomModels.TelkomPaymentRequest AutoPayRequest, string ip)
        {
            string wsStartTime = DateTime.Now.ToString(ConstantModels.FORMATDATETIME);
            string wsEndTime   = "";

            TelkomHelper telkomHelper = new TelkomHelper();

            TelkomModels.PSWServiceRequest         PswRequest      = new TelkomModels.PSWServiceRequest();
            TelkomModels.TelkomPaymentResponse     AutoPayResponse = new TelkomModels.TelkomPaymentResponse();
            TelkomModels.PSWServicePaymentResponse GetPayResponse  = new TelkomModels.PSWServicePaymentResponse();

            string decodeBillingCode = helper.Base64Decode(AutoPayRequest.billingCode);

            if (decodeBillingCode == "")
            {
                AutoPayResponse.responseCode        = "0210";
                AutoPayResponse.responseDescription = ResponseCodeModels.GetResponseDescription(AutoPayResponse.responseCode);
            }
            else
            {
                string[] splitBillingCode = decodeBillingCode.Split('~');
                string[] splitData1PSW    = ((splitBillingCode[0]).Replace("||", "~")).Split('~');

                Random random = new Random();
                PswRequest.SubProduct  = ConstantModels.SubProductPAY_Telkom;
                PswRequest.SequenceTrx = DateTime.Now.ToString("HHmmssfff") + random.Next(0, 9).ToString();
                PswRequest.TotalAmount = AutoPayRequest.totalAmount;
                PswRequest.AddAmount1  = splitData1PSW[1];
                PswRequest.AddAmount2  = splitData1PSW[2];
                PswRequest.AddAmount3  = splitData1PSW[3];
                PswRequest.InputData   = AutoPayRequest.billingNumber;
                PswRequest.Data1       = helper.GetSourceAccount(AutoPayRequest.institutionCode, ConstantModels.FeatureCode_Telkom);
                PswRequest.Data2       = splitData1PSW[0];
                PswRequest.Data3       = splitBillingCode[1];

                GetPayResponse = PSWServicePaymentTelkom(ref PswRequest);
                wsEndTime      = DateTime.Now.ToString(ConstantModels.FORMATDATETIME);

                if (GetPayResponse == null)
                {
                    AutoPayResponse.responseCode        = ConstantModels.TIMEOUTCODEPAY;
                    AutoPayResponse.responseDescription = ResponseCodeModels.GetResponseDescription(ConstantModels.TIMEOUTCODEPAY);
                }
                else if (GetPayResponse.RC == "00") //success
                {
                    AutoPayResponse.responseCode        = ConstantModels.SUCCESSCODEPAY;
                    AutoPayResponse.responseDescription = ResponseCodeModels.GetResponseDescription(ConstantModels.SUCCESSCODEPAY);
                    AutoPayResponse.data.billingNumber  = AutoPayRequest.billingNumber;
                    AutoPayResponse.data.reference      = AutoPayRequest.reference;
                    AutoPayResponse.data.journalSeq     = GetPayResponse.JurnalSeq.Trim();
                }
                else if (GetPayResponse.RC == ConstantModels.TIMEOUTCODEPAY) //timeout
                {
                    AutoPayResponse.responseCode        = ConstantModels.TIMEOUTCODEPAY;
                    AutoPayResponse.responseDescription = ResponseCodeModels.GetResponseDescription(GetPayResponse.RC);
                }
                else if (GetPayResponse.RC == ConstantModels.EXCEPTIONCODEPAY) //exception
                {
                    AutoPayResponse.responseCode        = ConstantModels.EXCEPTIONCODEPAY;
                    AutoPayResponse.responseDescription = ResponseCodeModels.GetResponseDescription(GetPayResponse.RC);
                }
                else //fail
                {
                    AutoPayResponse.responseCode        = ResponseCodeModels.GetResponseCodePSW(GetPayResponse.RC);
                    AutoPayResponse.responseDescription = ResponseCodeModels.GetResponseDescription(AutoPayResponse.responseCode);

                    //kondisi suspend kredit dari psw
                    if (GetPayResponse.RC == "Q4" || GetPayResponse.RC == "68" || GetPayResponse.RC == "82")
                    {
                        AutoPayResponse.data.billingNumber = AutoPayRequest.billingNumber;
                        AutoPayResponse.data.reference     = AutoPayRequest.reference;
                        AutoPayResponse.data.journalSeq    = GetPayResponse.JurnalSeq.Trim();
                    }
                }
            }

            //insert ke tabel TELKOMTRANSACTION
            telkomHelper.InsertTelkomTransaction(AutoPayRequest, PswRequest, AutoPayResponse, wsStartTime, wsEndTime, ip, (GetPayResponse == null ? "" : GetPayResponse.RC));
            return(AutoPayResponse);
        }
示例#2
0
        public void InsertTelkomTransaction(TelkomModels.TelkomPaymentRequest PayRequest, TelkomModels.PSWServiceRequest PswRequest, TelkomModels.TelkomPaymentResponse PayResponse, string wsStartTime, string wsEndTime, string ip, string rc_psw)
        {
            //string transDate = DateTime.Parse(PayRequest.TransactionDate).ToString("dd-MM-yyyy");
            string errorMsg = "";

            if (PayResponse.responseCode != "0200")
            {
                errorMsg = "";
            }

            string sql = "INSERT INTO TELKOMTRANSACTION ([CREATEDTIME],[WS_STARTTIME],[WS_ENDTIME],[INSTITUTION_CODE],[SEQUENCE_TRX],[TOTAL_AMOUNT],[FIRST_BILL]" +
                         ",[SECOND_BILL],[THIRD_BILL],[BILLING_NUMBER],[SOURCE_ACCOUNT],[NAME],[BILLING_CODE],[ENCODE_DATA],[TRANSACTION_DATE],[TRANSACTION_TIME],[RC],[RC_DESC]" +
                         ",[ERRMSG],[JURNALSEQ],[IP_ADDRESS],[NOMOR_REFF]) " +
                         "VALUES (@createdTime, @wsStartTime, @wsEndTime, @institutionCode, @sequenceTrx, @totalAmount, @firstBill, @secondBill, @thirdBill, " +
                         "@billingNumber, @sourceAccount, @name, @billingCode, @encodeData, @transactionDate, @transactionTime, @rc, @rcDesc, @errmsg, @jurnalSeq," +
                         "@ip, @nomorReff)";

            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.CommandType = CommandType.Text;
            sqlCommand.CommandText = sql;
            sqlCommand.Parameters.Add("@createdTime", SqlDbType.VarChar).Value     = DateTime.Now.ToString(ConstantModels.FORMATDATETIME);
            sqlCommand.Parameters.Add("@wsStartTime", SqlDbType.VarChar).Value     = wsStartTime;
            sqlCommand.Parameters.Add("@wsEndTime", SqlDbType.VarChar).Value       = wsEndTime;
            sqlCommand.Parameters.Add("@institutionCode", SqlDbType.VarChar).Value = PayRequest.institutionCode;
            sqlCommand.Parameters.Add("@sequenceTrx", SqlDbType.VarChar).Value     = PswRequest.SequenceTrx;
            sqlCommand.Parameters.Add("@totalAmount", SqlDbType.Decimal).Value     = Convert.ToDecimal(PayRequest.totalAmount);
            sqlCommand.Parameters.Add("@firstBill", SqlDbType.VarChar).Value       = PswRequest.AddAmount1;
            sqlCommand.Parameters.Add("@secondBill", SqlDbType.VarChar).Value      = PswRequest.AddAmount2;
            sqlCommand.Parameters.Add("@thirdBill", SqlDbType.VarChar).Value       = PswRequest.AddAmount3;
            sqlCommand.Parameters.Add("@billingNumber", SqlDbType.VarChar).Value   = PayRequest.billingNumber;
            sqlCommand.Parameters.Add("@sourceAccount", SqlDbType.VarChar).Value   = PswRequest.Data1;
            sqlCommand.Parameters.Add("@name", SqlDbType.VarChar).Value            = PswRequest.Data2;
            sqlCommand.Parameters.Add("@billingCode", SqlDbType.VarChar).Value     = PswRequest.Data3;
            sqlCommand.Parameters.Add("@encodeData", SqlDbType.VarChar).Value      = PayRequest.billingCode;
            sqlCommand.Parameters.Add("@transactionDate", SqlDbType.VarChar).Value = PswRequest.Transdate;
            sqlCommand.Parameters.Add("@transactionTime", SqlDbType.VarChar).Value = PswRequest.Transtime;
            sqlCommand.Parameters.Add("@rc", SqlDbType.VarChar).Value        = PayResponse.responseCode;
            sqlCommand.Parameters.Add("@rcDesc", SqlDbType.VarChar).Value    = PayResponse.responseDescription;
            sqlCommand.Parameters.Add("@errmsg", SqlDbType.VarChar).Value    = errorMsg;
            sqlCommand.Parameters.Add("@jurnalSeq", SqlDbType.VarChar).Value = PayResponse.data.journalSeq;
            sqlCommand.Parameters.Add("@ip", SqlDbType.VarChar).Value        = ip;
            sqlCommand.Parameters.Add("@nomorReff", SqlDbType.VarChar).Value = PayRequest.reference;
            util.ExecuteSqlCommand(sqlCommand);
        }