2017-08-08 98 views
1

我有一個問題時,做出充電,這表明我這個錯誤:令牌已經被使用,conekta

「令牌已被使用」 「香格里拉TARJETA沒有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"": """[email protected]""" 
        }, 
        ""line_items"": [{ 
        ""name"": ""Cobro Union"", 
        ""unit_price"": 1000, 
        ""quantity"": 1 
        }], 
        ""charges"": [{ 
        ""payment_method"": { 
         ""type"": ""card"", 
         ""token_id"": """[email protected]""" 
        },""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")); 
       } 

      } 
+0

是否已經使用了令牌? – mjwills

+0

「tokenTarjeta」和「usuario.TokenConekta」的值是什麼? – mjwills

+0

不,令牌是新的 –

回答

0

的問題是,參數token_id是一個只有一個呼叫,但如果你想重新使用卡的自動付款必須設置payment_source_id代替token_id的,這是正確的代碼:

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"": """ + [email protected]""" 
        },""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")); 
       } 

      }