public MakeValidateIpnContentRequest ( string content ) : PaysonIntegration.Response.ValidateResponse | ||
content | string | |
return | PaysonIntegration.Response.ValidateResponse |
public ActionResult IPN(string orderGuid) { Request.InputStream.Position = 0; var content = new StreamReader(Request.InputStream).ReadToEnd(); var state = repository.GetPurchaseState(orderGuid); if (state != null) { var api = new PaysonApi(state.UserId, state.UserKey, ApplicationId, true); var response = api.MakeValidateIpnContentRequest(content); if (response.Success) { var status = response.ProcessedIpnMessage.PaymentStatus.HasValue ? response.ProcessedIpnMessage.PaymentStatus.ToString() : "N/A"; state.Updates[DateTime.Now] = "IPN: " + status; state.LatestStatus = status; } else { state.Updates[DateTime.Now] = "IPN: IPN Failure"; state.LatestStatus = "Failure"; } } return new EmptyResult(); }
public ActionResult IPN(string regId) { log.Debug("IPN regId: " + regId); int regIdInt = -1; int.TryParse(regId, out regIdInt); var registration = db.Registreringar.FirstOrDefault(regg => regg.ID == regIdInt); if (registration != null) { Request.InputStream.Position = 0; var content = new StreamReader(Request.InputStream).ReadToEnd(); var api = new PaysonApi(CheckoutModel.PaysonUserId, CheckoutModel.PaysonUserKey, ApplicationId, true); var response = api.MakeValidateIpnContentRequest(content); var statusText = response.ProcessedIpnMessage.PaymentStatus.HasValue ? response.ProcessedIpnMessage.PaymentStatus.ToString() : "N/A"; var status = response.ProcessedIpnMessage.PaymentStatus; log.Debug("IPN message content: " + response.Content); log.Debug("IPN raw response: " + content); if (status == PaymentStatus.Completed || status == PaymentStatus.Completed) { log.Debug("IPN message, status: " + statusText + ". regId: " + regId + " success: " + response.Success); if (!registration.HarBetalt) { SetAsPaid(registration); } } else { log.Debug("IPN message for non complete transaction. regId: " + regId + ". Status: " + statusText); } } else { log.Error("Got IPN with wrong regId as query parameter: " + regId); SendMail.SendErrorMessage("Got IPN with wrong regId as query parameter: " + regId); } return new EmptyResult(); }