令牌已被使用,conekta

The token has already been used, conekta

我在充电时遇到问题,这显示了这个错误:

"The token has already been used" "La tarjeta no pudo ser procesada"

当我使用测试令牌执行此操作时,效果很好,但当我使用另一个令牌执行此操作时,它不起作用,这是我的实现。

 bool band = true;
            Order order;

            Expression<Func<Usuario, bool>> exp = (x) => x.IdUsuario == IdUsuario;
            UsuarioLoader uLoader = new UsuarioLoader();
            var usuario = uLoader.GetElementByProperty(exp);
            try
            {

                order = new conekta.Order().create(@"{
                  ""currency"":""MXN"",
                  ""customer_info"": {
                    ""customer_id"": """+usuario.TokenConekta+@""" 
                  },
                  ""line_items"": [{
                    ""name"": ""Cobro Union"",
                    ""unit_price"": 1000,
                    ""quantity"": 1
                  }],
                  ""charges"": [{
                    ""payment_method"": {
                       ""type"": ""card"",
                        ""token_id"": """+tokenTarjeta+@"""
                    },""amount"":1000
                  }]
                }");

            }
            catch (ConektaException e)
            {
                band = false;
                foreach (JObject obj in e.details)
                {
                    System.Console.WriteLine("\n [ERROR]:\n");
                    System.Console.WriteLine("message:\t" + obj.GetValue("message"));
                    System.Console.WriteLine("debug:\t" + obj.GetValue("debug_message"));
                    System.Console.WriteLine("code:\t" + obj.GetValue("code"));
                }

            }

问题是参数token_id只用于一次调用,但如果你想重复使用一张卡进行自动支付,你必须设置payment_source_id而不是[=13] =],这是正确的代码:

Expression<Func<Usuario, bool>> exp = (x) => x.IdUsuario == IdUsuario;
            UsuarioLoader uLoader = new UsuarioLoader();
            var usuario = uLoader.GetElementByProperty(exp);
            try
            {

                order = new conekta.Order().create(@"{
                  ""currency"":""MXN"",
                  ""customer_info"": {
                    ""customer_id"": """+usuario.TokenConekta+ @""" 
                  },
                  ""line_items"": [{
                    ""name"": ""Cobro Union"",
                    ""unit_price"": 1000,
                    ""quantity"": 1
                  }],
                  ""charges"": [{
                    ""payment_method"": {
                       ""type"": ""card"",
                        ""payment_source_id"": """ + tokenTarjeta+@"""
                    },""amount"":1000
                  }]
                }");

            }
            catch (ConektaException e)
            {
                band = false;
                foreach (JObject obj in e.details)
                {
                    System.Console.WriteLine("\n [ERROR]:\n");
                    System.Console.WriteLine("message:\t" + obj.GetValue("message"));
                    System.Console.WriteLine("debug:\t" + obj.GetValue("debug_message"));
                    System.Console.WriteLine("code:\t" + obj.GetValue("code"));
                }

            }