Javascript Redsys(MVC.net项目)出现问题-不显示付款消息
我在项目中的支付网关有问题。我的意图是集成一个来自web的支付网关。用户按下支付按钮,我的应用程序收集所有数据并显示支付窗口。当用户按下按钮时,应用程序将执行带有AngularJS的功能:Javascript Redsys(MVC.net项目)出现问题-不显示付款消息,javascript,.net,angularjs,model-view-controller,payment-gateway,Javascript,.net,Angularjs,Model View Controller,Payment Gateway,我在项目中的支付网关有问题。我的意图是集成一个来自web的支付网关。用户按下支付按钮,我的应用程序收集所有数据并显示支付窗口。当用户按下按钮时,应用程序将执行带有AngularJS的功能: function CreaPago() { $http({ method: 'POST', url: './PagoTarjeta/CrearPago', data: { v
function CreaPago() {
$http({
method: 'POST',
url: './PagoTarjeta/CrearPago',
data: {
valores: $scope.listadoLineasDeclaracion
}
}).then(function (response) {
$scope.parametros = response.data;
}, function (response) {
$scope.parametros = response.data || 'Request failed';
}).finally(function () {
window.open($scope.parametros);
});
}
一旦进入服务器(PagoTarjetaController.cs),我就收集支付所需的数据,并以html(C#)形式转发到web
在这里,我们返回调用控制器“PagoTarjetaController.cs”(C#)的操作“Cargar”
问题在于,最后显示的窗口如下所示:
我发现,如果我在PagoTarjetaController.cs中的“Cargar()”函数中加上一个等待时间,该应用程序大约90%的时间运行良好
我的问题是如何让应用程序在没有等待时间的情况下工作,以及为什么它不能100%的工作
**[HttpPost]
public string CrearPago(List<DeclaracionLinea> valores)
{
if (valores == null || valores.Count == 0) return string.Empty;
string cadenaConexion = System.Configuration.ConfigurationManager.AppSettings["CadenaDeConexion"];
ControladoraGuardado ctrGuarda = new ControladoraGuardado();
HistoricoPagos hist = new HistoricoPagos();
hist.Correcto = false;
hist.FechaEnvio = DateTime.Now;
hist.Id_Usuario = SoporteConversion.AEntero(System.Web.HttpContext.Current.Session["userid"].ToString());
hist.Id_Declaracion = valores[0].Id_Declaracion;
hist.FechaRespuesta = new DateTime(1900, 1, 1);
hist.Respuesta = string.Empty;
foreach (DeclaracionLinea lin in valores)
{
if (!lin.Pagada)
hist.Importe += lin.Importe;
}
ctrGuarda.GuardaHistoricoPagos(cadenaConexion, hist);
return System.Configuration.ConfigurationManager.AppSettings["urlFinal"] + "/PagoTarjeta/PagoTarjeta?importe=" + hist.Importe + "&pedido=" + hist.Id + "&iddeclaracion=" + hist.Id_Declaracion;
}**
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
<script src="~/Scripts/Controllers/pagoTarjetaController.js"></script>
<div id="login col-12">
<div class="container col-xs-12" ng-controller='pagoTarjetaController'>
<div class="row text-center">
<img src="~/Content/images/genericas/cargando.gif" />
</div>
<div id="login-row" class="row justify-content-center align-items-center">
<div id="login-column" class="col-sm-6 col-md-offset-3 col-sm-offset-3">
<div class="login-box col-sm-12">
<form action="https://sis-t.redsys.es:25443/sis/realizarPago" method="post">
<!--<form action="https://sis.redsys.es/sis/realizarPago" method="post">-->
<input runat="server" type="hidden" id="Ds_SignatureVersion" name="Ds_SignatureVersion" value="@TempData["Ds_SignatureVersion"]" />
<input runat="server" size="100" type="hidden" id="Ds_MerchantParameters" name="Ds_MerchantParameters" value="@TempData["Ds_MerchantParameters"]" />
<input runat="server" type="hidden" size="50" id="Ds_Signature" name="Ds_Signature" value="@TempData["Ds_Signature"]" />
</form>
</div>
</div>
</div>
</div>
</div>
function Cargar() {
$http({
method: 'POST',
url: './PagoTarjeta/Cargar',
data: { importe: valores.importe, pedido: valores.pedido, iddeclaracion : valores.iddeclaracion }
}).then(function (response) {
$scope.status = response.status;
$scope.listado = response.data;
}, function (response) {
$scope.listado = response.data || 'Request failed';
$scope.status = response.status;
}).finally(function () {
setTimeout(document.forms[0].submit(), 2000);
});
}
public void Cargar(string importe, string pedido, string iddeclaracion)
{
string version = "HMAC_SHA256_V1";
// New instance of RedysAPI
RedsysAPI r = new RedsysAPI();
//Parameters. This is an example. Use your own parameters
var fuc = System.Configuration.ConfigurationManager.AppSettings["TPVfuc"];
var terminal = System.Configuration.ConfigurationManager.AppSettings["TPVterminal"];
var currency = "978";
var trans = "0";
//This is the url of SOAP merchant service. This is an example use your own url
// In url is the path of InotificacionSIS.asmx
var url = "";
// OK url
var urlOK = System.Configuration.ConfigurationManager.AppSettings["urlFinal"] + "/PagoTarjeta/PagosOK?pedido=" + pedido.ToString() + "&iddeclaracion=" + iddeclaracion;
// KO url
var urlKO = System.Configuration.ConfigurationManager.AppSettings["urlFinal"] + "/PagoTarjeta/PagosKO?pedido=" + pedido.ToString() + "&iddeclaracion=" + iddeclaracion;
// Generate randomly with Customer's platform
var id = pedido;
// Amount
string amount = RevisarImporte(importe); // ;
// Main Key
var kc = System.Configuration.ConfigurationManager.AppSettings["TPVkc"];
// Fill Ds_MerchantParameters parameters
r.SetParameter("DS_MERCHANT_AMOUNT", amount);
r.SetParameter("DS_MERCHANT_ORDER", id);
r.SetParameter("DS_MERCHANT_MERCHANTCODE", fuc);
r.SetParameter("DS_MERCHANT_CURRENCY", currency);
r.SetParameter("DS_MERCHANT_TRANSACTIONTYPE", trans);
r.SetParameter("DS_MERCHANT_TERMINAL", terminal);
r.SetParameter("DS_MERCHANT_MERCHANTURL", url);
r.SetParameter("DS_MERCHANT_URLOK", urlOK);
r.SetParameter("DS_MERCHANT_URLKO", urlKO);
r.SetParameter("DS_MERCHANT_SUMTOTAL", amount);
// Calculate Ds_SignatureVersion
TempData["Ds_SignatureVersion"] = version;
// Calculate Ds_MerchantParameters
string parms = r.createMerchantParameters();
TempData["Ds_MerchantParameters"] = parms;
// Calculate Ds_Signature
string sig = r.createMerchantSignature(kc);
TempData["Ds_Signature"] = sig;
}
The example with time to wait is(c#):
public void Cargar(string importe, string pedido, string iddeclaracion)
{
System.Threading.Thread.Sleep(12000);
string version = "HMAC_SHA256_V1";
// New instance of RedysAPI
RedsysAPI r = new RedsysAPI();
//Parameters. This is an example. Use your own parameters
// PONER EN EL WEB.CONFIG
var fuc = System.Configuration.ConfigurationManager.AppSettings["TPVfuc"];
var terminal = System.Configuration.ConfigurationManager.AppSettings["TPVterminal"];
var currency = "978";
var trans = "0";
//This is the url of SOAP merchant service. This is an example use your own url
// In url is the path of InotificacionSIS.asmx
var url = "";
// OK url
var urlOK = System.Configuration.ConfigurationManager.AppSettings["urlFinal"] + "/PagoTarjeta/PagosOK?pedido=" + pedido.ToString() + "&iddeclaracion=" + iddeclaracion;
// KO url
var urlKO = System.Configuration.ConfigurationManager.AppSettings["urlFinal"] + "/PagoTarjeta/PagosKO?pedido=" + pedido.ToString() + "&iddeclaracion=" + iddeclaracion;
// Generate randomly with Customer's platform
var id = pedido;
// Amount
System.Threading.Thread.Sleep(2000);
string amount = RevisarImporte(importe); // importe + "00";
// Main Key
var kc = System.Configuration.ConfigurationManager.AppSettings["TPVkc"];
// Fill Ds_MerchantParameters parameters
r.SetParameter("DS_MERCHANT_AMOUNT", amount);
r.SetParameter("DS_MERCHANT_ORDER", id);
r.SetParameter("DS_MERCHANT_MERCHANTCODE", fuc);
r.SetParameter("DS_MERCHANT_CURRENCY", currency);
r.SetParameter("DS_MERCHANT_TRANSACTIONTYPE", trans);
r.SetParameter("DS_MERCHANT_TERMINAL", terminal);
r.SetParameter("DS_MERCHANT_MERCHANTURL", url);
r.SetParameter("DS_MERCHANT_URLOK", urlOK);
r.SetParameter("DS_MERCHANT_URLKO", urlKO);
r.SetParameter("DS_MERCHANT_SUMTOTAL", amount);
// Calculate Ds_SignatureVersion
TempData["Ds_SignatureVersion"] = version;
// Calculate Ds_MerchantParameters
string parms = r.createMerchantParameters();
TempData["Ds_MerchantParameters"] = parms;
// Calculate Ds_Signature
string sig = r.createMerchantSignature(kc);
TempData["Ds_Signature"] = sig;
}