public ActionResult PayUReq() { if (TempData["Membership"] == null) { return(null); } MembershipModel Membership = (MembershipModel)TempData["Membership"]; PayUModel Model = new PayUModel(Membership.Email, Membership.Type, Membership.EMECI); PayUT PayU = new PayUT(); PayU.AddTransaction(Membership, Model.referenceCode); TempData.Remove("Membership"); return(PartialView(Model)); }
public ActionResult GetConfirmation() { ServiceTracer.Log("Inicia HttpGet confirmacion PayU"); bool IsReserved = false; NameValueCollection q = Request.QueryString; if (q.AllKeys.Length > 0) { ServiceTracer.Log($"Respuesta: {q.ToString()}"); string currency = q["currency"] ?? ""; string polTransactionState = q["polTransactionState"] ?? ""; string polResponseCode = q["polResponseCode"] ?? ""; string referenceCode = q["referenceCode"] ?? ""; string reference_pol = q["reference_pol"] ?? ""; string lapTransactionState = q["lapTransactionState"] ?? ""; string polPaymentMethodType = q["polPaymentMethodType"] ?? ""; string polPaymentMethod = q["polPaymentMethod"] ?? ""; string TX_VALUE = q["TX_VALUE"] ?? ""; string transactionState = q["transactionState"] ?? ""; string signature = q["signature"] ?? ""; string PaymentMethod = string.Empty; if (polPaymentMethodType == "7") { PaymentMethod = "Oxxo||7Eleven"; } else { PaymentMethod = "Pago con tarjeta"; } TX_VALUE = Math.Round(double.Parse(TX_VALUE), 1).ToString("N1").Replace(",", ""); string str = $"{ApiKey}~{MerchantId}~{referenceCode}~{TX_VALUE}~{currency}~{transactionState}"; if (signature == new PayUModel().GetAsignature(str)) { ServiceTracer.Log("Signatura validada"); switch (lapTransactionState.ToLower()) { case "approved": if (polTransactionState == "4" && polResponseCode == "1") { IsReserved = CheckStatusTransaction(referenceCode); if (!IsReserved) { PayUT PayU = new PayUT(); PayU.UpdateTransaction(StatusT.Confirmado, referenceCode, reference_pol, PaymentMethod); IsReserved = true; SendEmail(referenceCode); } } break; case "declined": ServiceTracer.Log("Declinado!"); break; case "error": ServiceTracer.Log("Error!"); break; case "expired": ServiceTracer.Log("Expirado!"); break; case "pending": /* fueron por pago en sucursales, * oxxo, sevel eleven */ if (polTransactionState == "7" || polTransactionState == "14" || polTransactionState == "15") { if (polResponseCode == "15" || polResponseCode == "25" || polResponseCode == "26") { new PayUT().UpdateTransaction(StatusT.Proceso, referenceCode, reference_pol, PaymentMethod); IsReserved = true; SendEmail(referenceCode); } } break; } } else { ServiceTracer.Log($"La signatura no es identica: *string signature: {str}"); } } else { return(Redirect("https://www.emeci.com")); } TempData["PaidOut"] = IsReserved ? StatusT.Confirmado : StatusT.Rechazado; return(RedirectToAction("Membership", "Home")); }