示例#1
0
        public static bool CreateTransfer(int transactionId, Classes.Instbtc.Models.TransactionModel transaction)
        {
            string  result     = "";
            decimal btc_amount = decimal.Parse(Classes.Instbtc.Utilities.Conversion.GetBTCAmountWithInterest(transaction.Exchange_Amount.ToString(), transaction.Exchange_Currency, out decimal deduction));

            using (var con = Classes.DB.InstBTCDB("instbtc"))
            {
                string insertTransferQuery = " INSERT INTO transfer(id,btc_amount,service_fee_btc_amount,created_date) ";
                insertTransferQuery += $"VALUES(default,{btc_amount},{deduction}, '{DateTime.UtcNow.ToString()}') returning id;";

                try
                {
                    result = Classes.DB.Insert(con, insertTransferQuery, out int?transferId);
                    if (result == "Success")
                    {
                        string insertTransferTransactionQuery = " INSERT INTO transfer_transaction(id,transfer_id,transaction_id) ";
                        insertTransferTransactionQuery += $"VALUES(default,{transferId},{transactionId}) returning id;";
                        result = Classes.DB.Insert(con, insertTransferTransactionQuery, out int?ttid);
                    }
                }
                catch (Exception ex)
                {
                    result = ex.Message.ToString();
                }
            }

            return(result == "Success");
        }
示例#2
0
        private static object InsertTransaction(NpgsqlConnection conn, string id)
        {
            WithdrawalModel.MWithdrawal withdrawal = new WithdrawalModel.MWithdrawal();
            withdrawal = GetWithdrawal(conn, id);
            Classes.Instbtc.Models.TransactionModel transaction = new Classes.Instbtc.Models.TransactionModel();

            if (withdrawal.transaction_currency == "BTC")
            {
                #region Build Transaction Object BTC Wds
                transaction = new Classes.Instbtc.Models.TransactionModel()
                {
                    Psp_ID            = 2,
                    Deposit_Currency  = "USD",
                    Deposit_Amount    = (decimal)withdrawal.UsdConversion * -1,
                    Exchange_Currency = "BTC",
                    Exchange_Amount   = withdrawal.Amount * -1,
                    Created_Date      = DateTime.UtcNow,
                    Client_ID         = withdrawal.UserId,
                    Psp_Status        = "Approved",
                    Credited_Status   = "Credited",
                    type = Classes.Instbtc.Models.TransactionType.WITHDRAWAL,
                    Transaction_Currency = withdrawal.transaction_currency
                };
                #endregion
            }

            else if (withdrawal.transaction_currency == "EUR")
            {
                #region Build Transaction Object EUR Wds
                transaction = new Classes.Instbtc.Models.TransactionModel()
                {
                    Psp_ID            = 2,
                    Deposit_Currency  = "EUR",
                    Deposit_Amount    = withdrawal.Amount * -1,
                    Exchange_Currency = "EUR",
                    Exchange_Amount   = withdrawal.Amount * -1,
                    Created_Date      = DateTime.UtcNow,
                    Client_ID         = withdrawal.UserId,
                    Psp_Status        = "Approved",
                    Credited_Status   = "Credited",
                    type = Classes.Instbtc.Models.TransactionType.WITHDRAWAL,
                    Transaction_Currency = withdrawal.transaction_currency
                };
                #endregion
            }

            object res;
            res = Classes.Instbtc.Create.Transactions.CreateTransaction(transaction);
            return(res);
        }
