Beispiel #1
0
    private void PayPal(Guid goId)
    {
        StringBuilder url = new StringBuilder();

        string m_sPaypalBase = System.Configuration.ConfigurationManager.AppSettings["paypalBase"];
        string business      = System.Configuration.ConfigurationManager.AppSettings["paypalEmail"];
        string cancelUrl     = System.Configuration.ConfigurationManager.AppSettings["cancelPaymentUrlGala"] + "?id=" + goId.ToString();
        string returnUrl     = System.Configuration.ConfigurationManager.AppSettings["successPaymentUrlGala"];
        string notifyUrl     = System.Configuration.ConfigurationManager.AppSettings["notifyUrlGala"];

        url.Append(m_sPaypalBase);
        url.AppendFormat("&business={0}", HttpUtility.UrlEncode(business));
        url.AppendFormat("&item_name={0}", HttpUtility.UrlEncode("Payment for Gala Order"));                    // for: " + serials));
        url.AppendFormat("&item_number={0}", HttpUtility.UrlEncode(goId.ToString().Substring(0, 8).ToUpper())); // suppose to serial num, but there is possiblity of multiple entries per order????

        decimal amount = go.Amount;

        amount += go.Fee; // Add fees for PP payment
        amount += go.FeeShipping;
        amount += go.Tax;
        url.AppendFormat("&amount={0}", HttpUtility.UrlEncode(amount.ToString("0.00")));



        // //For testing of $0.01
        //url.AppendFormat("&amount={0}", HttpUtility.UrlEncode("0.01"));



        url.AppendFormat("&currency_code={0}", HttpUtility.UrlEncode("SGD"));

        url.AppendFormat("&shipping={0}", HttpUtility.UrlEncode("0"));
        url.AppendFormat("&no_shipping={0}", HttpUtility.UrlEncode("0"));
        url.AppendFormat("&invoice={0}", "");

        string custom = goId.ToString();

        url.AppendFormat("&custom={0}", HttpUtility.UrlEncode(custom));
        url.AppendFormat("&cancel_return={0}", HttpUtility.UrlEncode(cancelUrl));
        url.AppendFormat("&notify_url={0}", HttpUtility.UrlEncode(notifyUrl));
        url.AppendFormat("&return={0}", HttpUtility.UrlEncode(returnUrl + "?custom=" + goId.ToString()));

        RawLog rawlog = RawLog.NewRawLog();

        rawlog.Type       = 0; //send
        rawlog.Data       = url.ToString();
        rawlog.DateString = DateTime.Now.ToString();

        if (rawlog.IsValid)
        {
            rawlog.Save();
        }


        Response.Redirect(url.ToString());
    }
