コード例 #1
0
ファイル: PayeerHandler.cs プロジェクト: dovanduy/titan
        protected void CheckIncomeHash()
        {
            List <PayeerAccountDetails> gateWays = TableHelper.SelectRows <PayeerAccountDetails>(TableHelper.MakeDictionary("IsActive", true));

            bool isOk = false;

            foreach (var gateway in gateWays)
            {
                try
                {
                    string toHash = TransactionID + ":" + PaymentMethod + ":" + context.Request["m_operation_date"] + ":" + context.Request["m_operation_pay_date"]
                                    + ":" + MerchantAccount + ":" + OrderID + ":" + Amount + ":" + Currency + ":" + Args + ":" + Status + ":"
                                    + gateway.SecretKey;

                    string hash = HashingManager.SHA256(toHash).ToUpper();

                    CheckHash(SentHash, hash);
                    isOk = true;
                }
                catch (Exception ex) { }
            }

            //if (!isOk)
            //    throw new MsgException("Bad income hash");
        }
コード例 #2
0
        protected override string generate(string itemName, Money amount, string command, object[] args)
        {
            NVPStringBuilder nvps = new NVPStringBuilder();

            string orderId = HashingManager.GenerateMD5(AppSettings.Site.Name + DateTime.Now).ToLower();

            orderId = orderId.Substring(0, Math.Min(orderId.Length, 31));

            string description = command + "#" + String.Join(ArgsDelimeter + "", args);

            description = itemName + " **" + description;

            string toHash = account.MerchantID + ":" + orderId + ":" + amount.ToShortClearString() + ":" + AppSettings.Site.CurrencyCode
                            + ":" + HashingManager.Base64Encode(description) + ":" + account.SecretKey;
            string hash = HashingManager.SHA256(toHash).ToUpper();

            nvps.Append("m_shop", account.MerchantID)
            .Append("m_orderid", orderId)
            .Append("m_amount", amount.ToShortClearString())
            .Append("m_curr", AppSettings.Site.CurrencyCode)
            .Append("m_desc", HashingManager.Base64Encode(description))
            .Append("m_sign", hash);

            return(HandlerUrl + '?' + nvps.Build());
        }
コード例 #3
0
        /// <summary>
        /// Creates some general payza button
        /// </summary>
        /// <param name="itemName">Name describing the item or service. Max Length: 50 characters</param>
        /// <param name="amount">The price or cost of the product or service. The value for
        /// amount must be positive. Null or negative numbers are not allowed.</param>
        /// <param name="command">Describes how handler should handle IPN request.
        /// Stored in field apc_1. Max Length: 100 characters</param>
        /// <param name="args">
        /// Custom values you can pass along with the payment button.
        /// The values are not displayed to the payer on our Pay Process page.
        /// Payza returns these fields back in the IPN.
        /// Used by IIpnHandler ('command')
        /// Stored in fields apc_2 - apc_6. Max Length: 100 characters
        /// </param>
        /// <returns>Http address where member should be redirected after clicking button.</returns>
        protected override string generate(string itemName, Money amount, string command, object[] args)
        {
            string orderId = HashingManager.GenerateMD5(AppSettings.Site.Name + DateTime.Now).ToLower();

            string signature = String.Format("{0}:{1}:{2}:{3}:{4}:{5}", account.AccountEmail,
                                             account.SCIName, amount.ToShortClearString(), AppSettings.Site.CurrencyCode,
                                             AdvCashAccount.APIPassword, orderId);

            signature = HashingManager.SHA256(signature).ToLower();

            NVPStringBuilder nvps = new NVPStringBuilder();

            nvps.Append("ac_account_email", account.AccountEmail)
            .Append("ac_sci_name", account.SCIName)
            .Append("ac_comments", itemName.Substring(0, Math.Min(itemName.Length, ItemNameMaxLength)))
            .Append("ac_amount", amount.ToShortClearString())
            .Append("ac_currency", AppSettings.Site.CurrencyCode)

            .Append("ac_status_url", AppSettings.Site.Url + "Handlers/Payment/AdvCash.ashx")
            .Append("ac_success_url ", ButtonGenerationStrategy.SUCCESS_URL)
            .Append("ac_fail_url", ButtonGenerationStrategy.FAILURE_URL)

            .Append("ac_sign", signature)
            .Append("ac_order_id", orderId)
            .Append("acm_command", command)
            .Append("acm_args", String.Join(ArgsDelimeter + "", args));

            return(Handler + '?' + nvps.Build());
        }
コード例 #4
0
        protected void CheckIncomeHash()
        {
            string toHash = TransactionID + ":" + context.Request.QueryString["ac_start_date"] + ":" + context.Request.QueryString["ac_sci_name"] +
                            ":" + context.Request.QueryString["ac_src_wallet"]
                            + ":" + MerchantAccount + ":" + OrderID + ":" + context.Request.QueryString["ac_amount"] + ":" + Currency + ":" + AdvCashAccount.APIPassword;

            string hash = HashingManager.SHA256(toHash);

            CheckHash(SentHash, hash);
        }
コード例 #5
0
ファイル: AdzbuzzOAuth.cs プロジェクト: dovanduy/titan
        public static void CreateRedirect()
        {
            string key = HashingManager.SHA256(DateTime.Now + AppSettings.Offerwalls.UniversalHandlerPassword + SessionStateKey).ToLower();

            HttpContext.Current.Session[SessionStateKey] = key;

            var systemRedirectUri = GetRedirectUrl(key);

            HttpContext.Current.Response.Redirect(systemRedirectUri);
        }