示例#3
0
        public static string PushToBrand(Models.ClientModel Info, Classes.Instbtc.Models.TransactionModel Transaction, string PspStatus, object result, string note, string pin, string psp_name)
        {
            if (result.ToString() != "Internal Error" || result != null)
            {
                decimal OriginalDepositTransactionAmount = decimal.Parse(Transaction.Deposit_Amount.ToString());
                decimal OriginalBtcExchangeAmount        = decimal.Parse(Transaction.Exchange_Amount.ToString());

                decimal DepositAmountDeductionFee     = 0;
                decimal BTCExchangeAmountDeductionFee = 0;


                if (psp_name.ToLower() == "wire transfer")
                {
                    Transaction.Psp_ID = 1;
                }

                #region Get Right Deduction Fee
                if (Transaction.Psp_ID == 1)
                {
                    DepositAmountDeductionFee     = (OriginalDepositTransactionAmount * Convert.ToDecimal(0.025));
                    BTCExchangeAmountDeductionFee = (OriginalBtcExchangeAmount * Convert.ToDecimal(0.025));
                }
                else
                {
                    DepositAmountDeductionFee     = (OriginalDepositTransactionAmount * Convert.ToDecimal(0.05));
                    BTCExchangeAmountDeductionFee = (OriginalBtcExchangeAmount * Convert.ToDecimal(0.05));
                }
                #endregion

                decimal FinalDepositAmountToSend = (OriginalDepositTransactionAmount - DepositAmountDeductionFee);
                decimal FinalBTCAmountToSend     = (OriginalBtcExchangeAmount - BTCExchangeAmountDeductionFee);

                #region If not Approved Send Api Request to Brand to record tx
                if (PspStatus.ToLower() != "approved")
                {
                    var s = BrandMakeDeposit(Info.Referral, Info.Email, PspStatus, FinalDepositAmountToSend.ToString(), Transaction.Deposit_Currency, Transaction.PaymentReference, Transaction.CardHolderName, Transaction.CardLast4, "", note, pin, DepositAmountDeductionFee, psp_name);
                }
                #endregion

                #region If Approved Continue the Process
                if (PspStatus.ToLower() == "approved")
                {
                    string btcReff = "";

                    #region Make the BTC transfer
                    var res = Classes.btcWallet.Utilitties.createSelfTransaction(double.Parse(FinalBTCAmountToSend.ToString()), "http://54.200.165.82:4000/");

                    #region Funds were transfered
                    if (res.error == null)
                    {
                        btcReff = res.txResponse.hash;
                    }
                    #endregion

                    #region No funds
                    else if (res.error != null)
                    {
                        Email.SendNoFundsNotification(Transaction.Client_ID.ToString(), res.error.message);
                    }
                    #endregion

                    #region if tx unconfirmed error persist
                    if (res.error != null)
                    {
                        if (res.error.message.ToLower() == "tx exceeds maximum unconfirmed ancestors.")
                        {
                            #region do ZAP call
                            JavaScriptSerializer ser = new JavaScriptSerializer();
                            var client  = new RestClient("http://54.200.165.82:4000/zap");
                            var request = new RestRequest(Method.POST);
                            request.AddHeader("cache-control", "no-cache");
                            request.AddHeader("content-type", "application/x-www-form-urlencoded");
                            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11;
                            IRestResponse response = client.Execute(request);

                            var dss = ser.Deserialize <dynamic>(response.Content.ToString());
                            if (dss != null)
                            {
                                var s = dss.TryGetValue("success", out dynamic sc) ? sc : null;
                                if ((bool)s)
                                {
                                    res = Classes.btcWallet.Utilitties.createSelfTransaction(double.Parse(FinalBTCAmountToSend.ToString()), "http://54.200.165.82:4000/");
                                    if (res.error == null)
                                    {
                                        btcReff = res.txResponse.hash;
                                    }
                                }
                                else
                                {
                                    btcReff = res.txResponse.hash = "N/A";
                                }
                            }
                            #endregion
                        }
                    }
                    #endregion

                    #endregion
                    if (Transaction.Psp_ID != 1)
                    {
                        EmailTemplateUtilities.SendNotificationDeposit(Info.Id.ToString(), FinalDepositAmountToSend.ToString(), FinalBTCAmountToSend.ToString(), Transaction);
                    }

                    #region Create Withdrawal Object
                    WithdrawalModel.MWithdrawal WithdrawalModel = new WithdrawalModel.MWithdrawal
                    {
                        UserId               = Info.Id,
                        WalletId             = "Not Applicable",
                        ClientName           = string.Concat(Info.First_name, " ", Info.Last_name),
                        DocumentId           = "Not Applicable",
                        DocuLink             = "Not Applicable",
                        Amount               = Transaction.Exchange_Amount,
                        Status               = "Initial",
                        DocumentStatus       = CRM.Models.WithdrawalModel.DocumentStatus.OUT_FOR_SIGNATURE,
                        CreatedDate          = DateTime.UtcNow,
                        UsdConversion        = 0,
                        ServiceFeeUsd        = 0,
                        ServiceFee           = BTCExchangeAmountDeductionFee,
                        refference_hash      = btcReff,
                        transaction_currency = "BTC"
                    };
                    #endregion

                    #region Create Initial Wd Request
                    var wd_id = CreateWdRequestReturningId(WithdrawalModel);
                    #endregion

                    if (!string.IsNullOrEmpty(wd_id.ToString()))
                    {
                        using (var conn = Classes.DB.InstBTCDB("instbtc"))
                        {
                            bool updateResult = UpdateCreditedStatus(conn, wd_id.ToString(), PspStatus);
                            if (updateResult)
                            {
                                UpdateUsdValueAmount(conn, wd_id.ToString());
                                var withdrawalData = GetWithdrawal(conn, wd_id.ToString());
                                if (withdrawalData.TransactionId == -1 && withdrawalData.Status == "Approved")
                                {
                                    var wd_result = InsertTransaction(conn, wd_id.ToString());

                                    if (wd_result.ToString() != "Internal Error" && !string.IsNullOrEmpty(wd_result.ToString()))
                                    {
                                        var updateWithdrawalTransaction = UpdateTransactionId(conn, wd_id.ToString(), Convert.ToInt32(wd_result));

                                        if (updateWithdrawalTransaction)
                                        {
                                            var brand_deposit_res = BrandMakeDeposit(Info.Referral, Info.Email, PspStatus, FinalDepositAmountToSend.ToString(), Transaction.Deposit_Currency, Transaction.PaymentReference, Transaction.CardHolderName, Transaction.CardLast4, "", string.Concat("[Refference:", btcReff, "] [Service Fee: ", DepositAmountDeductionFee, "] ", note), pin, DepositAmountDeductionFee, psp_name);
                                        }
                                        else
                                        {
                                            //logs issues
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                #endregion
            }
            return("Success");
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string            username      = Classes.Cookie.GetCookie("ggZurkVKwLIM+SQ2NMcfsra8/nnrhm9u5sl4TMYTE2Y", false);
            var               roles         = Utilities.AccountUtilities.getUserRoles(username);
            RoleUtilities     roleUtilities = new RoleUtilities();
            List <RolesModel> rolesModels   = new List <RolesModel>();
            List <string>     roleLists     = roles.Split(',').ToList();

            if (roleLists.Find(f => f.ToLower() == "12") == null)
            {
                Response.Redirect("/dashboard.aspx");
            }



            if (Request.HttpMethod == "POST")
            {
                #region Assign Post Variables
                string ClientId          = Request.Form["clientId"];
                string PaymentReferrence = Request.Form["pspRef"];
                string PaymentStatus     = Request.Form["pspStatus"];
                string CreditedStatus    = Request.Form["creditedStatus"];
                string PspId             = Request.Form["ctl00$ctl00$MainContent$LMainContent$pspId"];
                string Amount            = Request.Form["amount"];
                string Currency          = Request.Form["currency"];
                string Note             = Request.Form["note"];
                string CardLast4        = Request.Form["cardLast4"];
                string CardExpiry       = Request.Form["cardExpiry"];
                string CardHolderName   = Request.Form["cardHolder"];
                string TradingAccountId = Request.Form["PIN"];
                #endregion

                string PIN = !string.IsNullOrEmpty(TradingAccountId) ? TradingAccountId : string.Empty;

                #region Get Client Info
                ClientModel Info = new ClientModel();
                using (NpgsqlConnection conn = Classes.DB.InstBTCDB("instbtc"))
                {
                    Info = Clients.FindById(conn, int.Parse(ClientId));
                }
                #endregion

                if (Info != null)
                {
                    #region Creating the Transaction Object
                    Classes.Instbtc.Models.TransactionModel Transaction = new Classes.Instbtc.Models.TransactionModel
                    {
                        Psp_ID            = decimal.Parse(PspId),
                        Deposit_Currency  = Currency,
                        Deposit_Amount    = Convert.ToDecimal(Amount),
                        Exchange_Currency = "BTC",
                        Exchange_Amount   = Convert.ToDecimal(Classes.Instbtc.Utilities.Conversion.GetBTCAmountRestSharp(Amount, Currency)),
                        Created_Date      = DateTime.UtcNow,
                        Client_ID         = Convert.ToDecimal(ClientId),
                        Psp_Status        = PaymentStatus,
                        Credited_Status   = CreditedStatus,
                        PaymentReference  = PaymentReferrence,
                        Notes             = Note,
                        type                 = Classes.Instbtc.Models.TransactionType.DEPOSIT,
                        CardLast4            = !string.IsNullOrEmpty(CardLast4) ? CardLast4 : "",
                        CardHolderName       = !string.IsNullOrEmpty(CardHolderName) ? CardHolderName : "",
                        Transaction_Currency = "BTC"
                    };
                    #endregion

                    #region Create The Transaction
                    var    TransactionCheck = Utilities.Transactions.CheckTransactionIfExist(Transaction.PaymentReference);
                    object result           = new object();
                    if (string.IsNullOrEmpty(TransactionCheck))
                    {
                        result = Classes.Instbtc.Create.Transactions.CreateTransaction(Transaction);
                    }
                    else
                    {
                        toastrUtilities.SessionPush("toast", new KeyValuePair <string, string>("error", $"Cant Create Transaction, Existing Detected!"));
                        Response.Redirect("/transaction-lists.aspx");
                    }

                    #endregion

                    if (result.ToString() != "Internal Error" || result != null)
                    {
                        decimal OriginalDepositTransactionAmount = decimal.Parse(Transaction.Deposit_Amount.ToString());
                        decimal OriginalBtcExchangeAmount        = decimal.Parse(Transaction.Exchange_Amount.ToString());

                        EmailTemplateUtilities.SendNotificationDeposit(Info.Id.ToString(), OriginalDepositTransactionAmount.ToString(), OriginalBtcExchangeAmount.ToString(), Transaction);

                        //if (Info.Referral.ToLower() == "lblv" || Info.Referral.ToLower() == "tradershome" || Info.Referral.ToLower() == "profitix" || Info.Referral.ToLower() == "vlom" || Info.Referral.ToLower() == "uptos" || Info.Referral.ToLower() == "fundiza" || Info.Referral.ToLower() == "kiplar" || Info.Referral.ToLower() == "investigram" || Info.Referral.ToLower() == "commercewealth")
                        //{
                        //    try
                        //    {
                        //        var pspList = PspUtilities.GetPspById(Transaction.Psp_ID.ToString());
                        //        var pspName = pspList.Where(w => w.Id == int.Parse(Transaction.Psp_ID.ToString()))?.FirstOrDefault()?.Name;
                        //        pspName = pspName.Replace("USD ", "").Replace("EUR ", "").Replace("AUD ", "");
                        //        var res = BrandsIntegration.PushToBrand(Info, Transaction, PaymentStatus, result, $"[{pspName}] " + Note, PIN, pspName);
                        //        toastrUtilities.SessionPush("toast", new KeyValuePair<string, string>("success", $"{res}"));
                        //    }
                        //    catch (Exception ex)
                        //    {
                        //        toastrUtilities.SessionPush("toast", new KeyValuePair<string, string>("error", $"{ex.Message.ToString()}"));
                        //    }
                        //}
                        //else
                        //{
                        //    decimal OriginalDepositTransactionAmount = decimal.Parse(Transaction.Deposit_Amount.ToString());
                        //    decimal OriginalBtcExchangeAmount = decimal.Parse(Transaction.Exchange_Amount.ToString());

                        //    EmailTemplateUtilities.SendNotificationDeposit(Info.Id.ToString(), OriginalDepositTransactionAmount.ToString(), OriginalBtcExchangeAmount.ToString(), Transaction);
                        //}
                    }
                    else
                    {
                        toastrUtilities.SessionPush("toast", new KeyValuePair <string, string>("error", $"An Error Occured Cant Create Transaction"));
                    }
                }
                else
                {
                    //Redirect Invalid Client Id;
                    toastrUtilities.SessionPush("toast", new KeyValuePair <string, string>("error", $"No Client With this Id: {ClientId}"));
                    Response.Redirect("/transaction-lists.aspx");
                }
            }

            OptionUtilities optionUtilities = new OptionUtilities();
            pspId.Items.AddRange(optionUtilities.GetPSPOptions());
        }
示例#5
0
        public static void SendNotificationDeposit(string UserId, string amountUsd, string amountBtc, Classes.Instbtc.Models.TransactionModel Transaction)
        {
            #region Get Client Info Via UserId

            ClientModel Info = new ClientModel();
            using (var con = Classes.DB.InstBTCDB("instbtc"))
            {
                Info = Clients.FindById(con, int.Parse(UserId));
            }
            #endregion

            #region Build email Template
            string Template = $"<h3>Dear {Info.First_name} {Info.Last_name},</h3>"
                              + $"<p>Your deposit of ${Transaction.Deposit_Amount} has been successfully recieved and the following amount will be available on your account.</p>"
                              + $"<p>{amountBtc} BTC = ${amountUsd}</p>"
                              + $"<p>As per your request the purchased bitcoin is available in your BTC wallet.</p>"
                              + $"<p>Please don't hesitate to contact us should you have any questions. </p>"
                              + $"<p>We look forward to doing business with you again soon!</p><br>"
                              + $"<br>With regards,<br> <b style=\"color: #f7931a;\">Instbtc Team</b>";

            var body = generalEmailTemplate(Template);
            #endregion

            MailMessage message    = new MailMessage();
            SmtpClient  smtpClient = new SmtpClient();

            try
            {
                message.From = new MailAddress("*****@*****.**");
                (message.To).Add(new MailAddress(Info.Email));

                //if(Transaction.Psp_ID == 1)
                //(message.Bcc).Add("*****@*****.**");

                message.Subject        = string.Concat("Deposit Confirmation/Purchase Notification ", "[", Transaction.PaymentReference, "]");
                message.IsBodyHtml     = true;
                message.Body           = body;
                smtpClient.Host        = "smtp.gmail.com";
                smtpClient.Port        = 587;
                smtpClient.Credentials = (ICredentialsByHost) new NetworkCredential("*****@*****.**", "bG5dDe8kjycEqBHZ");
                smtpClient.EnableSsl   = true;
                smtpClient.Send(message);
            }
            catch
            {
            }
        }
示例#6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            JavaScriptSerializer ser = new JavaScriptSerializer();
            string resp = string.Empty;

            if (Request.HttpMethod == "POST")
            {
                #region GET POST Variables
                var wire_amount   = Request.Form["wire_amount"];
                var wire_currency = Request.Form["wire_currency"];
                var wire_ref      = Request.Form["wire_reff"];
                var custom_param  = Request.Form["custom_param"];
                #endregion

                #region Get Client UserId via the Custom Parameters
                var ClientId = string.Empty;
                if (custom_param.Contains("-"))
                {
                    ClientId = custom_param.Substring(0, custom_param.IndexOf("-"));
                }
                #endregion

                if (!string.IsNullOrEmpty(ClientId))
                {
                    #region Creating the Transaction Object
                    Classes.Instbtc.Models.TransactionModel Transaction = new Classes.Instbtc.Models.TransactionModel
                    {
                        Psp_ID            = decimal.Parse("1"),
                        Deposit_Currency  = wire_currency,
                        Deposit_Amount    = Convert.ToDecimal(wire_amount),
                        Exchange_Currency = "BTC",
                        Exchange_Amount   = Convert.ToDecimal(Classes.Instbtc.Utilities.Conversion.GetBTCAmountRestSharp(wire_amount, wire_currency)),
                        Created_Date      = DateTime.UtcNow,
                        Client_ID         = Convert.ToDecimal(ClientId),
                        Psp_Status        = "Approved",
                        Credited_Status   = "Credited",
                        PaymentReference  = wire_ref,
                        Notes             = $"Approved [{wire_ref}]",
                        type                 = Classes.Instbtc.Models.TransactionType.DEPOSIT,
                        CardLast4            = "",
                        CardHolderName       = "",
                        Transaction_Currency = "BTC"
                    };
                    #endregion

                    var    TransactionCheck = Utilities.Transactions.CheckTransactionIfExist(Transaction.PaymentReference);
                    object result           = new object();
                    if (string.IsNullOrEmpty(TransactionCheck))
                    {
                        result = Classes.Instbtc.Create.Transactions.CreateTransaction(Transaction)?.ToString() ?? null;

                        if (!string.IsNullOrEmpty(result.ToString()) && result.ToString() != "Internal Error")
                        {
                            #region Api Response
                            resp = ser.Serialize(new
                            {
                                success = true,
                                id      = result.ToString()
                            });
                            Response.ContentType = "application/json";
                            Response.Write(resp);
                            Response.End();
                            #endregion
                        }
                    }
                    else
                    {
                        #region Api Response
                        resp = ser.Serialize(new
                        {
                            success = false,
                            msg     = "failed to create transaction, transaction reff already exist!."
                        });
                        Response.ContentType = "application/json";
                        Response.Write(resp);
                        Response.End();
                        #endregion
                    }
                }
            }
        }
示例#7
0
        public static string ProcessConversionRequest(string conversion_id, string status)
        {
            List <Models.ConversionReqModel> RequestInfo = new List <Models.ConversionReqModel>();

            Classes.Instbtc.Models.TransactionModel Transaction = new Classes.Instbtc.Models.TransactionModel();

            using (var con = Classes.DB.InstBTCDB("instbtc"))
            {
                RequestInfo = GetConversionRequestById(con, conversion_id);

                if (RequestInfo.Count > 0)
                {
                    var ClientBitcoinBalance = Clients.GetUserBtcBalance(con, RequestInfo.FirstOrDefault().client_id.ToString());
                    var ClientEuroBalance    = Clients.GetUserEurBalance(con, RequestInfo.FirstOrDefault().client_id.ToString());

                    #region Hold The Params
                    decimal from_amount          = RequestInfo.FirstOrDefault().amount;
                    string  from_currency        = RequestInfo.FirstOrDefault().currency;
                    decimal to_amount            = RequestInfo.FirstOrDefault().conversion_amount;
                    string  to_currency          = RequestInfo.FirstOrDefault().conversion_currency;
                    string  transaction_currency = RequestInfo.FirstOrDefault().transaction_currency;
                    int     client_id            = RequestInfo.FirstOrDefault().client_id;
                    #endregion

                    #region Update Conversion Request Status
                    string        query = $"UPDATE conversion_requests SET credited_status = @credited_status WHERE id=@id";
                    NpgsqlCommand cmd   = new NpgsqlCommand(query, con);
                    cmd.Parameters.AddWithValue("@credited_status", status);
                    cmd.Parameters.AddWithValue("@id", int.Parse(conversion_id));
                    UpdateConversionRequest(con, query, cmd);
                    #endregion

                    if (transaction_currency == "BTC" && status == "Approved")
                    {
                        #region Check if Bitcoin Balance is still Enough
                        if (from_amount > Convert.ToDecimal(ClientBitcoinBalance))
                        {
                            return("Not Enough Bitcoin Balance");
                        }
                        #endregion

                        #region Add Funds on EUR Wallet Balance

                        #region Create Transaction Object
                        Transaction = new Classes.Instbtc.Models.TransactionModel
                        {
                            Psp_ID            = 11,
                            Deposit_Currency  = from_currency,
                            Deposit_Amount    = from_amount,
                            Exchange_Currency = to_currency,
                            Exchange_Amount   = to_amount,
                            Created_Date      = DateTime.UtcNow,
                            Client_ID         = Convert.ToDecimal(client_id),
                            Psp_Status        = status,
                            Credited_Status   = "Credited",
                            PaymentReference  = "",
                            Notes             = $"Converted {from_amount} {from_currency}, {to_currency} Wallet recieved {to_amount} {to_currency}.",
                            type                 = Classes.Instbtc.Models.TransactionType.CONVERSION,
                            CardLast4            = "",
                            CardHolderName       = "",
                            Transaction_Currency = "EUR"
                        };
                        #endregion

                        #region Create Transaction
                        var eur_trans_id = Classes.Instbtc.Create.Transactions.CreateTransaction(Transaction)?.ToString();
                        #endregion

                        #endregion

                        #region Deduct BTC Wallet Balance

                        #region Create Transaction Object
                        Transaction = new Classes.Instbtc.Models.TransactionModel
                        {
                            Psp_ID            = 11,
                            Deposit_Currency  = from_currency,
                            Deposit_Amount    = from_amount * -1,
                            Exchange_Currency = from_currency,
                            Exchange_Amount   = from_amount * -1,
                            Created_Date      = DateTime.UtcNow,
                            Client_ID         = Convert.ToDecimal(client_id),
                            Psp_Status        = status,
                            Credited_Status   = "Credited",
                            PaymentReference  = "",
                            Notes             = $"Deducted {from_amount} {from_currency} on BTC Wallet. [reff trans: {eur_trans_id}]",
                            type                 = Classes.Instbtc.Models.TransactionType.CONVERSION,
                            CardLast4            = "",
                            CardHolderName       = "",
                            Transaction_Currency = "BTC"
                        };
                        #endregion

                        #region Create Transaction
                        var btc_trans_id = Classes.Instbtc.Create.Transactions.CreateTransaction(Transaction)?.ToString();
                        #endregion

                        #endregion

                        #region Update Conversion Request Transaction Id
                        query = $"UPDATE conversion_requests SET transaction_id = @transaction_id WHERE id=@id";
                        cmd   = new NpgsqlCommand(query, con);
                        cmd.Parameters.AddWithValue("@transaction_id", int.Parse(eur_trans_id));
                        cmd.Parameters.AddWithValue("@id", int.Parse(conversion_id));
                        UpdateConversionRequest(con, query, cmd);
                        #endregion

                        return("Success, conversion request is updated!");
                    }

                    if (transaction_currency == "EUR" && status == "Approved")
                    {
                        #region Check if Bitcoin Balance is still Enough
                        if (from_amount > Convert.ToDecimal(ClientEuroBalance))
                        {
                            return("Not Enough Euro Balance");
                        }
                        #endregion

                        #region Add Funds on BTC Wallet

                        #region Create Transaction Object
                        Transaction = new Classes.Instbtc.Models.TransactionModel
                        {
                            Psp_ID            = 11,
                            Deposit_Currency  = from_currency,
                            Deposit_Amount    = from_amount,
                            Exchange_Currency = to_currency,
                            Exchange_Amount   = to_amount,
                            Created_Date      = DateTime.UtcNow,
                            Client_ID         = Convert.ToDecimal(client_id),
                            Psp_Status        = status,
                            Credited_Status   = "Credited",
                            PaymentReference  = "",
                            Notes             = $"Converted {from_amount} {from_currency}. {to_currency} Wallet recieved {to_amount} {to_currency}.",
                            type                 = Classes.Instbtc.Models.TransactionType.CONVERSION,
                            CardLast4            = "",
                            CardHolderName       = "",
                            Transaction_Currency = "BTC"
                        };
                        #endregion

                        #region Create Transaction
                        var btc_trans_id = Classes.Instbtc.Create.Transactions.CreateTransaction(Transaction)?.ToString();
                        #endregion

                        #endregion

                        #region Deduct Funds on EUR Wallet

                        #region Create Transaction Object
                        Transaction = new Classes.Instbtc.Models.TransactionModel
                        {
                            Psp_ID            = 11,
                            Deposit_Currency  = from_currency,
                            Deposit_Amount    = from_amount * -1,
                            Exchange_Currency = from_currency,
                            Exchange_Amount   = from_amount * -1,
                            Created_Date      = DateTime.UtcNow,
                            Client_ID         = Convert.ToDecimal(client_id),
                            Psp_Status        = status,
                            Credited_Status   = "Credited",
                            PaymentReference  = "",
                            Notes             = $"Deducted {from_amount} {from_currency} on {from_currency} Wallet. [reff trans: {btc_trans_id}]",
                            type                 = Classes.Instbtc.Models.TransactionType.CONVERSION,
                            CardLast4            = "",
                            CardHolderName       = "",
                            Transaction_Currency = "EUR"
                        };
                        #endregion

                        #region Create Transaction
                        var eur_trans_id = Classes.Instbtc.Create.Transactions.CreateTransaction(Transaction)?.ToString();
                        #endregion

                        #endregion

                        #region Update Conversion Request Transaction Id
                        query = $"UPDATE conversion_requests SET transaction_id = @transaction_id WHERE id=@id";
                        cmd   = new NpgsqlCommand(query, con);
                        cmd.Parameters.AddWithValue("@transaction_id", int.Parse(btc_trans_id));
                        cmd.Parameters.AddWithValue("@id", int.Parse(conversion_id));
                        UpdateConversionRequest(con, query, cmd);
                        #endregion

                        return("Success, conversion request is updated!");;
                    }
                }
            }
            return("Success, conversion request is updated!");
        }