Beispiel #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string raw = Request.Form.ToString();


            //string raw = "mc_gross=0.01&invoice=&protection_eligibility=Ineligible&address_status=unconfirmed&payer_id=UR49ET2KZXEW8&tax=0.00&address_street=1&payment_date=04%3a14%3a17+Jul+06%2c+2011+PDT&payment_status=Completed&charset=UTF-8&address_zip=123&first_name=Ryan&mc_fee=0.01&address_country_code=SG&address_name=Lin+Ryan&notify_version=3.1&custom=741d39e4-59a0-45ea-80cb-f8ab4a9ae516&payer_status=unverified&business=support%40iptech.com.sg&address_country=Singapore&address_city=Singapore&quantity=1&verify_sign=ApBHX6qbpxJW-Ll3oP22LSbo0WeuAQORcWZMIuElqANQ07mCXbMxElR6&payer_email=ryan.lin%40iptech.com.sg&txn_id=14778729V9946272U&payment_type=instant&last_name=Lin&address_state=&receiver_email=alan%40u-win.com.sg&payment_fee=&receiver_id=SFV2QPZN3N34S&txn_type=web_accept&item_name=Payment+for+the+Conference(s)+and+Forum(s)+purchase&mc_currency=SGD&item_number=WEBNEW2000014&residence_country=SG&receipt_id=0296-7872-5878-7642&handling_amount=0.00&transaction_subject=FFF8A3B8-3CB6-4C76-ACBE-AFFA5DB0D61EDCode42A0D59A&payment_gross=&shipping=0.00&ipn_track_id=D4iefWBu-inyL2a-VXfFwg";

            RawLog rawlog = RawLog.NewRawLog();
            rawlog.Type       = 1; //response
            rawlog.Data       = raw;
            rawlog.DateString = DateTime.Now.ToString();

            if (rawlog.IsValid)
            {
                rawlog.Save();
            }

            TransactionLog Tlog = TransactionLog.NewTransactionLog();
            //Tlog.RegistrationID = Guid.NewGuid(); //WRONG

            string[] args = raw.Split('&');

            for (int i = 0; i < args.Length; i++)
            {
                string[] arg = args[i].Split('=');

                switch (arg[0])
                {
                case "mc_gross": Tlog.Gross = float.Parse(HttpUtility.HtmlDecode(arg[1])); break;

                case "invoice": Tlog.TransactionID = HttpUtility.HtmlDecode(arg[1]); break;

                case "protection_eligibility": Tlog.Protection = HttpUtility.HtmlDecode(arg[1]); break;

                case "payer_id": Tlog.PayerID = HttpUtility.HtmlDecode(arg[1]); break;

                case "tax": Tlog.Tax = float.Parse(HttpUtility.HtmlDecode(arg[1])); break;

                case "payment_date": Tlog.PaymentDate = Server.UrlDecode(HttpUtility.HtmlDecode(arg[1])); break;

                case "payment_status": Tlog.PaymentStatus = HttpUtility.HtmlDecode(arg[1]); break;

                case "charset": break;

                case "first_name": Tlog.FirstName = HttpUtility.HtmlDecode(arg[1]); break;

                case "mc_fee": Tlog.TransactionFee = float.Parse(HttpUtility.HtmlDecode(arg[1])); break;

                case "ify_version": break;

                case "payer_status": break;

                case "business": Tlog.Business = Server.UrlDecode(HttpUtility.HtmlDecode(arg[1])); break;

                case "quantity": break;

                case "payer_email": Tlog.PayerEmail = Server.UrlDecode(HttpUtility.HtmlDecode(arg[1])); break;

                case "verify_sign": Tlog.VerifySign = HttpUtility.HtmlDecode(arg[1]); break;

                case "txn_id": Tlog.PaypalID = HttpUtility.HtmlDecode(arg[1]); break;

                case "payment_type": Tlog.PaymentType = HttpUtility.HtmlDecode(arg[1]); break;

                case "last_name": Tlog.LastName = HttpUtility.HtmlDecode(arg[1]); break;

                case "receiver_email": Tlog.ReceiverEmail = Server.UrlDecode(HttpUtility.HtmlDecode(arg[1])); break;

                case "payment_fee": break;

                case "receiver_id": Tlog.ReceiverID = HttpUtility.HtmlDecode(arg[1]); break;

                case "txn_type": break;

                case "item_name": Tlog.ItemName = Server.UrlDecode(HttpUtility.HtmlDecode(arg[1])); Tlog.Subject = Server.UrlDecode(HttpUtility.HtmlDecode(arg[1])); break;

                case "mc_currency": Tlog.Currency = HttpUtility.HtmlDecode(arg[1]); break;

                case "item_number": break;

                case "residence_country": Tlog.Country = HttpUtility.HtmlDecode(arg[1]); break;

                case "handling_amount": Tlog.Handling = float.Parse(HttpUtility.HtmlDecode(arg[1])); break;

                case "transaction_subject": break;

                case "payment_gross": break;

                case "shipping": Tlog.Shipping = float.Parse(HttpUtility.HtmlDecode(arg[1])); break;

                case "merchant_return_link": break;

                case "custom": Tlog.RegistrationID = new Guid(HttpUtility.HtmlDecode(arg[1])); break;
                    //string[] custom = HttpUtility.HtmlDecode(arg[1]).Split(new string[] { "DCode" }, StringSplitOptions.None);
                    //for (int y = 0; y < custom.Length; y++)
                    //{
                    //    if (y.Equals(0))
                    //        Tlog.RegistrationID = new Guid(custom[y]);

                    //    if (y.Equals(1))
                    //        discountCode = custom[y];
                    //}
                    //break;
                }
            }

            if (Tlog.PaymentStatus.Contains("Completed"))
            {
                try
                {
                    GeneralFunction.CompleteNewGalaOrderPayPal(Tlog.RegistrationID);
                }
                catch (Exception exp)
                {
                    RawLog log = RawLog.NewRawLog();
                    log.Type       = 3; // Process payment error
                    log.Data       = "[" + exp.Message + "]";
                    log.DateString = DateTime.Now.ToString();

                    if (log.IsValid)
                    {
                        log.Save();
                    }
                }
            }

            if (Tlog.PaymentStatus.Contains("Pending"))
            {
                // not so good
            }

            if (Tlog.PaymentStatus.Contains("Denied"))
            {
                // bad!
            }

            if (Tlog.IsValid)
            {
                Tlog.Save();
            }
            else
            {
                RawLog log = RawLog.NewRawLog();
                log.Type       = 2; //error
                log.Data       = Tlog.BrokenRulesCollection.ToString();
                log.DateString = DateTime.Now.ToString();

                if (log.IsValid)
                {
                    log.Save();
                }
            }
        }
        catch (Exception ex)
        {
            RawLog log = RawLog.NewRawLog();
            log.Type       = 4; // Overall payment error
            log.Data       = "[" + ex.Message + "]";
            log.DateString = DateTime.Now.ToString();

            if (log.IsValid)
            {
                log.Save();
            }
        }
    }
