protected void Page_Load(object sender, EventArgs e)
        {
            DataTable dttemp = Peerfx_DB.SPs.ViewEmbeeObjectsCurrentlyProcessing().GetDataSet().Tables[0];
            foreach (DataRow dr in dttemp.Rows)
            {
                if (dr["transid"] != DBNull.Value){
                    string transid = dr["transid"].ToString();
                    Peerfx.External_APIs.Embee em = new Peerfx.External_APIs.Embee();
                    EmbeeObject embeeobject = em.GetStatus(transid);

                    Peerfx.Site sitetemp = new Peerfx.Site();
                    int paymentkey = sitetemp.getPaymentKey_fromEmbeetransid(Convert.ToInt32(transid));
                    embeeobject.Payment_key = paymentkey;
                    if (embeeobject.Transstatus == 2)
                    {
                        //complete transaction
                        Peerfx_DB.SPs.UpdateEmbeeObjectsIpn(Convert.ToInt32(transid), embeeobject.Message, 2).Execute();
                        Peerfx_DB.SPs.UpdatePaymentStatus(paymentkey, 5).Execute();

                        //email to say top up was sent
                        Peerfx.External_APIs.SendGrid sg = new Peerfx.External_APIs.SendGrid();
                        sg.Send_Email_Payment_Completed_Embee(paymentkey);
                    }
                    else if (embeeobject.Transstatus == -1)
                    {
                        //cancel transaction
                        Peerfx_DB.SPs.UpdateEmbeeObjectsIpn(Convert.ToInt32(transid), embeeobject.Message, 3).Execute();
                        Peerfx_DB.SPs.UpdatePaymentStatus(paymentkey, 7).Execute();
                    }
                }
            }
        }
Example #2
0
        protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
        {
            if (e.CommandName == "btntradedetails")
            {
                GridDataItem item = (GridDataItem)e.Item;
                int paymentkey = Convert.ToInt32(item["payments_key"].Text);
                LoadTradeDetails(paymentkey);
                pnltradedetails.Visible = true;
            }
            if (e.CommandName == "btnWithdraw")
            {
                GridDataItem item = (GridDataItem)e.Item;
                int paymentkey = Convert.ToInt32(item["payments_key"].Text);
                Payment paymenttemp = sitetemp.getPayment(paymentkey);
                Int64 payment_payment_object_key = sitetemp.getpaymentobject(6, paymentkey);
                Users user_requestor = sitetemp.get_user_info(paymenttemp.Requestor_user_key);

                sitetemp.InternalTransaction(paymenttemp.Buy_currency, paymenttemp.Buy_amount, payment_payment_object_key, paymenttemp.Payment_object_receiver, currentuser.User_key, "From Payment object to Withdrawl Bank Account", 1, paymentkey);
                Peerfx_DB.SPs.UpdatePaymentStatus(paymentkey, 5).Execute(); //payment delivered

                //payment completed, send email
                Peerfx.External_APIs.SendGrid sg = new Peerfx.External_APIs.SendGrid();
                sg.Send_Email_Payment_Completed(paymenttemp.Payments_Key, user_requestor);

                RadGrid1.Rebind();
            }
        }
Example #3
0
        public void CheckCC_Trades_DirectPayment()
        {
            //trades currently awaiting payment from CC
            DataTable dttemp = Peerfx_DB.SPs.ViewCurrencyCloudTradeBystatus(5).GetDataSet().Tables[0];

            foreach (DataRow dr in dttemp.Rows){
                if (dr["cc_paymentid"].ToString().Length > 0)
                {
                    Hashtable hstemp = getPaymentDetails(dr["cc_paymentid"].ToString());
                    if (hstemp.Count > 0)
                    {
                        if (hstemp["status"].ToString() == "completed")
                        {
                            //trade has finally been sent to recipient
                            Int64 cctradekey = Convert.ToInt64(dr["currencycloud_trade_key"]);
                            int paymentskey = Convert.ToInt32(dr["payments_key"]);
                            Payment paymenttemp = sitetemp.getPayment(paymentskey);

                            Peerfx_DB.SPs.UpdateCurrencyCloudTradesFundsreceived(cctradekey).Execute();

                            //move money from cc object to payment object
                            Users cctreasury = sitetemp.get_treasury_account(2);
                            Int64 cctreasurypaymentobject = sitetemp.getpaymentobject_UserBalance(cctreasury.User_key, paymenttemp.Buy_currency);
                            sitetemp.InternalTransaction(paymenttemp.Buy_currency, paymenttemp.Buy_amount, cctreasurypaymentobject, paymenttemp.Payment_object_receiver, paymenttemp.Requestor_user_key, "CurrencyCloud to Receiver Object", 1, paymentskey);

                            //change status to Transaction Complete
                            Peerfx_DB.SPs.UpdatePaymentStatus(paymentskey, 5).Execute();

                            //payment in Payment Sent, send email
                            Peerfx.External_APIs.SendGrid sg = new Peerfx.External_APIs.SendGrid();
                            Users user_requestor = sitetemp.get_user_info(paymenttemp.Requestor_user_key);
                            sg.Send_Email_Payment_Completed(paymenttemp.Payments_Key, user_requestor);
                        }
                    }
                }
            }
            Peerfx_DB.SPs.UpdateScheduledTask(4).Execute();
        }
