Beispiel #1
0
        public override bool IsValid()
        {
            if (string.IsNullOrEmpty(Email) && string.IsNullOrEmpty(Phone))
            {
                StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                StatusDesc = "Please Supply an Email or Phone Number";
                return(false);
            }

            string propertiesThatCanBeNull = $"{nameof(Id)}|{nameof(Email)}|{nameof(Phone)}";
            string nullCheckResult         = SharedCommons.CheckForNulls(this, propertiesThatCanBeNull);

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

            if (!string.IsNullOrEmpty(Email) && !SharedCommons.IsValidEmail(Email))
            {
                StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                StatusDesc = "Please Supply an valid Email Address";
                return(false);
            }

            if (!string.IsNullOrEmpty(Phone) && !SharedCommons.IsValidUgPhoneNumber(Phone))
            {
                StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                StatusDesc = "Please Supply an valid Phone";
                return(false);
            }

            return(base.IsValid());
        }
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());
        }
Beispiel #3
0
        public override bool IsValid()
        {
            string propertiesThatCanBeNull = $"{nameof(Id)}";
            string nullCheckResult         = SharedCommons.CheckForNulls(this, propertiesThatCanBeNull);

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

            return(base.IsValid());
        }