Beispiel #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string raw = Request.Form.ToString();
            //string discountCode = string.Empty;
            //string raw = "mc_gross=0.01&protection_eligibility=Ineligible&address_status=unconfirmed&payer_id=75RQAEDZYCD6A&tax=0.00&address_street=test&payment_date=22%3a18%3a17+Oct+22%2c+2015+PDT&payment_status=Completed&charset=gb2312&address_zip=34&first_name=shanice&mc_fee=0.01&address_country_code=SG&address_name=soh+shanice&notify_version=3.8&custom=d693b35c-3db3-4e99-8141-c1626e719165&payer_status=unverified&business=af%40ifektiv.com&address_country=Singapore&address_city=&quantity=1&verify_sign=AMIxIb-fq-bQLc45DZlYXp5uIWZJAzSFbammHFZ7khJL2HUKacwcLPGQ&payer_email=shanice%40ifektiv.com&txn_id=15C87088M38848415&payment_type=instant&last_name=soh&address_state=&receiver_email=af%40ifektiv.com&payment_fee=&receiver_id=MU2A9FC6CKEYE&txn_type=web_accept&item_name=Payment+for+APAC+Effie+Entry&mc_currency=SGD&item_number=D693B35C&residence_country=SG&receipt_id=3610-4808-7977-6573&handling_amount=0.00&transaction_subject=d693b35c-3db3-4e99-8141-c1626e719165&payment_gross=&shipping=0.00&ipn_track_id=721492c2a4faa";

            RawLog rawlog = RawLog.NewRawLog();
            rawlog.Type       = 1; //response
            rawlog.Data       = raw;
            rawlog.DateString = DateTime.Now.ToString();

            if (rawlog.IsValid)
            {
                rawlog.Save();
            }

            TransactionLog Tlog = TransactionLog.NewTransactionLog();
            //Tlog.RegistrationID = Guid.NewGuid(); //WRONG

            string[] args = raw.Split('&');

            for (int i = 0; i < args.Length; i++)
            {
                string[] arg = args[i].Split('=');

                switch (arg[0])
                {
                case "mc_gross": Tlog.Gross = float.Parse(HttpUtility.HtmlDecode(arg[1])); break;

                case "invoice": Tlog.TransactionID = HttpUtility.HtmlDecode(arg[1]); break;

                case "protection_eligibility": Tlog.Protection = HttpUtility.HtmlDecode(arg[1]); break;

                case "payer_id": Tlog.PayerID = HttpUtility.HtmlDecode(arg[1]); break;

                case "tax": Tlog.Tax = float.Parse(HttpUtility.HtmlDecode(arg[1])); break;

                case "payment_date": Tlog.PaymentDate = Server.UrlDecode(HttpUtility.HtmlDecode(arg[1])); break;

                case "payment_status": Tlog.PaymentStatus = HttpUtility.HtmlDecode(arg[1]); break;

                case "charset": break;

                case "first_name": Tlog.FirstName = HttpUtility.HtmlDecode(arg[1]); break;

                case "mc_fee": Tlog.TransactionFee = float.Parse(HttpUtility.HtmlDecode(arg[1])); break;

                case "ify_version": break;

                case "payer_status": break;

                case "business": Tlog.Business = Server.UrlDecode(HttpUtility.HtmlDecode(arg[1])); break;

                case "quantity": break;

                case "payer_email": Tlog.PayerEmail = Server.UrlDecode(HttpUtility.HtmlDecode(arg[1])); break;

                case "verify_sign": Tlog.VerifySign = HttpUtility.HtmlDecode(arg[1]); break;

                case "txn_id": Tlog.PaypalID = HttpUtility.HtmlDecode(arg[1]); break;

                case "payment_type": Tlog.PaymentType = HttpUtility.HtmlDecode(arg[1]); break;

                case "last_name": Tlog.LastName = HttpUtility.HtmlDecode(arg[1]); break;

                case "receiver_email": Tlog.ReceiverEmail = Server.UrlDecode(HttpUtility.HtmlDecode(arg[1])); break;

                case "payment_fee": break;

                case "receiver_id": Tlog.ReceiverID = HttpUtility.HtmlDecode(arg[1]); break;

                case "txn_type": break;

                case "item_name": Tlog.ItemName = Server.UrlDecode(HttpUtility.HtmlDecode(arg[1])); Tlog.Subject = Server.UrlDecode(HttpUtility.HtmlDecode(arg[1])); break;

                case "mc_currency": Tlog.Currency = HttpUtility.HtmlDecode(arg[1]); break;

                case "item_number": break;

                case "residence_country": Tlog.Country = HttpUtility.HtmlDecode(arg[1]); break;

                case "handling_amount": Tlog.Handling = float.Parse(HttpUtility.HtmlDecode(arg[1])); break;

                case "transaction_subject": break;

                case "payment_gross": break;

                case "shipping": Tlog.Shipping = float.Parse(HttpUtility.HtmlDecode(arg[1])); break;

                case "merchant_return_link": break;

                case "custom": Tlog.RegistrationID = new Guid(HttpUtility.HtmlDecode(arg[1])); break;
                    //string[] custom = HttpUtility.HtmlDecode(arg[1]).Split(new string[] { "DCode" }, StringSplitOptions.None);
                    //for (int y = 0; y < custom.Length; y++)
                    //{
                    //    if (y.Equals(0))
                    //        Tlog.RegistrationID = new Guid(custom[y]);

                    //    if (y.Equals(1))
                    //        discountCode = custom[y];
                    //}
                    //break;
                }
            }

            if (Tlog.PaymentStatus.Contains("Completed"))
            {
                try
                {
                    GeneralFunction.CompletePaymentAdhocPayPal(Tlog.RegistrationID);
                }
                catch (Exception exp)
                {
                    RawLog log = RawLog.NewRawLog();
                    log.Type       = 3; // Process payment error
                    log.Data       = "[" + exp.Message + "]";
                    log.DateString = DateTime.Now.ToString();

                    if (log.IsValid)
                    {
                        log.Save();
                    }
                }
            }

            if (Tlog.PaymentStatus.Contains("Pending"))
            {
                // not so good
            }

            if (Tlog.PaymentStatus.Contains("Denied"))
            {
                // bad!
            }

            if (Tlog.IsValid)
            {
                Tlog.Save();
            }
            else
            {
                RawLog log = RawLog.NewRawLog();
                log.Type       = 2; //error
                log.Data       = Tlog.BrokenRulesCollection.ToString();
                log.DateString = DateTime.Now.ToString();

                if (log.IsValid)
                {
                    log.Save();
                }
            }
        }
        catch (Exception ex)
        {
            RawLog log = RawLog.NewRawLog();
            log.Type       = 4; // Overall payment error
            log.Data       = "[" + ex.Message + "]";
            log.DateString = DateTime.Now.ToString();

            if (log.IsValid)
            {
                log.Save();
            }
        }
    }
