Example #1
0
        public TelkomModels.PSWServicePaymentResponse PSWServicePaymentTelkom(ref TelkomModels.PSWServiceRequest requestParam)
        {
            string url = ConstantModels.URLINQPAY_TELKOM;

            string _requestInq = "[" + JsonConvert.SerializeObject(requestParam) + "]";
            string requestInq  = "data=" + _requestInq;

            ASCIIEncoding ascii = new ASCIIEncoding();

            byte[]         postBytes = ascii.GetBytes(requestInq);
            HttpWebRequest request;

            try
            {
                request = (HttpWebRequest)HttpWebRequest.Create(url);
            }
            catch (UriFormatException)
            {
                return(null);
            }

            request.Method        = "POST";
            request.Accept        = "application/x-www-form-urlencoded";
            request.ContentType   = "application/x-www-form-urlencoded";
            request.ContentLength = postBytes.Length;
            System.Net.ServicePointManager.Expect100Continue = false;

            // add post data to request
            Stream postStream = request.GetRequestStream();

            postStream.Write(postBytes, 0, postBytes.Length);
            postStream.Flush();
            postStream.Close();
            try
            {
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    Stream       answerStream = response.GetResponseStream();
                    StreamReader answerReader = new StreamReader(answerStream);
                    String       jsonAnswer   = answerReader.ReadToEnd();
                    TelkomModels.PSWServicePaymentResponse respond = JsonConvert.DeserializeObject <TelkomModels.PSWServicePaymentResponse>(jsonAnswer);
                    return(respond);
                }
                else
                {
                    TelkomModels.PSWServicePaymentResponse respond = new TelkomModels.PSWServicePaymentResponse();
                    respond.RC = ConstantModels.TIMEOUTCODEPAY;
                    return(respond);
                }
            }catch (Exception ex)
            {
                TelkomModels.PSWServicePaymentResponse respond = new TelkomModels.PSWServicePaymentResponse();
                respond.RC = ConstantModels.EXCEPTIONCODEPAY;
                return(respond);
            }
        }
Example #2
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);
        }