什么会导致我的模型在 HttpWebRequest (Google Chrome) 上突然变为空?
What would cause my model to suddenly go null on an HttpWebRequest (Google Chrome)?
我正在使用 HttpWebRequest
将付款详细信息传达给付款处理商并接收回复。
当封装这个请求的方法被命中时,模型被传入但请求一发生突然变为空。也就是说,这发生在 Google Chrome 中,但我确信这里有更深层次的问题。
我也只在生产服务器上观察到这种行为,但我无法确定它是否在本地主机下调试。
对于那些与支付处理商合作过的人,我使用了类似的方法 post 向 Authorize.Net 付款,没有问题。也许这是一个与信息如何 posted 到另一台服务器以及以何种格式发送有关的问题。
查看模型
public class PaymentModel
{
// --------------------
// Patient Information
// --------------------
[Required(ErrorMessage = "First Name is required")]
public string PatientFirstName { get; set; }
[Required(ErrorMessage = "Last Name is required")]
public string PatientLastName { get; set; }
public bool EmailReceipt { get; set; }
[EmailAddress(ErrorMessage = "A valid email address is required if a receipt is to be emailed")]
public string EmailAddress { get; set; }
[DataType(DataType.Date, ErrorMessage = "A valid Date Of Service is required (mm/dd/yyyy)")]
[Required(ErrorMessage = "A valid Date Of Service is required")]
public DateTime DateOfService { get; set; }
public string BillCode { get; set; }
// Company Specific information
public static string AccountNumberPrefix = "xx";
public static string CompanyAccountNumber = "xxx";
public static string CompanyName = "xxx";
[Required(ErrorMessage = "Account Number is required")]
public string AccountNumber { get; set; }
public string PhoneNumber { get; set; }
// ---------------------
// Payment Information
// ---------------------
[Required(ErrorMessage = "Name on Card is required")]
public string NameOnCard { get; set; }
[Required(ErrorMessage = "Card Billing Address is required")]
public string BillingAddress { get; set; }
[Required(ErrorMessage = "Card Billing Zipcode in required")]
public string BillingZipCode { get; set; }
public string CardType { get; set; }
[Required(ErrorMessage = "A valid Credit Card Number is required")]
public string CardNumber { get; set; }
[Required(ErrorMessage = "CSC/CVN is required")]
public string SecurityCode { get; set; }
public string ExpireMonth { get; set; }
public string ExpireYear { get; set; }
[Required(ErrorMessage = "A valid payment amount is required")]
[RegularExpression(@"^(?=.*\d)\d{0,6}(\.\d{1,2})?$", ErrorMessage = "Invalid format - Allowed: x.xx (Number/Decimal)")]
public string PaymentAmount { get; set; }
// -----------------
// Static Options
// -----------------
// CC Expire Month Options
public static List<SelectListItem> ExpMonthOptions = new List<SelectListItem>()
{
new SelectListItem() {Text="01", Value="01"},
new SelectListItem() {Text="02", Value="02"},
new SelectListItem() {Text="03", Value="03"},
new SelectListItem() {Text="04", Value="04"},
new SelectListItem() {Text="05", Value="05"},
new SelectListItem() {Text="06", Value="06"},
new SelectListItem() {Text="07", Value="07"},
new SelectListItem() {Text="08", Value="08"},
new SelectListItem() {Text="09", Value="09"},
new SelectListItem() {Text="10", Value="10"},
new SelectListItem() {Text="11", Value="11"},
new SelectListItem() {Text="12", Value="12"}
};
// CC Expire Year Options
public static List<SelectListItem> ExpYearOptions = new List<SelectListItem>()
{
new SelectListItem() {Text=DateTime.Now.Year.ToString(), Value=DateTime.Now.Year.ToString()},
new SelectListItem() {Text=DateTime.Now.AddYears(1).ToString("yyyy"), Value=DateTime.Now.AddYears(1).ToString("yyyy")},
new SelectListItem() {Text=DateTime.Now.AddYears(2).ToString("yyyy"), Value=DateTime.Now.AddYears(2).ToString("yyyy")},
new SelectListItem() {Text=DateTime.Now.AddYears(3).ToString("yyyy"), Value=DateTime.Now.AddYears(3).ToString("yyyy")},
new SelectListItem() {Text=DateTime.Now.AddYears(4).ToString("yyyy"), Value=DateTime.Now.AddYears(4).ToString("yyyy")},
new SelectListItem() {Text=DateTime.Now.AddYears(5).ToString("yyyy"), Value=DateTime.Now.AddYears(5).ToString("yyyy")},
new SelectListItem() {Text=DateTime.Now.AddYears(6).ToString("yyyy"), Value=DateTime.Now.AddYears(6).ToString("yyyy")},
new SelectListItem() {Text=DateTime.Now.AddYears(7).ToString("yyyy"), Value=DateTime.Now.AddYears(7).ToString("yyyy")},
new SelectListItem() {Text=DateTime.Now.AddYears(8).ToString("yyyy"), Value=DateTime.Now.AddYears(8).ToString("yyyy")},
new SelectListItem() {Text=DateTime.Now.AddYears(9).ToString("yyyy"), Value=DateTime.Now.AddYears(9).ToString("yyyy")},
new SelectListItem() {Text=DateTime.Now.AddYears(10).ToString("yyyy"), Value=DateTime.Now.AddYears(10).ToString("yyyy")}
};
// ------------------
// Payment Processor
// ------------------
public string referenceNumber { get; set; }
public string processorError { get; set; }
}
控制器
// POST: /Payment/Confirmation
[HttpPost]
public ActionResult Confirmation(string restartBtn, string prevBtn, string nextBtn)
{
try
{
// Get current payment session
PaymentModel paymentSession = GetPayment();
// Return to previous step
if (prevBtn != null)
{
// Ensure there are no false processor errors
paymentSession.processorError = string.Empty;
return View("index", paymentSession);
}
// Proceed to process and next step
if (nextBtn != null)
{
// Initialize Transaction Reference
paymentSession.referenceNumber = PaymentUtilities.GenerateReferenceNumber(15, false);
// Initialize new transaction object for Authorize.Net
MerchantOne merchantName = new MerchantOne(
"xxxx", // User Name
"xxxx" // Password
);
// Perform the transaction and get the response
var response = merchantName.Charge(paymentSession);
// Store the initial response
_repository.InsertTransaction(response);
// Was the payment declined?
if (response.IsError)
{
paymentSession.processorError = response.Message;
return View("index", paymentSession);
}
// Store successful payment details
_repository.InsertPayment(paymentSession, response);
// Did the user elect to receive a receipt?
if (paymentSession.EmailReceipt)
{
// Email receipt
EmailReceipt(paymentSession, response);
}
return View("receipt", paymentSession);
}
// Clear payment session and return to first step
if (restartBtn != null)
{
RemovePayment();
return View("index");
}
}
catch (Exception ex)
{
EmailError(ex);
return View("Error");
}
return View();
}
Class 处理事务(发送 HttpWebRequest
)
public class MerchantOne
{
private readonly string _userName;
private readonly string _password;
// POST URLS
private const string postURL = "https://secure.merchantonegateway.com/api/transact.php?";
private const string testURL = "";
public MerchantOne(string username, string password)
{
_userName = username;
_password = password;
}
public MerchantResponse Charge(PaymentModel paymentSession)
{
// Prepare and assign post values
Dictionary<string, string> postValues = new Dictionary<string, string>();
// Merchant Information
postValues.Add("username", _userName);
postValues.Add("password", _password);
postValues.Add("type", "sale");
// Transaction Information
postValues.Add("orderid", paymentSession.referenceNumber);
postValues.Add("ccnumber", paymentSession.CardNumber);
postValues.Add("ccexp", paymentSession.ExpireMonth + paymentSession.ExpireYear.Substring(2, 2));
postValues.Add("cvv", paymentSession.SecurityCode);
postValues.Add("amount", paymentSession.PaymentAmount.Replace("$", "").Replace(",", "").Trim());
postValues.Add("address1", paymentSession.BillingAddress);
postValues.Add("zip", paymentSession.BillingZipCode);
// Convert the fields into http POST format
String postString = String.Empty;
foreach (KeyValuePair<string, string> postValue in postValues)
{
postString += postValue.Key + "=" + HttpUtility.UrlEncode(postValue.Value) + "&";
}
postString = postString.TrimEnd('&');
// Create an HttpWebRequest object for communication with Merchant One
HttpWebRequest objRequest;
objRequest = (HttpWebRequest)WebRequest.Create(postURL);
objRequest.Method = "POST";
objRequest.ContentLength = postString.Length;
objRequest.ContentType = "application/x-www-form-urlencoded";
// POST the data as stream
StreamWriter streamWriter = null;
streamWriter = new StreamWriter(objRequest.GetRequestStream());
streamWriter.Write(postString);
streamWriter.Close();
// Returned values are returned as a stream, then read into a string
String postResponse;
HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
using (StreamReader responseStream = new StreamReader(objResponse.GetResponseStream()))
{
postResponse = responseStream.ReadToEnd();
responseStream.Close();
}
// Prepare new response object
MerchantResponse response = new MerchantResponse();
// ----------------------------------------------------------------
// Fill response properties with gateway response array indexes
//-----------------------------------------------------------------
response.RawResponseData = postResponse; // Capture the entire response string in raw format
string[] responseArray = postResponse.Split('&');
response.MOresponse = responseArray[0].Split('=')[1];
response.MOresponseText = responseArray[1].Split('=')[1];
response.MOauthCode = responseArray[2].Split('=')[1];
response.MOtransactionId = responseArray[3].Split('=')[1];
response.MOavsResponse = responseArray[4].Split('=')[1];
response.MOcvvResponse = responseArray[5].Split('=')[1];
response.MOorderId = responseArray[6].Split('=')[1];
response.MOtype = responseArray[7].Split('=')[1];
response.MOresponse_Code = responseArray[8].Split('=')[1];
// Add payment method to response based on CC number
response.MOpaymentType = ResponsePaymentTypePerCC(paymentSession.CardNumber);
// Add name on card from payment field for transaction storage
response.MOnameOnCard = paymentSession.NameOnCard;
// Add Transaction Amount from payment field for transaction storage
response.MOtransactionAmt = paymentSession.PaymentAmount.Replace("$", "").Replace(",", "").Trim();
// Transaction result
response.IsTransactionApproved = response.MOresponse == "1"; // Transaction Approved?
response.IsError = response.MOresponse != "1"; // Transaction Failed (i.e. Declined)?
response.Message = ResponseReasonPerCode(response.MOresponse_Code, response.MOresponseText); // Reason for response
// Return response object
return response;
}
private string ResponseReasonPerCode(string responseCode, string responseText)
{
string responseReason;
switch (responseCode)
{
case "200":
responseReason = "Transaction was declined by processor.";
break;
case "201":
responseReason = "Transaction denied. Do not honor.";
break;
case "202":
responseReason = "Insufficient Funds.";
break;
case "203":
responseReason = "Over Limit.";
break;
case "204":
responseReason = "Transaction not allowed.";
break;
case "220":
responseReason = "Incorrect payment data.";
break;
case "221":
responseReason = "No such card issuer.";
break;
case "222":
responseReason = "No such card number on file with issuer.";
break;
case "223":
responseReason = "Card has expired.";
break;
case "224":
responseReason = "Invalid expiration date.";
break;
case "225":
responseReason = "Invalid card security code (CVV).";
break;
case "240":
responseReason = "Call issuer for further information.";
break;
case "250":
responseReason = "Pick up card.";
break;
case "251":
responseReason = "Lost card.";
break;
case "252":
responseReason = "Stolen card.";
break;
case "253":
responseReason = "Fraudulent card.";
break;
case "260":
responseReason = "Transaction declined (260): " + responseText;
break;
case "430":
responseReason = "Duplicate transaction.";
break;
default:
responseReason = "Unable to process payment. Error code " + responseText;
break;
}
return responseReason;
}
private string ResponsePaymentTypePerCC(string ccNumber)
{
string paymentType = string.Empty;
switch (ccNumber.Trim().Substring(0, 1))
{
case "3":
paymentType = "AMEX";
break;
case "4":
paymentType = "VISA";
break;
case "5":
paymentType = "MC";
break;
case "6":
paymentType = "DISC";
break;
}
return paymentType;
}
}
错误信息是这样的..
System.NullReferenceException: Object reference not set to an instance of an object. at namespace.MerchantOne.Charge(PaymentModel paymentSession) at namespace.Controllers.PaymentController.Confirmation(String restartBtn, String prevBtn, String nextBtn)
老实说,这可能是另一个对象变为 null 或未被初始化,但现在,我能想到的是我的 PaymentModel
在使用后丢失了。
感谢任何帮助。
我遇到了类似的问题。我从 paypal 收到购物车物品和其他金额的无效回复。原来在收到响应时我使用的是 IP 地址,但在发送请求时我使用的是本地主机。你能检查一下这是否是问题所在吗?
所以,事实证明……Chrome 浏览器有些愚蠢。
我整天都在为此苦思冥想。我的代码没问题,服务器上的会话设置没问题。
404 未在 woff/woff2 个文件中找到。我在我的项目中使用了 font-awesome,它正在寻找的两个资源抛出了 404/not found,这正在杀死我的 asp.net 会话。
终于解决了我的问题...将 .woff 和 .woff2 MIME 类型添加到我的服务器。
Why is @font-face throwing a 404 error on woff files?
感谢所有试图提供帮助的人。
我正在使用 HttpWebRequest
将付款详细信息传达给付款处理商并接收回复。
当封装这个请求的方法被命中时,模型被传入但请求一发生突然变为空。也就是说,这发生在 Google Chrome 中,但我确信这里有更深层次的问题。
我也只在生产服务器上观察到这种行为,但我无法确定它是否在本地主机下调试。
对于那些与支付处理商合作过的人,我使用了类似的方法 post 向 Authorize.Net 付款,没有问题。也许这是一个与信息如何 posted 到另一台服务器以及以何种格式发送有关的问题。
查看模型
public class PaymentModel
{
// --------------------
// Patient Information
// --------------------
[Required(ErrorMessage = "First Name is required")]
public string PatientFirstName { get; set; }
[Required(ErrorMessage = "Last Name is required")]
public string PatientLastName { get; set; }
public bool EmailReceipt { get; set; }
[EmailAddress(ErrorMessage = "A valid email address is required if a receipt is to be emailed")]
public string EmailAddress { get; set; }
[DataType(DataType.Date, ErrorMessage = "A valid Date Of Service is required (mm/dd/yyyy)")]
[Required(ErrorMessage = "A valid Date Of Service is required")]
public DateTime DateOfService { get; set; }
public string BillCode { get; set; }
// Company Specific information
public static string AccountNumberPrefix = "xx";
public static string CompanyAccountNumber = "xxx";
public static string CompanyName = "xxx";
[Required(ErrorMessage = "Account Number is required")]
public string AccountNumber { get; set; }
public string PhoneNumber { get; set; }
// ---------------------
// Payment Information
// ---------------------
[Required(ErrorMessage = "Name on Card is required")]
public string NameOnCard { get; set; }
[Required(ErrorMessage = "Card Billing Address is required")]
public string BillingAddress { get; set; }
[Required(ErrorMessage = "Card Billing Zipcode in required")]
public string BillingZipCode { get; set; }
public string CardType { get; set; }
[Required(ErrorMessage = "A valid Credit Card Number is required")]
public string CardNumber { get; set; }
[Required(ErrorMessage = "CSC/CVN is required")]
public string SecurityCode { get; set; }
public string ExpireMonth { get; set; }
public string ExpireYear { get; set; }
[Required(ErrorMessage = "A valid payment amount is required")]
[RegularExpression(@"^(?=.*\d)\d{0,6}(\.\d{1,2})?$", ErrorMessage = "Invalid format - Allowed: x.xx (Number/Decimal)")]
public string PaymentAmount { get; set; }
// -----------------
// Static Options
// -----------------
// CC Expire Month Options
public static List<SelectListItem> ExpMonthOptions = new List<SelectListItem>()
{
new SelectListItem() {Text="01", Value="01"},
new SelectListItem() {Text="02", Value="02"},
new SelectListItem() {Text="03", Value="03"},
new SelectListItem() {Text="04", Value="04"},
new SelectListItem() {Text="05", Value="05"},
new SelectListItem() {Text="06", Value="06"},
new SelectListItem() {Text="07", Value="07"},
new SelectListItem() {Text="08", Value="08"},
new SelectListItem() {Text="09", Value="09"},
new SelectListItem() {Text="10", Value="10"},
new SelectListItem() {Text="11", Value="11"},
new SelectListItem() {Text="12", Value="12"}
};
// CC Expire Year Options
public static List<SelectListItem> ExpYearOptions = new List<SelectListItem>()
{
new SelectListItem() {Text=DateTime.Now.Year.ToString(), Value=DateTime.Now.Year.ToString()},
new SelectListItem() {Text=DateTime.Now.AddYears(1).ToString("yyyy"), Value=DateTime.Now.AddYears(1).ToString("yyyy")},
new SelectListItem() {Text=DateTime.Now.AddYears(2).ToString("yyyy"), Value=DateTime.Now.AddYears(2).ToString("yyyy")},
new SelectListItem() {Text=DateTime.Now.AddYears(3).ToString("yyyy"), Value=DateTime.Now.AddYears(3).ToString("yyyy")},
new SelectListItem() {Text=DateTime.Now.AddYears(4).ToString("yyyy"), Value=DateTime.Now.AddYears(4).ToString("yyyy")},
new SelectListItem() {Text=DateTime.Now.AddYears(5).ToString("yyyy"), Value=DateTime.Now.AddYears(5).ToString("yyyy")},
new SelectListItem() {Text=DateTime.Now.AddYears(6).ToString("yyyy"), Value=DateTime.Now.AddYears(6).ToString("yyyy")},
new SelectListItem() {Text=DateTime.Now.AddYears(7).ToString("yyyy"), Value=DateTime.Now.AddYears(7).ToString("yyyy")},
new SelectListItem() {Text=DateTime.Now.AddYears(8).ToString("yyyy"), Value=DateTime.Now.AddYears(8).ToString("yyyy")},
new SelectListItem() {Text=DateTime.Now.AddYears(9).ToString("yyyy"), Value=DateTime.Now.AddYears(9).ToString("yyyy")},
new SelectListItem() {Text=DateTime.Now.AddYears(10).ToString("yyyy"), Value=DateTime.Now.AddYears(10).ToString("yyyy")}
};
// ------------------
// Payment Processor
// ------------------
public string referenceNumber { get; set; }
public string processorError { get; set; }
}
控制器
// POST: /Payment/Confirmation
[HttpPost]
public ActionResult Confirmation(string restartBtn, string prevBtn, string nextBtn)
{
try
{
// Get current payment session
PaymentModel paymentSession = GetPayment();
// Return to previous step
if (prevBtn != null)
{
// Ensure there are no false processor errors
paymentSession.processorError = string.Empty;
return View("index", paymentSession);
}
// Proceed to process and next step
if (nextBtn != null)
{
// Initialize Transaction Reference
paymentSession.referenceNumber = PaymentUtilities.GenerateReferenceNumber(15, false);
// Initialize new transaction object for Authorize.Net
MerchantOne merchantName = new MerchantOne(
"xxxx", // User Name
"xxxx" // Password
);
// Perform the transaction and get the response
var response = merchantName.Charge(paymentSession);
// Store the initial response
_repository.InsertTransaction(response);
// Was the payment declined?
if (response.IsError)
{
paymentSession.processorError = response.Message;
return View("index", paymentSession);
}
// Store successful payment details
_repository.InsertPayment(paymentSession, response);
// Did the user elect to receive a receipt?
if (paymentSession.EmailReceipt)
{
// Email receipt
EmailReceipt(paymentSession, response);
}
return View("receipt", paymentSession);
}
// Clear payment session and return to first step
if (restartBtn != null)
{
RemovePayment();
return View("index");
}
}
catch (Exception ex)
{
EmailError(ex);
return View("Error");
}
return View();
}
Class 处理事务(发送 HttpWebRequest
)
public class MerchantOne
{
private readonly string _userName;
private readonly string _password;
// POST URLS
private const string postURL = "https://secure.merchantonegateway.com/api/transact.php?";
private const string testURL = "";
public MerchantOne(string username, string password)
{
_userName = username;
_password = password;
}
public MerchantResponse Charge(PaymentModel paymentSession)
{
// Prepare and assign post values
Dictionary<string, string> postValues = new Dictionary<string, string>();
// Merchant Information
postValues.Add("username", _userName);
postValues.Add("password", _password);
postValues.Add("type", "sale");
// Transaction Information
postValues.Add("orderid", paymentSession.referenceNumber);
postValues.Add("ccnumber", paymentSession.CardNumber);
postValues.Add("ccexp", paymentSession.ExpireMonth + paymentSession.ExpireYear.Substring(2, 2));
postValues.Add("cvv", paymentSession.SecurityCode);
postValues.Add("amount", paymentSession.PaymentAmount.Replace("$", "").Replace(",", "").Trim());
postValues.Add("address1", paymentSession.BillingAddress);
postValues.Add("zip", paymentSession.BillingZipCode);
// Convert the fields into http POST format
String postString = String.Empty;
foreach (KeyValuePair<string, string> postValue in postValues)
{
postString += postValue.Key + "=" + HttpUtility.UrlEncode(postValue.Value) + "&";
}
postString = postString.TrimEnd('&');
// Create an HttpWebRequest object for communication with Merchant One
HttpWebRequest objRequest;
objRequest = (HttpWebRequest)WebRequest.Create(postURL);
objRequest.Method = "POST";
objRequest.ContentLength = postString.Length;
objRequest.ContentType = "application/x-www-form-urlencoded";
// POST the data as stream
StreamWriter streamWriter = null;
streamWriter = new StreamWriter(objRequest.GetRequestStream());
streamWriter.Write(postString);
streamWriter.Close();
// Returned values are returned as a stream, then read into a string
String postResponse;
HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
using (StreamReader responseStream = new StreamReader(objResponse.GetResponseStream()))
{
postResponse = responseStream.ReadToEnd();
responseStream.Close();
}
// Prepare new response object
MerchantResponse response = new MerchantResponse();
// ----------------------------------------------------------------
// Fill response properties with gateway response array indexes
//-----------------------------------------------------------------
response.RawResponseData = postResponse; // Capture the entire response string in raw format
string[] responseArray = postResponse.Split('&');
response.MOresponse = responseArray[0].Split('=')[1];
response.MOresponseText = responseArray[1].Split('=')[1];
response.MOauthCode = responseArray[2].Split('=')[1];
response.MOtransactionId = responseArray[3].Split('=')[1];
response.MOavsResponse = responseArray[4].Split('=')[1];
response.MOcvvResponse = responseArray[5].Split('=')[1];
response.MOorderId = responseArray[6].Split('=')[1];
response.MOtype = responseArray[7].Split('=')[1];
response.MOresponse_Code = responseArray[8].Split('=')[1];
// Add payment method to response based on CC number
response.MOpaymentType = ResponsePaymentTypePerCC(paymentSession.CardNumber);
// Add name on card from payment field for transaction storage
response.MOnameOnCard = paymentSession.NameOnCard;
// Add Transaction Amount from payment field for transaction storage
response.MOtransactionAmt = paymentSession.PaymentAmount.Replace("$", "").Replace(",", "").Trim();
// Transaction result
response.IsTransactionApproved = response.MOresponse == "1"; // Transaction Approved?
response.IsError = response.MOresponse != "1"; // Transaction Failed (i.e. Declined)?
response.Message = ResponseReasonPerCode(response.MOresponse_Code, response.MOresponseText); // Reason for response
// Return response object
return response;
}
private string ResponseReasonPerCode(string responseCode, string responseText)
{
string responseReason;
switch (responseCode)
{
case "200":
responseReason = "Transaction was declined by processor.";
break;
case "201":
responseReason = "Transaction denied. Do not honor.";
break;
case "202":
responseReason = "Insufficient Funds.";
break;
case "203":
responseReason = "Over Limit.";
break;
case "204":
responseReason = "Transaction not allowed.";
break;
case "220":
responseReason = "Incorrect payment data.";
break;
case "221":
responseReason = "No such card issuer.";
break;
case "222":
responseReason = "No such card number on file with issuer.";
break;
case "223":
responseReason = "Card has expired.";
break;
case "224":
responseReason = "Invalid expiration date.";
break;
case "225":
responseReason = "Invalid card security code (CVV).";
break;
case "240":
responseReason = "Call issuer for further information.";
break;
case "250":
responseReason = "Pick up card.";
break;
case "251":
responseReason = "Lost card.";
break;
case "252":
responseReason = "Stolen card.";
break;
case "253":
responseReason = "Fraudulent card.";
break;
case "260":
responseReason = "Transaction declined (260): " + responseText;
break;
case "430":
responseReason = "Duplicate transaction.";
break;
default:
responseReason = "Unable to process payment. Error code " + responseText;
break;
}
return responseReason;
}
private string ResponsePaymentTypePerCC(string ccNumber)
{
string paymentType = string.Empty;
switch (ccNumber.Trim().Substring(0, 1))
{
case "3":
paymentType = "AMEX";
break;
case "4":
paymentType = "VISA";
break;
case "5":
paymentType = "MC";
break;
case "6":
paymentType = "DISC";
break;
}
return paymentType;
}
}
错误信息是这样的..
System.NullReferenceException: Object reference not set to an instance of an object. at namespace.MerchantOne.Charge(PaymentModel paymentSession) at namespace.Controllers.PaymentController.Confirmation(String restartBtn, String prevBtn, String nextBtn)
老实说,这可能是另一个对象变为 null 或未被初始化,但现在,我能想到的是我的 PaymentModel
在使用后丢失了。
感谢任何帮助。
我遇到了类似的问题。我从 paypal 收到购物车物品和其他金额的无效回复。原来在收到响应时我使用的是 IP 地址,但在发送请求时我使用的是本地主机。你能检查一下这是否是问题所在吗?
所以,事实证明……Chrome 浏览器有些愚蠢。 我整天都在为此苦思冥想。我的代码没问题,服务器上的会话设置没问题。
404 未在 woff/woff2 个文件中找到。我在我的项目中使用了 font-awesome,它正在寻找的两个资源抛出了 404/not found,这正在杀死我的 asp.net 会话。
终于解决了我的问题...将 .woff 和 .woff2 MIME 类型添加到我的服务器。
Why is @font-face throwing a 404 error on woff files?
感谢所有试图提供帮助的人。