Beispiel #4
0
    private void PayPal(string serials)
    {
        StringBuilder url = new StringBuilder();

        string m_sPaypalBase = System.Configuration.ConfigurationManager.AppSettings["paypalBase"];
        string business      = System.Configuration.ConfigurationManager.AppSettings["paypalEmail"];
        string cancelUrl     = System.Configuration.ConfigurationManager.AppSettings["cancelPaymentUrl"];
        string returnUrl     = System.Configuration.ConfigurationManager.AppSettings["successPaymentUrl"];
        string notifyUrl     = System.Configuration.ConfigurationManager.AppSettings["notifyUrl"];

        url.Append(m_sPaypalBase);
        url.AppendFormat("&business={0}", HttpUtility.UrlEncode(business));
        url.AppendFormat("&item_name={0}", HttpUtility.UrlEncode("Payment for APAC Effie Entry"));                    // for: " + serials));
        url.AppendFormat("&item_number={0}", HttpUtility.UrlEncode(payGroupId.ToString().Substring(0, 8).ToUpper())); // suppose to serial num, but there is possiblity of multiple entries per order????

        decimal amount = GeneralFunction.CalculateGroupTotalPriceFromCache();

        amount += GeneralFunction.CalculateCreditFees(amount); // Add fees for PP payment // 0.01;
        if (ddlCountry.SelectedValue.ToLower() == "singapore")
        {
            amount += GeneralFunction.CalculateTax(amount);
        }

        bool IsTestPay = System.Configuration.ConfigurationManager.AppSettings["IsTestPay"].ToString() == "1";

        if (IsTestPay)
        {
            amount = 0.01m;
        }
        url.AppendFormat("&amount={0}", HttpUtility.UrlEncode(amount.ToString("0.00")));

        //For testing of $0.01
        //url.AppendFormat("&amount={0}", HttpUtility.UrlEncode("0.01"));

        url.AppendFormat("&currency_code={0}", HttpUtility.UrlEncode("SGD"));

        url.AppendFormat("&shipping={0}", HttpUtility.UrlEncode("0"));
        url.AppendFormat("&no_shipping={0}", HttpUtility.UrlEncode("0"));
        url.AppendFormat("&invoice={0}", "");

        string custom = payGroupId.ToString();

        url.AppendFormat("&custom={0}", HttpUtility.UrlEncode(custom));
        url.AppendFormat("&cancel_return={0}", HttpUtility.UrlEncode(cancelUrl));
        url.AppendFormat("&notify_url={0}", HttpUtility.UrlEncode(notifyUrl));
        url.AppendFormat("&return={0}", HttpUtility.UrlEncode(returnUrl + "?custom=" + payGroupId.ToString()));

        RawLog rawlog = RawLog.NewRawLog();

        rawlog.Type       = 0; //send
        rawlog.Data       = url.ToString();
        rawlog.DateString = DateTime.Now.ToString();

        if (rawlog.IsValid)
        {
            rawlog.Save();
        }
        //GeneralFunction.CompleteNewEntrySubmissionPayPal(payGroupId);

        Response.Redirect(url.ToString());
    }