Example #4
0
        protected void btnContinue2_Click(object sender, EventArgs e)
        {
            //LoadRates(false);

            //Save current user
            int currentuserkey = 0;
            if (sitetemp.isloggedin())
            {
                //user logged in
                currentuserkey = currentuser.User_key;
            }
            else
            {
                //create new user in db & attach userkey to payment key
                DateTime dttemp = new DateTime(Convert.ToInt32(txtbirthyear.Value), Convert.ToInt32(txtbirthmonth.Value), Convert.ToInt32(txtbirthyear.Value));
                StoredProcedure sp_UpdateSignup1 = Peerfx_DB.SPs.UpdateUsers(0, null, txtfirstnamesender.Text, null, txtlastnamesender.Text, dttemp, Convert.ToInt32(ddlcountryresidence.SelectedValue), txtemailsender.Text, HttpContext.Current.Request.UserHostAddress, 0);
                sp_UpdateSignup1.Execute();
                currentuserkey = Convert.ToInt32(sp_UpdateSignup1.Command.Parameters[9].ParameterValue.ToString());
            }

            Int64 receiverpaymentobject = 0;
            Int64 senderpaymentobject = 0;
            //even if it's not a bank account, will still enter the correct payment object

            //if new recipient, save to database
            if ((pnlexistingreceiver.Visible) && (ddlReceivers.SelectedValue != "0"))
            {
                if (ddlReceivers.SelectedValue == "-1")
                {
                    //passport user
                    receiverpaymentobject = Convert.ToInt64(ddlotherpassportusers.SelectedValue);
                }
                else if (ddlReceivers.SelectedValue == "-2")
                {
                    //top up embee
                    //1st step record the embee payment object
                    string strphone = txtembeephone.Text;
                    strphone = strphone.Replace("-", "").Replace(" ", "");
                    while (strphone.Substring(0, 1) == "0")
                    {
                        strphone = strphone.Substring(1, strphone.Length - 1);
                    }

                    StoredProcedure sp_UpdateEmbeeObject = Peerfx_DB.SPs.UpdateEmbeeCatalogRecordpaymentobject(Convert.ToInt32(ddlembeecatalog.SelectedValue),strphone, 0);
                    sp_UpdateEmbeeObject.Execute();
                    receiverpaymentobject = Convert.ToInt64(sp_UpdateEmbeeObject.Command.Parameters[2].ParameterValue.ToString());
                }
                else
                {
                    receiverpaymentobject = Convert.ToInt64(ddlReceivers.SelectedValue);
                }
            }
            else
            {
                BankAccounts ba = BankAccountEntry1.gettxtfields();
                //new recipient
                receiverpaymentobject = BankAccountEntry1.InsertBankAccount(currentuser.User_key);
                Peerfx_DB.SPs.UpdateRecipients(0, currentuser.User_key, receiverpaymentobject).Execute();
                /*StoredProcedure sp_UpdateBank_account = Peerfx_DB.SPs.UpdateBankAccounts(0, null, Convert.ToInt32(ddlbuycurrency.SelectedValue), null, null, currentuserkey, HttpContext.Current.Request.UserHostAddress, lblconfirmreceiverAccount.Text, lblconfirmreceiverIBAN.Text, lblconfirmreceiverBankCode.Text, lblconfirmreceiverABArouting.Text, txtfirstnamereceiver.Text, txtlastnamereceiver.Text, null, 0);
                sp_UpdateBank_account.Execute();
                int bank_account_key = Convert.ToInt32(sp_UpdateBank_account.Command.Parameters[14].ParameterValue.ToString());
                //Save payment object
                StoredProcedure sp_UpdatePaymentObject = Peerfx_DB.SPs.UpdatePaymentObjects(0, 1, bank_account_key, 0);
                sp_UpdatePaymentObject.Execute();
                receiverpaymentobject = Convert.ToInt64(sp_UpdatePaymentObject.Command.Parameters[3].ParameterValue.ToString());*/
            }

            if (pnlloggedinsender.Visible)
            {
                if (sitetemp.IsUserBalance(Convert.ToInt64(hdsenderpaymentobjectkey.Value)))
                {
                    //user balance
                    senderpaymentobject = Convert.ToInt64(hdsenderpaymentobjectkey.Value);
                }
                else
                {
                    //bank account
                    senderpaymentobject = 0;
                }
            }

            //Confirming quote, create in database
            //Save & get Quote
            StoredProcedure sp_UpdateQuotes = Peerfx_DB.SPs.UpdateQuotes(0, Convert.ToDecimal(txtsell.Value), Convert.ToInt32(ddlsellcurrency.SelectedValue), Convert.ToDecimal(txtbuy.Value), Convert.ToInt32(ddlbuycurrency.SelectedValue), Convert.ToDecimal(lblrate.Text), Convert.ToDecimal(hdservicefee.Value), null, null, 0);
            sp_UpdateQuotes.Execute();
            int quote_key = Convert.ToInt32(sp_UpdateQuotes.Command.Parameters[9].ParameterValue.ToString());

            //Save & get Payment key

            StoredProcedure sp_UpdatePayments = Peerfx_DB.SPs.UpdatePayments(0, quote_key, 0, 0, currentuserkey, lblconfirmreceiverdescription.Text,senderpaymentobject,receiverpaymentobject);
            sp_UpdatePayments.Execute();
            int payment_key = Convert.ToInt32(sp_UpdatePayments.Command.Parameters[3].ParameterValue.ToString());
            lblpaymentnum.Text = payment_key.ToString();
            //update payment status to confirmed
            Peerfx_DB.SPs.UpdatePaymentStatus(payment_key, 2).Execute();

            //Assign proper treasury type
            int treasurytype = 2; //default = cc
            if (chkpremium.Checked)
            {
                treasurytype = 1;
            }
            if (sitetemp.getpaymentobjecttype(receiverpaymentobject) == 7)//receiver is embee
            {
                treasurytype = 1;
            }
            Peerfx_DB.SPs.UpdatePaymentTreasury(payment_key, treasurytype).Execute();

            //Send confirmation email with instructions etc.
            Peerfx.External_APIs.SendGrid sg = new Peerfx.External_APIs.SendGrid();
            sg.Send_Email_Payment_Confirmed(payment_key, currentuser);

            Hashtable hstemp = new Hashtable();
            hstemp.Add("Treasury Type", treasurytype.ToString());
            hstemp.Add("Payment Key", payment_key);
            hstemp.Add("Sell Currency", ddlsellcurrency.SelectedItem.Text);
            hstemp.Add("Sell Amount", txtsell.Text);
            hstemp.Add("Buy Currency", ddlbuycurrency.SelectedItem.Text);
            hstemp.Add("Buy Amount", txtbuy.Text);
            mx.TrackEvent("ExchangeCurrency - Confirmed Payment", currentuser.User_key, hstemp);

            bool isuserbalance = false;
            if (pnlloggedinsender.Visible)
            {
                if (sitetemp.IsUserBalance(Convert.ToInt64(hdsenderpaymentobjectkey.Value)))
                {
                    //send money from user balance to payment object
                    Int64 userbalance_payment_object_key = sitetemp.getpaymentobject_UserBalance(currentuser.User_key,Convert.ToInt32(ddlsellcurrency.SelectedValue));
                    Int64 payment_payment_object_key = sitetemp.getpaymentobject(6,payment_key);
                    Peerfx_DB.SPs.UpdateTransactionsInternal(0, 2, Convert.ToInt32(ddlsellcurrency.SelectedValue), Convert.ToDecimal(txtsell.Value), userbalance_payment_object_key, payment_payment_object_key, sitetemp.get_ipaddress(), currentuser.User_key, "user balance to payment", 0, 1, payment_key).Execute();

                    //instantly convert the payment, because source funding is balance
                    //initiate conversion
                    sitetemp.payment_initiate(payment_key);
                    Response.Redirect("/User/Dashboard.aspx?notification=true");
                }
            }

            if (!isuserbalance)
            {

                //Change tab to bank transfer info
                changetab(2);

                //Status to Awaiting User Deposit
                Peerfx_DB.SPs.UpdatePaymentStatus(payment_key, 11).Execute();
            }

            //populate labels
            updatealreadyconfirmedtab();
        }