コード例 #6
0
ファイル: AdvCashAccount.cs プロジェクト: dovanduy/titan
        private authDTO getAuthDTO()
        {
            authDTO dto = new authDTO();

            dto.apiName = accountDetails.APIName;
            DateTime UtcNow = DateTime.UtcNow;

            dto.authenticationToken = HashingManager.SHA256(AdvCashAccount.APIPassword + ":" + UtcNow.ToString("yyyyMMdd") + ":" + UtcNow.ToString("HH"));
            dto.accountEmail        = accountDetails.AccountEmail;

            return(dto);
        }
コード例 #7
0
ファイル: ApiAccessToken.cs プロジェクト: dovanduy/titan
    public static ApiAccessToken GetOrCreate(int userId)
    {
        var tokens = TableHelper.GetListFromRawQuery <ApiAccessToken>(String.Format(
                                                                          "SELECT * FROM ApiAccessTokens WHERE UserId = {0} AND ExpiresDate >= '{1}'", userId, AppSettings.ServerTime.ToDBString()));

        ApiAccessToken result = null;

        if (tokens.Count > 0)
        {
            result = tokens[0];
        }
        else
        {
            result             = new ApiAccessToken();
            result.UserId      = userId;
            result.ExpiresDate = DateTime.Now.AddDays(7);
            result.Token       = HashingManager.SHA512HMAC(HashingManager.GenerateMD5(userId + DateTime.Now.ToString()),
                                                           HashingManager.SHA256(AppSettings.Offerwalls.UniversalHandlerPassword + userId + DateTime.Now));
            result.Save();
        }

        return(result);
    }
コード例 #8
0
ファイル: CustomFile.cs プロジェクト: dovanduy/titan
        //Method return MsgException
        public void SaveOnClient(string fileName, string filePath)

        {
            if (_Stream == null)
            {
                throw new ArgumentNullException();
            }

            using (var client = new WebClient())
            {
                var values = new NameValueCollection();
                values["p"]  = HashingManager.SHA256(AppSettings.Offerwalls.UniversalHandlerPassword);
                values["fn"] = HttpUtility.UrlEncode(fileName);
                values["fp"] = HttpUtility.UrlEncode(filePath);
                values["h"]  = HttpUtility.UrlEncode(Serialize());

                //Send request to proper handler
                string urlPost = AppSettings.Site.Url + "Handlers/CustomFileCreator.ashx";

                try
                {
                    var    response       = client.UploadValues(urlPost, values);
                    string responseString = Encoding.Default.GetString(response);

                    if (responseString != OfferwallFileManager.RESPONSE_OK_CODE)
                    {
                        throw new MsgException(responseString);
                    }

                    Path = filePath + fileName;
                }
                catch (Exception ex)
                {
                    throw new MsgException(ex.Message);
                }
            }
        }
コード例 #9
0
        private string buildTransactionRequestString(TransactionRequest request, ref string queryString)
        {
            string transactionID = HashingManager.GenerateMD5(DateTime.Now + request.MemberName + AppSettings.Offerwalls.UniversalHandlerPassword);

            var arrayToHash = new string[] { accountDetails.APIKey, accountDetails.APISecret, "json", accountDetails.LocationId.ToString(), "live" };
            var DataToHash  = String.Join(".", arrayToHash);
            var user        = new Member(request.MemberName);

            string hash = HashingManager.SHA256(DataToHash).ToLower();

            //We need to convert money from our currency to KES
            var moneyToBeSent = CurrencyExchangeHelper.Calculate(request.Payment, "KES");

            queryString = String.Format("format=json&api_key={0}&hash={1}&location_id={2}&mode=live",
                                        accountDetails.APIKey, hash, accountDetails.LocationId.ToString());

            return(new NVPStringBuilder()
                   .Append("format", "json")
                   .Append("api_key", accountDetails.APIKey)
                   .Append("hash", hash)
                   .Append("location_id", accountDetails.LocationId)
                   .Append("mode", "live")
                   .Append("beneficiaries[0][gateway]", "mpesa")
                   .Append("beneficiaries[0][phone]", request.PayeeId)
                   .Append("beneficiaries[0][trans_reference]", transactionID)
                   .Append("beneficiaries[0][description]", request.Note)
                   .Append("beneficiaries[0][first_name]", user.FirstName)
                   .Append("beneficiaries[0][last_name]", user.SecondName)
                   .Append("beneficiaries[0][amount]", moneyToBeSent.ToShortClearString())
                   .Append("beneficiaries[0][callback_url]", AppSettings.Site.Url + "Handlers/Payment/MPesaSapamaX.ashx")
                   .Append("beneficiaries[0][callback_http_method]", "GET")
                   .Append("beneficiaries[0][message]", HttpUtility.UrlEncode(AppSettings.Payments.TransactionNote))
                   .Append("beneficiaries[0][short_code]", accountDetails.Username)
                   .Append("beneficiaries[0][currency]", "KES")
                   .Build());
        }
コード例 #10
0
ファイル: MarketplaceIPN.cs プロジェクト: dovanduy/titan
        string CreateHash()
        {
            string input = AppSettings.Offerwalls.UniversalHandlerPassword + ((int)AppSettings.ServerTime.Subtract(new DateTime(1970, 1, 1)).TotalSeconds).ToString();

            return(HashingManager.SHA256(input));
        }