Beispiel #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string raw = Request.Form.ToString();
            //string discountCode = string.Empty;
            //string raw = "mc_gross=1144.00&protection_eligibility=Ineligible&address_status=confirmed&payer_id=CZ47M7SFTQ2XG&address_street=1+Emlyn+Road&payment_date=01%3a37%3a09+Dec+14%2c+2016+PST&payment_status=Pending&charset=gb2312&address_zip=W12+9TF&first_name=Will&mc_fee=39.40&address_country_code=GB&address_name=Will+Philipps&notify_version=3.8&custom=fd901804-56e8-4573-b6d9-2e097d0c7eac&payer_status=verified&business=af%40ifektiv.com&address_country=United+Kingdom&address_city=London&quantity=1&verify_sign=AAUUy98LqRzbTaozCbnuIMikh2AmApNWvYUyUdNS4.-GHJBT0K3t5Ya0&payer_email=willphilipps%40btinternet.com&txn_id=83J71625FR2201601&payment_type=instant&last_name=Philipps&address_state=London&receiver_email=af%40ifektiv.com&payment_fee=&receiver_id=MU2A9FC6CKEYE&pending_reason=paymentreview&txn_type=web_accept&item_name=Payment+for+APAC+Effie+Entry&mc_currency=SGD&item_number=FD901804&residence_country=GB&transaction_subject=&payment_gross=&shipping=0.00&ipn_track_id=3869ea83a1068";

            RawLog rawlog = RawLog.NewRawLog();
            rawlog.Type       = 1; //response
            rawlog.Data       = raw;
            rawlog.DateString = DateTime.Now.ToString();

            if (rawlog.IsValid)
            {
                rawlog.Save();
            }

            TransactionLog Tlog = TransactionLog.NewTransactionLog();
            //Tlog.RegistrationID = Guid.NewGuid(); //WRONG

            string[] args = raw.Split('&');

            for (int i = 0; i < args.Length; i++)
            {
                string[] arg = args[i].Split('=');

                switch (arg[0])
                {
                case "mc_gross": Tlog.Gross = float.Parse(HttpUtility.HtmlDecode(arg[1])); break;

                case "invoice": Tlog.TransactionID = HttpUtility.HtmlDecode(arg[1]); break;

                case "protection_eligibility": Tlog.Protection = HttpUtility.HtmlDecode(arg[1]); break;

                case "payer_id": Tlog.PayerID = HttpUtility.HtmlDecode(arg[1]); break;

                case "tax": Tlog.Tax = float.Parse(HttpUtility.HtmlDecode(arg[1])); break;

                case "payment_date": Tlog.PaymentDate = Server.UrlDecode(HttpUtility.HtmlDecode(arg[1])); break;

                case "payment_status": Tlog.PaymentStatus = HttpUtility.HtmlDecode(arg[1]); break;

                case "charset": break;

                case "first_name": Tlog.FirstName = HttpUtility.HtmlDecode(arg[1]); break;

                case "mc_fee": Tlog.TransactionFee = float.Parse(HttpUtility.HtmlDecode(arg[1])); break;

                case "ify_version": break;

                case "payer_status": break;

                case "business": Tlog.Business = Server.UrlDecode(HttpUtility.HtmlDecode(arg[1])); break;

                case "quantity": break;

                case "payer_email": Tlog.PayerEmail = Server.UrlDecode(HttpUtility.HtmlDecode(arg[1])); break;

                case "verify_sign": Tlog.VerifySign = HttpUtility.HtmlDecode(arg[1]); break;

                case "txn_id": Tlog.PaypalID = HttpUtility.HtmlDecode(arg[1]); break;

                case "payment_type": Tlog.PaymentType = HttpUtility.HtmlDecode(arg[1]); break;

                case "last_name": Tlog.LastName = HttpUtility.HtmlDecode(arg[1]); break;

                case "receiver_email": Tlog.ReceiverEmail = Server.UrlDecode(HttpUtility.HtmlDecode(arg[1])); break;

                case "payment_fee": break;

                case "receiver_id": Tlog.ReceiverID = HttpUtility.HtmlDecode(arg[1]); break;

                case "txn_type": break;

                case "item_name": Tlog.ItemName = Server.UrlDecode(HttpUtility.HtmlDecode(arg[1])); Tlog.Subject = Server.UrlDecode(HttpUtility.HtmlDecode(arg[1])); break;

                case "mc_currency": Tlog.Currency = HttpUtility.HtmlDecode(arg[1]); break;

                case "item_number": break;

                case "residence_country": Tlog.Country = HttpUtility.HtmlDecode(arg[1]); break;

                case "handling_amount": Tlog.Handling = float.Parse(HttpUtility.HtmlDecode(arg[1])); break;

                case "transaction_subject": break;

                case "payment_gross": break;

                case "shipping": Tlog.Shipping = float.Parse(HttpUtility.HtmlDecode(arg[1])); break;

                case "merchant_return_link": break;

                case "custom": Tlog.RegistrationID = new Guid(HttpUtility.HtmlDecode(arg[1])); break;
                    //string[] custom = HttpUtility.HtmlDecode(arg[1]).Split(new string[] { "DCode" }, StringSplitOptions.None);
                    //for (int y = 0; y < custom.Length; y++)
                    //{
                    //    if (y.Equals(0))
                    //        Tlog.RegistrationID = new Guid(custom[y]);

                    //    if (y.Equals(1))
                    //        discountCode = custom[y];
                    //}
                    //break;
                }
            }

            if (Tlog.PaymentStatus.Contains("Completed"))
            {
                try
                {
                    GeneralFunction.CompleteNewEntrySubmissionPayPal(Tlog.RegistrationID);
                }
                catch (Exception exp)
                {
                    RawLog log = RawLog.NewRawLog();
                    log.Type       = 3; // Process payment error
                    log.Data       = "[" + exp.Message + "]";
                    log.DateString = DateTime.Now.ToString();

                    if (log.IsValid)
                    {
                        log.Save();
                    }
                }
            }

            if (Tlog.PaymentStatus.Contains("Pending"))
            {
                // not so good
            }

            if (Tlog.PaymentStatus.Contains("Denied"))
            {
                // bad!
            }

            if (Tlog.IsValid)
            {
                Tlog.Save();
            }
            else
            {
                RawLog log = RawLog.NewRawLog();
                log.Type       = 2; //error
                log.Data       = Tlog.BrokenRulesCollection.ToString();
                log.DateString = DateTime.Now.ToString();

                if (log.IsValid)
                {
                    log.Save();
                }
            }
        }
        catch (Exception ex)
        {
            RawLog log = RawLog.NewRawLog();
            log.Type       = 4; // Overall payment error
            log.Data       = "[" + ex.Message + "]";
            log.DateString = DateTime.Now.ToString();

            if (log.IsValid)
            {
                log.Save();
            }
        }
    }
