0
我有2個意見,一個名爲PostToPalPal如下和DomainConfirmationView。在DomainConfirmationView上,我有一個鏈接到PostToPayPal的按鈕,然後通過post事件重定向到paypal。我遇到的問題是,當我點擊這個按鈕時,它什麼也不做。我已經在另一個頁面上工作,但是我只在頁面頂部有@model dynamic
,其餘的都是HTML。有沒有人有想法,我錯了?道歉,如果這真的是愚蠢的,這是我第一次去MVC。鏈接之間的意見
感謝
@model application.Models.PayPal
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title>Index</title>
<script src="@Url.Content("~/Scripts/jquery-1.6.2.min.js")" type="text/javascript"></script>
</head>
<body>
<form id="frm" [email protected]>
@Html.HiddenFor(model => model.cmd)
@Html.HiddenFor(model => model.business)
@Html.HiddenFor(model => model.no_shipping)
@Html.HiddenFor(model => [email protected])
@Html.HiddenFor(model => model.cancel_return)
@Html.HiddenFor(model => model.notify_url)
@Html.HiddenFor(model => model.currency_code)
@Html.HiddenFor(model => model.item_name)
@Html.HiddenFor(model => model.amount)
</form>
<p style="text-align: center">
<h4>
<img src="../../Images/New-LogoPNG.png" />
<br />
You are now being redirected to Paypal...</h4>
</p>
</body>
</html>
<script type="text/javascript" language="javascript">
$(this.document).ready(function() {
var frm = $("form");
frm.submit();
});
</script>
DomainConfirmationView
@model Application.Models.DomainCustomerDetails
@using (Html.BeginForm("PostToPayPal", "Home"))
{
<input type ="hidden" name="item" value= ".com"/>
<input type = "hidden" name="amount" value="10" />
}
@{
ViewBag.Title = "Domain order placed";
}
@{
String Input = "Hi" +".<BR /><BR />"
+ "You have a new domain order that has been placed."
+ "<BR /><BR />"
+ "Domain Details"
+ "<BR /><BR />"
+ "Domain name:" + Model.DomainName
+ "<BR /><BR />"
+ "Domain duration " + Model.DomainDuration
+ "<BR /><BR />"
+ "Domain order type" + Model.OrderType
+ "<BR /><BR />"
+ "<BR /><BR />"
+ Model.FirstName
+ "<BR /><BR />"
+ Model.LastName
+ "<BR /><BR />"
+ Model.BusinessName
+ "<BR /><BR />"
+ Model.Address
+ "<BR /><BR />"
+ Model.Address2
+ "<BR /><BR />"
+ Model.PostalCode
+ "<BR /><BR />"
+ Model.EmailAddress
+ "<BR /><BR />"
+ Model.ContactNumber
+ "<BR /><BR />"
+ "<BR /><BR />"
+ "Kind regards"
+ "<BR /><BR />"
+ "xxx"
+ "<BR /><BR />"
+ "Email: [email protected]"
+ "<BR /><BR />";
String Output = Server.HtmlDecode(Input);
WebMail.SmtpServer = "mail.xxx.com";
WebMail.SmtpPort = 25;
WebMail.EnableSsl = false;
WebMail.UserName = "[email protected]";
WebMail.Password = "xxxx";
WebMail.From = "[email protected]";
WebMail.Send("[email protected]", "You have a new domain order " + Model.DomainName,Output);
}
@{
String Inputorder = "Hi " + Model.FirstName
+ "<BR /><BR />"
+ "We are pleased to say your domain name " + Model.DomainName + "has been ordered."
+ "<BR /><BR />"
+ "Domain Details"
+ "<BR /><BR />"
+ Model.DomainName
+ "<BR /><BR />"
+ "Domain duration" + Model.DomainDuration
+ "<BR /><BR />"
+ "What to do next"
+ "<BR /><BR />"
+ "Server IP"
+ "<BR /><BR />"
+"Name Server 1:"
+ "<BR /><BR />"
+"Name Server 2:"
+ "<BR /><BR />"
+"MX:"
+ "<BR /><BR />"
+"A:"
+ "<BR /><BR />"
+"CNAME:"
+ "<BR /><BR />"
+ "PLEASE NOTE"
+ "<BR /><BR />"
+ "Please allow 24 hours for any DNS changes to take effect due to DNS caching by your ISP."
+ "<BR /><BR />"
+ "Many thanks for your order"
+ "<BR /><BR />"
+ "Kind regards"
+ "<BR /><BR />"
+ "xxx"
+ "<BR /><BR />"
+ "Email: [email protected]"
+ "<BR /><BR />";
String Outputorder = Server.HtmlDecode(Inputorder);
WebMail.SmtpServer = "mail.xxx.com";
WebMail.SmtpPort = 25;
WebMail.EnableSsl = false;
WebMail.UserName = "[email protected]";
WebMail.Password = "xxx";
WebMail.From = "[email protected]";
WebMail.Send(Model.EmailAddress, "Your new domain order: " + Model.DomainName,Outputorder);
}
<p>Thank you, almost done</p>
<p>Please click the purchase button to continue</p>
<input type ="submit" name="btsubmit" value= "Purchase"/>
I also have a controller called DomainsController
[HttpPost]
public ActionResult PostToPayPal(string item, string amount)
{
YippeeYay.Models.PayPal paypal = new Models.PayPal();
paypal.cmd = "_xclick";
paypal.business = ConfigurationManager.AppSettings["BusinessAccountKey"];
bool useSandbox = Convert.ToBoolean(ConfigurationManager.AppSettings["UseSandbox"]);
if (useSandbox)
ViewBag.actionURL = "https://www.sandbox.paypal.com/cgi-big/webscr";
else
ViewBag.actionURL = "https://www.paypal.com/cgi-bin/webscr";
paypal.cancel_return = System.Configuration.ConfigurationManager.AppSettings["CancelURL"];
[email protected] = ConfigurationManager.AppSettings["ReturnURL"];
paypal.notify_url = ConfigurationManager.AppSettings["NotifyURL"];
paypal.currency_code = ConfigurationManager.AppSettings["CurrencyCode"];
paypal.item_name = item;
paypal.amount = amount;
return View(paypal);
}
謝謝格雷格,這很好!有一種感覺是簡單的。 – Steve