Beispiel #1
0
        protected void btnOnlinePayment_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                string MerchantCode     = Globals.GATEWAY_MERCHANTCODE;
                string Currency         = "UGX";
                string ItemDesc         = $"Payment For Sale [ {GenerateTransactionIDIfNotExists()} ]";
                string CustomerRef      = Session["CustID"] as string;
                string Amount           = GetItemTotal();
                string Password         = SharedCommons.GenearetHMACSha256Hash(Globals.GATEWAY_SECRET_KEY, Globals.GATEWAY_PASSWORD);
                string ReturnUrl        = Globals.RETURN_URL;
                string VendorCode       = Globals.GATEWAY_VENDORCODE;
                string VendorTranId     = GenerateTransactionIDIfNotExists();
                string datatToSign      = VendorCode + MerchantCode + Amount + ItemDesc + Currency + ReturnUrl + VendorTranId;
                string DigitalSignature = SharedCommons.GenearetHMACSha256Hash(Globals.GATEWAY_SECRET_KEY, datatToSign);
                string RequestData      = "VENDORCODE=" + VendorCode + "&PASSWORD="******"&VENDOR_TRANID=" + VendorTranId + "&ITEM_TOTAL=" + Amount + "&ITEM_DESCRIPTION=" + ItemDesc + "&CURRENCY=" + Currency + "&RETURN_URL=" + ReturnUrl + "&DIGITAL_SIGNATURE=" + DigitalSignature + "&MERCHANTCODE=" + MerchantCode + "&CUSTOMER_REF=" + CustomerRef;
                string URL = Globals.URL_FOR_PEGASUS_PAYMENTS_GATEWAY + "?" + RequestData;
                Response.Redirect(URL);
            }
            catch (Exception ex)
            {
                //display error
                ShowErrorMsg(SharedLogic.INTERNAL_ERROR_MSG);

                //log error
                SharedLogic.TcmpTestCore.LogError($"EXCEPTION:{ex.Message}", $"{this.GetType().Name}-{SharedLogic.GetCurrentMethod()}", "N/A");
            }
        }
Beispiel #2
0
        public override bool IsValid()
        {
            string propertiesThatCanBeNull = $"{nameof(Id)}|{nameof(PaymentNarration)}";
            string nullCheckResult         = SharedCommons.CheckForNulls(this, propertiesThatCanBeNull);

            if (nullCheckResult != SharedCommonsGlobals.SUCCESS_STATUS_TEXT)
            {
                StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                StatusDesc = nullCheckResult;
                return(false);
            }

            Payment duplicatePayment = Payment.QueryWithStoredProc("GetPaymentByPaymentSystemCodeAndID", PaymentId, PaymentSystemCode).FirstOrDefault();

            if (duplicatePayment != null)
            {
                StatusCode = SharedCommonsGlobals.SUCCESS_STATUS_CODE;
                StatusDesc = SharedCommonsGlobals.SUCCESS_STATUS_TEXT;
                return(false);
            }

            PaymentSystem system = PaymentSystem.QueryWithStoredProc("GetPaymentSystemByID", PaymentSystemCode).FirstOrDefault();

            if (system == null)
            {
                StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                StatusDesc = "INVALID PAYMENT SYSTEM CODE OR PASSWORD";
                return(false);
            }

            string hashedPassword = SharedCommons.GenearetHMACSha256Hash(system.SecretKey, Password);

            if (hashedPassword != system.Password)
            {
                StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                StatusDesc = "INVALID PAYMENT SYSTEM CODE OR PASSWORD";
                return(false);
            }

            string dataToSign = PaymentSystemCode + Password + PaymentAmount + PaymentId + PaymentChannel + PayerContact + PayerName;
            string hmacHash   = SharedCommons.GenearetHMACSha256Hash(system.SecretKey, dataToSign);

            if (DigitalSignature != hmacHash)
            {
                StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                StatusDesc = "INVALID DIGITAL SIGNATURE";
                return(false);
            }

            return(base.IsValid());
        }