Beispiel #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        payGroupIdString = Request.QueryString["pgId"];

        if (payGroupIdString != null && !String.IsNullOrEmpty(payGroupIdString))
        {
            payGroupId = GeneralFunction.GetValueGuid(payGroupIdString, true);
        }
        else
        {
            return;
        }


        StringBuilder url = new StringBuilder();

        string m_sPaypalBase = System.Configuration.ConfigurationManager.AppSettings["paypalBase"];
        string business      = System.Configuration.ConfigurationManager.AppSettings["paypalEmail"];
        string cancelUrl     = System.Configuration.ConfigurationManager.AppSettings["cancelPaymentUrlAdhoc"];
        string returnUrl     = System.Configuration.ConfigurationManager.AppSettings["successPaymentUrlAdhoc"];
        string notifyUrl     = System.Configuration.ConfigurationManager.AppSettings["notifyUrlAdhoc"];

        url.Append(m_sPaypalBase);
        url.AppendFormat("&business={0}", HttpUtility.UrlEncode(business));
        url.AppendFormat("&item_name={0}", HttpUtility.UrlEncode("Payment for APAC Effie " + GeneralFunction.EffieEventYear())); // for: " + serials));
        url.AppendFormat("&item_number={0}", HttpUtility.UrlEncode(payGroupId.ToString().Substring(0, 8).ToUpper()));            // suppose to serial num, but there is possiblity of multiple entries per order????

        //decimal amount = GeneralFunction.CalculateGroupTotalPriceFromCache();
        //amount += GeneralFunction.CalculateCreditFees(amount); // Add fees for PP payment
        decimal amount = GeneralFunction.TotalAdhocGrandAmount(payGroupId);

        bool IsTestPay = System.Configuration.ConfigurationManager.AppSettings["IsTestPay"].ToString() == "1";

        if (IsTestPay)
        {
            amount = 0.01m;
        }
        url.AppendFormat("&amount={0}", HttpUtility.UrlEncode(amount.ToString("0.00")));



        // For testing of $0.01
        //url.AppendFormat("&amount={0}", HttpUtility.UrlEncode("0.01"));



        url.AppendFormat("&currency_code={0}", HttpUtility.UrlEncode("SGD"));

        url.AppendFormat("&shipping={0}", HttpUtility.UrlEncode("0"));
        url.AppendFormat("&no_shipping={0}", HttpUtility.UrlEncode("0"));
        url.AppendFormat("&invoice={0}", "");

        string custom = payGroupId.ToString();

        url.AppendFormat("&custom={0}", HttpUtility.UrlEncode(custom));
        url.AppendFormat("&cancel_return={0}", HttpUtility.UrlEncode(cancelUrl));
        url.AppendFormat("&notify_url={0}", HttpUtility.UrlEncode(notifyUrl));
        url.AppendFormat("&return={0}", HttpUtility.UrlEncode(returnUrl + "?custom=" + payGroupId.ToString()));

        RawLog rawlog = RawLog.NewRawLog();

        rawlog.Type       = 0; //send
        rawlog.Data       = url.ToString();
        rawlog.DateString = DateTime.Now.ToString();

        if (rawlog.IsValid)
        {
            rawlog.Save();
        }


        Response.Redirect(url.ToString());
    }