Example #5
0
        public void payment_complete(Payment paymenttemp)
        {
            int paymentkey = paymenttemp.Payments_Key;
            Int64 payment_payment_object_key = getpaymentobject(6, paymentkey);
            Users user_requestor = get_user_info(paymenttemp.Requestor_user_key);

            //Check if does not require manual export
            if (!paymenttemp.Requiresmanualexport)
            {
                Peerfx.External_APIs.SendGrid sg = new Peerfx.External_APIs.SendGrid();
                //Automatically complete payment

                //If Applicable - Ownership of funds is changing, so need to change ownership of funds in ext bank accounts , eg. bancbox
                AdjustExternalBanks(paymenttemp);

                if (paymenttemp.Payment_object_receiver_type == 3) //going to user balance
                {
                    Peerfx_DB.SPs.UpdateTransactionsInternal(0, 2, paymenttemp.Buy_currency, paymenttemp.Buy_amount, payment_payment_object_key, paymenttemp.Payment_object_receiver, get_ipaddress(), paymenttemp.Requestor_user_key, "From Payment to User Balance", 0, 1, paymentkey).Execute();
                    Peerfx_DB.SPs.UpdatePaymentStatus(paymentkey, 5).Execute(); //payment delivered

                    //payment completed, send email
                    sg.Send_Email_Payment_Completed(paymenttemp.Payments_Key, user_requestor);
                }
                else if (paymenttemp.Payment_object_receiver_type == 7) //Embee top up
                {
                    //Send Top Up
                    EmbeeObject embeetemp = getEmbeeObject(paymenttemp.Payments_Key);
                    External_APIs.Embee embeecalls = new External_APIs.Embee();
                    int newtransid = embeecalls.RequestPurchase(embeetemp.Productid.ToString(), embeetemp.Phone, user_requestor.Email, get_ipaddress(), user_requestor.User_key, paymentkey);
                    Peerfx_DB.SPs.UpdateEmbeeNewtransid(newtransid, embeetemp.Embee_object_key).Execute();
                    Peerfx_DB.SPs.UpdatePaymentStatus(paymentkey, 6).Execute();

                    Int64 embee_paymentobjectkey = getpaymentobject(7, embeetemp.Embee_object_key);
                    Peerfx_DB.SPs.UpdateTransactionsExternal(0, 1, paymenttemp.Buy_currency, paymenttemp.Buy_amount, payment_payment_object_key, embee_paymentobjectkey, get_ipaddress(), paymenttemp.Requestor_user_key, "From Payment to Embee Object", "", 0, 1, paymentkey).Execute();

                    //send receiver note
                    try
                    {
                        string thebody = System.IO.File.ReadAllText(HttpContext.Current.Server.MapPath("/SMS/payment_confirmed_Embee.txt"));
                        thebody = thebody.Replace("FIRST_NAME", user_requestor.First_name);
                        thebody = thebody.Replace("LAST_NAME", user_requestor.Last_name);
                        thebody = thebody.Replace("TOPUP_NAME", embeetemp.Productname);

                        External_APIs.Twilio twillio = new External_APIs.Twilio();
                        twillio.SendSMS(embeetemp.Phone, thebody, embeetemp.Country);
                    }
                    catch
                    {
                    }
                }
                else if ((paymenttemp.Buy_currency == 3) && (user_requestor.Bancbox_payment_object_key > 0) && (IsBankAccount(paymenttemp.Payment_object_receiver)))
                {
                    //Send out money via Bancbox account
                    External_APIs.BancBox bb = new External_APIs.BancBox();
                    bb.SendFunds_External(user_requestor.User_key, paymenttemp.Payment_object_receiver, paymenttemp.Buy_amount, "External Transfer", false, 1, paymenttemp.Payments_Key);
                    Peerfx_DB.SPs.UpdateTransactionsExternal(0, 1, paymenttemp.Buy_currency, paymenttemp.Buy_amount, payment_payment_object_key, paymenttemp.Payment_object_receiver, get_ipaddress(), paymenttemp.Requestor_user_key, "From Payment to Ext US Bank", "", 0, 1, paymentkey).Execute();

                    //change status to Transaction Complete
                    Peerfx_DB.SPs.UpdatePaymentStatus(paymentkey, 5).Execute();

                    //payment in Payment Sent, send email
                    sg.Send_Email_Payment_Completed(paymenttemp.Payments_Key, user_requestor);
                }
            }
            else
            {
                //notify admin manual export is required

                //change status to processing transaction / awaiting withdrawl
                Peerfx_DB.SPs.UpdatePaymentStatus(paymenttemp.Payments_Key, 10).Execute();
            }
        }