Ejemplo n.º 1
0
        public IActionResult OnceOff()
        {
            TempData["Product"] = TempData["Product"];
            TempData["Price"]   = TempData["Price"];
            TempData["NoxID"]   = TempData["NoxID"];
            TempData["Name"]    = TempData["Name"];
            TempData.Keep();
            var onceOffRequest = new PayFastRequest(this.payFastSettings.PassPhrase);

            // Merchant Details
            onceOffRequest.merchant_id  = this.payFastSettings.MerchantId;
            onceOffRequest.merchant_key = this.payFastSettings.MerchantKey;
            onceOffRequest.return_url   = this.payFastSettings.ReturnUrl;
            onceOffRequest.cancel_url   = this.payFastSettings.CancelUrl;
            onceOffRequest.notify_url   = this.payFastSettings.NotifyUrl;

            // Buyer Details
            //onceOffRequest.email_address = "*****@*****.**";

            // Transaction Details
            onceOffRequest.m_payment_id     = repo.GenerateCustomerPaymentID((int)TempData["CustomerID"]);
            onceOffRequest.amount           = Convert.ToDouble(TempData["Price"]);
            onceOffRequest.item_name        = TempData["Product"].ToString();
            onceOffRequest.item_description = "Once off payment for " + TempData["Name"] + TempData["Product"];
            // Transaction Options
            //onceOffRequest.email_confirmation = true;
            //onceOffRequest.confirmation_address = "*****@*****.**";

            StringBuilder str = new StringBuilder();

            str.Append("merchant_id=" + HttpUtility.UrlEncode(onceOffRequest.merchant_id));
            str.Append("&merchant_key=" + HttpUtility.UrlEncode(onceOffRequest.merchant_key));
            str.Append("&return_url=" + HttpUtility.UrlEncode(onceOffRequest.return_url));
            str.Append("&cancel_url=" + HttpUtility.UrlEncode(onceOffRequest.cancel_url));
            str.Append("&notify_url=" + HttpUtility.UrlEncode(onceOffRequest.notify_url));

            str.Append("&m_payment_id=" + HttpUtility.UrlEncode(onceOffRequest.m_payment_id));
            str.Append("&amount=" + HttpUtility.UrlEncode(onceOffRequest.amount.ToString("G", CultureInfo.InvariantCulture)));
            str.Append("&item_name=" + HttpUtility.UrlEncode(onceOffRequest.item_name));
            str.Append("&item_description=" + HttpUtility.UrlEncode(onceOffRequest.item_description));
            var redirectUrl = $"{this.payFastSettings.ProcessUrl}{str.ToString()}";

            return(Redirect(redirectUrl));
        }