コード例 #1
0
        public VerifyStatusStruct verify([FromBody] VerifyStruct obj)
        {
            PaymentSelect select = new PaymentSelect(Configuration, _hostingEnvironment);

            return(select.Verify(obj));
        }
コード例 #2
0
        public ActionResult <ResponseStruct <WithdrawService> > GetWithdrawServices()
        {
            PaymentSelect select = new PaymentSelect(Configuration, _hostingEnvironment);

            return(select.GetWithdrawServices());
        }
コード例 #3
0
        public Status WithdrawFunds(long mobile, string pass, long account, long serviceID, long amount)
        {
            Status status = new Status();

            try
            {
                //(amount / 100) % 1 == 0
                if (amount > 100)
                {
                    PaymentSelect pSelect           = new PaymentSelect(Configuration, _hostingEnvironment);
                    long          smartpayServiceID = pSelect.GetSmartpayServiceID(serviceID);
                    if (smartpayServiceID > 0)
                    {
                        DbSelect select = new DbSelect(Configuration, _hostingEnvironment);
                        long     userID = select.getUserIdByMobile(mobile, pass);


                        if (userID > 0)
                        {
                            decimal earningValue = pSelect.GetUserEarningValue(userID);
                            if (earningValue > amount / 100)
                            {
                                if (account.ToString().Length == 9)
                                {
                                    PaymentInsert pInsert   = new PaymentInsert(Configuration, _hostingEnvironment);
                                    long          paymentID = pInsert.InsertTransaction(userID, serviceID, amount, account);
                                    if (paymentID > 0)
                                    {
                                        DateTime now = DateTime.Now;



                                        string smsXML = @$ "<request point=" "3587" ">
<payment account = " "{account}" " check = " "24776" " date = " "{DateTime.Now.ToString(" yyyy - MM - ddTHH : mm : sszz00 ")}" "
id = " "{paymentID}" " service = " "{smartpayServiceID}" " source = " "CASH" " sum = " "{amount}" "> <attribute name = " "id2" " value = " "pack" "/>
            
                </payment>
            </request>";
                                        KeyManager.SetKeyPath($"{_hostingEnvironment.ContentRootPath}/wwwroot/private.pem");
                                        string certificate = KeyManager.GenerateSignature(smsXML, Encoding.UTF8);
                                        var    smsContent  = new StringContent(smsXML, Encoding.UTF8, "text/xml");
                                        //smsContent.Headers.ContentType = MediaTypeHeaderValue.Parse("text/xml");

                                        string     smsUrl    = $"https://smartpay.az/external/extended";
                                        HttpClient smsClient = new HttpClient();
                                        smsClient.DefaultRequestHeaders.Add("paylogic-signature", certificate);

                                        var smsRslt = smsClient.PostAsync(smsUrl, smsContent).Result;
                                        var smsResp = smsRslt.Content.ReadAsStringAsync().Result;

                                        XmlDocument xmlDoc = new XmlDocument();
                                        xmlDoc.LoadXml(smsResp);
                                        XmlNodeList parentNode = xmlDoc.GetElementsByTagName("result");
                                        if (parentNode.Count > 0)
                                        {
                                            foreach (XmlNode childrenNode in parentNode)
                                            {
                                                int state    = Convert.ToInt32(childrenNode.Attributes["state"].Value);
                                                int substate = Convert.ToInt32(childrenNode.Attributes["substate"].Value);
                                                int final    = Convert.ToInt32(childrenNode.Attributes["final"].Value);
                                                if (state == 60 && substate == 0 && final == 1)
                                                {
                                                    pInsert.UpdateTransaction(paymentID, state, substate, final);
                                                    pInsert.WithdrawUserBalance(userID, amount);
                                                    status.response = 1; //ugurlu
                                                                         //Debug.WriteLine("");
                                                }
                                                else if (state == 0 || state == 30 || state == 40 || state == 70)
                                                {
                                                    pInsert.UpdateTransaction(paymentID, state, substate, final);
                                                    StartCheckRequestTimer(paymentID, userID, amount);
                                                    status.response = 2;//gozlemededi
                                                }
                                                else
                                                {
                                                    pInsert.UpdateTransaction(paymentID, state, substate, final);
                                                    status.response = 3;//odenish xetasi
                                                }
                                            }
                                        }
                                        else
                                        {
                                            status.response       = 4; // signature and etc
                                            status.responseString = "Error";
                                        }
                                    }
                                    else
                                    {
                                        status.response       = 4; // error
                                        status.responseString = "Error";
                                    }
                                }
                                else
                                {
                                    status.response       = 5;//wrong payNumber
                                    status.responseString = "check account";
                                }
                            }

                            else
                            {
                                status.response       = 6;//access danied
                                status.responseString = "not enough earning balance";
                            }
                        }
                        else
                        {
                            status.response       = 7;//access danied
                            status.responseString = "access danied";
                        }
                    }
                    else
                    {
                        status.response       = 8; // service not found
                        status.responseString = "Service not found";
                    }
                }
                else
                {
                    status.response       = 9; // service not found
                    status.responseString = "wrong amount";
                }
            }
            catch (Exception ex)
            {
                status.response       = 4; // error
                status.responseString = $"Internal error: {ex.Message}";
            }
            return(status);
        }