public void createShippingLine() { getApiKey(); conekta.Api.version = "2.0.0"; Order order = new conekta.Order().create(@"{ ""currency"":""MXN"", ""customer_info"": { ""name"": ""Jul Ceballos"", ""phone"": ""+5215555555555"", ""email"": ""*****@*****.**"" }, ""line_items"": [{ ""name"": ""Box of Cohiba S1s"", ""unit_price"": 35000, ""quantity"": 1 }] }"); Assert.AreEqual(order.id.GetType().ToString(), "System.String"); order = new Order().find(order.id); ShippingLine shipping_line = order.createShippingLine(@"{ ""amount"": 0, ""tracking_number"": ""TRACK123"", ""carrier"": ""USPS"", ""method"": ""Train"", ""metadata"": { ""random_key"": ""random_value"" } }"); Assert.AreEqual(shipping_line.tracking_number, "TRACK123"); }
public void createDiscountLine() { getApiKey(); conekta.Api.version = "2.0.0"; Order order = new conekta.Order().create(@"{ ""currency"":""MXN"", ""customer_info"": { ""name"": ""Jul Ceballos"", ""phone"": ""+5215555555555"", ""email"": ""*****@*****.**"" }, ""line_items"": [{ ""name"": ""Box of Cohiba S1s"", ""unit_price"": 35000, ""quantity"": 1 }] }"); Assert.AreEqual(order.id.GetType().ToString(), "System.String"); order = new Order().find(order.id); DiscountLine discount_line = order.createDiscountLine(@"{ ""code"": ""123"", ""type"": ""loyalty"", ""amount"": 600 }"); Assert.AreEqual(discount_line.code, "123"); Assert.AreEqual(discount_line.type, "loyalty"); }
public void updateLineItem() { getApiKey(); conekta.Api.version = "2.0.0"; Order order = new conekta.Order().create(@"{ ""currency"":""MXN"", ""customer_info"": { ""name"": ""Jul Ceballos"", ""phone"": ""+5215555555555"", ""email"": ""*****@*****.**"" }, ""line_items"": [{ ""name"": ""Box of Cohiba S1s"", ""unit_price"": 35000, ""quantity"": 1 }] }"); Assert.AreEqual(order.id.GetType().ToString(), "System.String"); order = new Order().find(order.id); LineItem line_item = (LineItem)order.line_items.at(0); //line_item = line_item.update(@"{ // ""name"": ""Box S1s"", // ""unit_price"": 45000 //}"); //Assert.AreEqual(line_item.name, "Box S1s"); }
public void createTaxLine() { getApiKey(); conekta.Api.version = "2.0.0"; Order order = new conekta.Order().create(@"{ ""currency"":""MXN"", ""customer_info"": { ""name"": ""Jul Ceballos"", ""phone"": ""+5215555555555"", ""email"": ""*****@*****.**"" }, ""line_items"": [{ ""name"": ""Box of Cohiba S1s"", ""unit_price"": 35000, ""quantity"": 1 }] }"); Assert.AreEqual(order.id.GetType().ToString(), "System.String"); order = new Order().find(order.id); TaxLine tax_line = order.createTaxLine(@"{ ""description"": ""IVA"", ""amount"": 600, ""metadata"": { ""random_key"": ""random_value"" } }"); Assert.AreEqual(tax_line.description, "IVA"); Assert.AreEqual(tax_line.amount, 600); }
public void CreateOxxo() { getApiKey(); conekta.Api.version = "2.0.0"; Order order = new conekta.Order().create(@"{ ""currency"":""MXN"", ""customer_info"": { ""name"": ""Jul Ceballos"", ""phone"": ""+5215555555555"", ""email"": ""*****@*****.**"" }, ""line_items"": [{ ""name"": ""Box of Cohiba S1s"", ""unit_price"": 35000, ""quantity"": 1 }], ""charges"": [{ ""payment_method"": { ""type"": ""oxxo_cash"", ""expires_at"": 1553273553 }, ""amount"": 35000 }] }"); Assert.AreEqual(order.id.GetType().ToString(), "System.String"); System.Console.WriteLine(order.payment_status); Assert.AreEqual(order.payment_status, "pending_payment"); Assert.AreEqual(order.amount, 35000); }
public void update() { getApiKey(); conekta.Api.version = "2.0.0"; Order order = new conekta.Order().create(@"{ ""currency"":""MXN"", ""customer_info"": { ""name"": ""Jul Ceballos"", ""phone"": ""+5215555555555"", ""email"": ""*****@*****.**"" }, ""line_items"": [{ ""name"": ""Box of Cohiba S1s"", ""unit_price"": 35000, ""quantity"": 1 }] }"); Assert.AreEqual(order.id.GetType().ToString(), "System.String"); Assert.AreEqual(order.amount, 35000); order = new Order().find(order.id); order = order.update(@"{""currency"": ""USD""}"); Assert.AreEqual(order.id.GetType().ToString(), "System.String"); Assert.AreEqual(order.amount, 35000); }
public void createLineItem() { conekta.Api.apiKey = "key_eYvWV7gSDkNYXsmr"; conekta.Api.version = "2.0.0"; Order order = new conekta.Order().create(@"{ ""currency"":""MXN"", ""customer_info"": { ""name"": ""Jul Ceballos"", ""phone"": ""+5215555555555"", ""email"": ""*****@*****.**"" }, ""line_items"": [{ ""name"": ""Box of Cohiba S1s"", ""unit_price"": 35000, ""quantity"": 1 }] }" ); Assert.AreEqual(order.id.GetType().ToString(), "System.String"); order = new Order().find(order.id); LineItem line_item = order.createLineItem(@"{ ""name"": ""Box of Cohiba S1s"", ""unit_price"": 35000, ""quantity"": 1 }" ); Assert.AreEqual(line_item.name, "Box of Cohiba S1s"); }
public void createCard() { getApiKey(); conekta.Api.version = "2.0.0"; Order order = new conekta.Order().create(@"{ ""currency"":""MXN"", ""customer_info"": { ""name"": ""Jul Ceballos"", ""phone"": ""+5215555555555"", ""email"": ""*****@*****.**"" }, ""line_items"": [{ ""name"": ""Box of Cohiba S1s"", ""unit_price"": 35000, ""quantity"": 1 }], ""charges"": [{ ""payment_method"": { ""type"": ""card"", ""token_id"": ""tok_test_visa_4242"" } }], ""metadata"": { ""yes"": ""nou"" } }"); Assert.AreEqual(order.id.GetType().ToString(), "System.String"); Assert.AreEqual(order.payment_status, "paid"); Assert.AreEqual(order.amount, 35000); Charge charge = (Charge)order.charges.at(0); Assert.AreEqual(charge.payment_method.brand, "visa"); order = new Order().find(order.id); Assert.AreEqual(order.id.GetType().ToString(), "System.String"); Assert.AreEqual(order.payment_status, "paid"); Assert.AreEqual(order.amount, 35000); order = order.createReturn(@"{""amount"": 35000}"); Assert.AreEqual(order.id.GetType().ToString(), "System.String"); Assert.AreEqual(order.payment_status, "refunded"); Assert.AreEqual(order.amount, 35000); Order[] orders = new Order().where (new JObject()); Assert.AreEqual(orders[0].id.GetType().ToString(), "System.String"); }
public void updateTaxLine() { conekta.Api.apiKey = "key_eYvWV7gSDkNYXsmr"; conekta.Api.version = "2.0.0"; Order order = new conekta.Order().create(@"{ ""currency"":""MXN"", ""customer_info"": { ""name"": ""Jul Ceballos"", ""phone"": ""+5215555555555"", ""email"": ""*****@*****.**"" }, ""line_items"": [{ ""name"": ""Box of Cohiba S1s"", ""unit_price"": 35000, ""quantity"": 1, ""metadata"": { ""random_key"": ""random value"" } }] }" ); Assert.AreEqual(order.id.GetType().ToString(), "System.String"); order = new Order().find(order.id); TaxLine tax_line = order.createTaxLine(@"{ ""description"": ""IVA"", ""amount"": 600, ""contextual_data"": { ""random_key"": ""random_value"" } }" ); order = new Order().find(order.id); //tax_line = order.tax_lines.at(0).update(@"{ // ""description"": ""IVA"", // ""amount"": 1000, // ""contextual_data"": { // ""random_key"": ""random_value"" // } //}"); //System.Console.WriteLine(tax_line.amount); //Assert.AreEqual(tax_line.description, "IVA"); //Assert.AreEqual(tax_line.amount, 1000); }
public void createCharge() { conekta.Api.apiKey = "key_eYvWV7gSDkNYXsmr"; conekta.Api.version = "2.0.0"; Order order = new conekta.Order().create(@"{ ""currency"":""MXN"", ""customer_info"": { ""name"": ""Jul Ceballos"", ""phone"": ""+5215555555555"", ""email"": ""*****@*****.**"" }, ""line_items"": [{ ""name"": ""Box of Cohiba S1s"", ""unit_price"": 35000, ""quantity"": 1 }] }" ); order.createCharge(@"{ ""payment_method"": { ""type"": ""card"", ""token_id"": ""tok_test_visa_4242"" }, ""amount"": 35000 }" ); order = new Order().find(order.id); Assert.AreEqual(order.id.GetType().ToString(), "System.String"); Assert.AreEqual(order.payment_status, "paid"); Assert.AreEqual(order.amount, 35000); order = new Order().find(order.id); Assert.AreEqual(order.id.GetType().ToString(), "System.String"); Assert.AreEqual(order.payment_status, "paid"); Assert.AreEqual(order.amount, 35000); order = order.createReturn(@"{""amount"": 35000}"); Assert.AreEqual(order.id.GetType().ToString(), "System.String"); Assert.AreEqual(order.payment_status, "refunded"); Assert.AreEqual(order.amount, 35000); Order[] orders = new Order().where (new JObject()); Assert.AreEqual(orders[0].id.GetType().ToString(), "System.String"); }
public void updateDiscountLine() { conekta.Api.apiKey = "key_eYvWV7gSDkNYXsmr"; conekta.Api.version = "2.0.0"; Order order = new conekta.Order().create(@"{ ""currency"":""MXN"", ""customer_info"": { ""name"": ""Jul Ceballos"", ""phone"": ""5575553324"", ""email"": ""*****@*****.**"" }, ""line_items"": [{ ""name"": ""Box of Cohiba S1s"", ""unit_price"": 35000, ""quantity"": 1 }] }" ); Assert.AreEqual(order.id.GetType().ToString(), "System.String"); order = new Order().find(order.id); DiscountLine discount_line = order.createDiscountLine(@"{ ""code"": ""234"", ""type"": ""loyalty"", ""amount"": 600 }" ); order = new Order().find(order.id); discount_line = (DiscountLine)order.discount_lines.at(0); discount_line = discount_line.update(@"{ ""amount"": 700, ""code"": ""567"", ""type"": ""coupon"" }" ); Assert.AreEqual(discount_line.type, "coupon"); Assert.AreEqual(discount_line.code, "567"); Assert.AreEqual(discount_line.amount, 700); }
public void updateShippingLine() { conekta.Api.apiKey = "key_eYvWV7gSDkNYXsmr"; conekta.Api.version = "2.0.0"; Order order = new conekta.Order().create(@"{ ""currency"":""MXN"", ""customer_info"": { ""name"": ""Jul Ceballos"", ""phone"": ""+5215555555555"", ""email"": ""*****@*****.**"" }, ""line_items"": [{ ""name"": ""Box of Cohiba S1s"", ""unit_price"": 35000, ""quantity"": 1 }] }" ); Assert.AreEqual(order.id.GetType().ToString(), "System.String"); order = new Order().find(order.id); ShippingLine shipping_line = order.createShippingLine(@"{ ""amount"": 0, ""tracking_number"": ""TRACK123"", ""carrier"": ""Fedex"", ""method"": ""Train"", ""contextual_data"": { ""random_key"": ""random_value"" } }" ); order = new Order().find(order.id); shipping_line = (ShippingLine)order.shipping_lines.at(0); shipping_line = shipping_line.update(@"{ ""carrier"": ""UPS"" }" ); Assert.AreEqual(shipping_line.carrier, "UPS"); }
public void captureCharge() { getApiKey(); conekta.Api.version = "2.0.0"; Order order = new conekta.Order().create(@"{ ""currency"":""MXN"", ""customer_info"": { ""name"": ""Jul Ceballos"", ""phone"": ""+5215555555555"", ""email"": ""*****@*****.**"" }, ""line_items"": [{ ""name"": ""Box of Cohiba S1s"", ""unit_price"": 35000, ""quantity"": 1 }], ""pre_authorize"": true }"); order.createCharge(@"{ ""payment_method"": { ""type"": ""card"", ""token_id"": ""tok_test_visa_4242"" }, ""amount"": 35000 }"); order = new Order().find(order.id); order = order.capture(); Assert.AreEqual(order.id.GetType().ToString(), "System.String"); Assert.AreEqual(order.payment_status, "paid"); Assert.AreEqual(order.amount, 35000); }
public void getObject() { getApiKey(); conekta.Api.version = "2.0.0"; conekta.Order order = new conekta.Order().create(@"{ ""currency"": ""MXN"", ""customer_info"": { ""name"": ""Jul Ceballos"", ""phone"": ""+5215555555555"", ""email"": ""*****@*****.**"" }, ""line_items"": [{ ""name"": ""Box of Cohiba S1s a"", ""unit_price"": 35000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s b"", ""unit_price"": 36000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s c"", ""unit_price"": 37000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s d"", ""unit_price"": 38000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s e"", ""unit_price"": 39000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s f"", ""unit_price"": 40000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s g"", ""unit_price"": 41000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s h"", ""unit_price"": 42000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s i"", ""unit_price"": 43000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s j"", ""unit_price"": 44000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s k"", ""unit_price"": 45000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s l"", ""unit_price"": 46000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s m"", ""unit_price"": 47000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s n"", ""unit_price"": 48000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s ñ"", ""unit_price"": 49000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s o"", ""unit_price"": 50000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s p"", ""unit_price"": 51000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s q"", ""unit_price"": 52000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s r"", ""unit_price"": 53000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s s"", ""unit_price"": 54000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s t"", ""unit_price"": 55000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s u"", ""unit_price"": 56000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s v"", ""unit_price"": 57000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s w"", ""unit_price"": 58000, ""quantity"": 1 }, { ""name"": ""Box of Cohiba S1s x"", ""unit_price"": 59000, ""quantity"": 1 }] }"); LineItem line_item = (LineItem)order.line_items.at(0); int size = order.line_items.data.Length; order.line_items.next_page(); Assert.AreEqual(order.line_items.data.Length > size, true); }
protected void Page_Load(object sender, EventArgs e) { conekta.Api.version = "2.0.0"; int order_id = RequestTool.RequestInt("order_id", 0); Lebi_Order order = B_Lebi_Order.GetModel(order_id); if (order == null) { Response.Write("ERROR"); Response.End(); return; } Lebi_Language language = B_Lebi_Language.GetModel(order.Language_id); if (order.IsPaid == 1) { Response.Write(Language.Tag("已付款", language.Code)); Response.End(); return; } order.Site_id_pay = CurrentSite.id; order.Language_id = CurrentLanguage.id; //SystemLog.Add("订单:" + order.Code + "-" + CurrentSite.id + "--" + CurrentLanguage.id); Lebi_OnlinePay pay = Shop.Bussiness.Money.GetOnlinePay(order, "conekta"); if (pay == null) { Response.Write("系统错误"); Response.End(); return; } conekta.Api.apiKey = pay.UserKey; if (pay.FreeFeeRate == 1) { pay.FeeRate = 0; } if (pay.FeeRate > 0) { order.Money_OnlinepayFee = order.Money_Pay * pay.FeeRate / 100; } if (order.OnlinePay_id != pay.id) { order.OnlinePay_id = pay.id; order.OnlinePay_Code = pay.Code; order.OnlinePay = pay.Name; } B_Lebi_Order.Update(order); if (order.weixin_prepay_id.Contains("oxxopay")) { //"oxxopay:" + JsonConvert.SerializeObject(jo) + ";"; string oxxo = RegexTool.GetRegValue(order.weixin_prepay_id, "oxxopay:(.*?)};") + "}"; try { JObject jo = (JObject)JsonConvert.DeserializeObject(oxxo); reference = jo["reference"].ToString(); money = jo["money"].ToString(); } catch (Exception ex) { //Response.Write(ex.ToString()); } } else { } if (money == order.Money_Pay.ToString()) { return; } money = order.Money_Pay.ToString(); Lebi_Currency currendy = B_Lebi_Currency.GetModel(pay.Currency_id); BaseConfig SYS = ShopCache.GetBaseConfig(); Shop.Bussiness.Site site = new Shop.Bussiness.Site(); ////////////////////////////////////////////请求参数//////////////////////////////////////////// //页面跳转同步通知页面路径 string return_url = "http://" + RequestTool.GetRequestDomain() + site.WebPath + "/onlinepay/conektapay/return_url.aspx"; //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/ //卖家支付宝帐户 string seller_email = pay.Email; //必填 //商户订单号 string out_trade_no = order.Code; //商户网站订单系统中唯一订单号,必填 //订单名称 string subject = order.Code; //必填 //付款金额 string total_fee = (order.Money_Pay * currendy.ExchangeRate * (1 + (pay.FeeRate / 100)) * 100).ToString("f0"); //必填 try { string ostring = @"{ ""line_items"": [{ ""name"": ""ordercode_{ordercode}"", ""unit_price"": {money}, ""quantity"": 1 }], ""shipping_lines"": [{ ""amount"": 0, ""carrier"": ""xxxxxx"" }], //shipping_lines - physical goods only ""currency"": ""MXN"", ""customer_info"": { ""name"": ""{u_name}"", ""email"": ""{u_email}"", ""phone"": ""{u_phone}"" }, ""shipping_contact"":{ ""address"": { ""street1"": ""xxx xxx"", ""postal_code"": ""06100"", ""country"": ""MX"" } }, //required only for physical goods ""charges"":[{ ""payment_method"": { ""type"": ""oxxo_cash"" } }] }"; ostring = ostring.Replace("{ordercode}", order.Code); ostring = ostring.Replace("{money}", total_fee); ostring = ostring.Replace("{u_name}", order.User_UserName); ostring = ostring.Replace("{u_email}", order.T_Email); ostring = ostring.Replace("{u_phone}", order.T_MobilePhone); ostring = ostring.Replace("{t_name}", order.T_Name); conekta.Order order1 = new conekta.Order().create(ostring); //ostring = string.Format(ostring, order.Code, total_fee, order.T_Name, order.T_Email, order.T_MobilePhone); //conekta.Order corder = new conekta.Order().create(ostring); //Response.Write("ID: " + order1.id); //Response.Write("ID111: " + order1.charges.toJSON()); //ID: ord_2jDzPMV51K1i9z9Ti //ID111: { "has_more":false,"data":[{"id":"5b91d84aedbb6e28f3ef1639","livemode":false,"created_at":1536284746,"currency":"MXN","payment_method":{"service_name":"OxxoPay","barcode_url":"https://s3.amazonaws.com/cash_payment_barcodes/sandbox_reference.png","object":"cash_payment","type":"oxxo","expires_at":1538870400,"store_name":"OXXO","reference":"98000000140098"},"object":"charge","description":"Payment from order","status":"pending_payment","amount":13500,"fee":549,"customer_id":"","order_id":"ord_2jDzPMV51K1i9z9Ti"}],"_type":"conekta.Charge, conekta, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"} //Response.Write("Payment Method: " + order1.charges[0].payment_method.service_name); //Response.Write("Reference: " + order1.charges[0].payment_method.reference); //Response.Write("$" + (order1.amount / 100) + order1.currency); //Response.Write("Order"); //Response.Write(order1.line_items[0].quantity + " - " // + order1.line_items[0].name + " - " // + (order1.line_items.unit_price / 100)); reference = RegexTool.GetRegValue(order1.charges.toJSON(), "\"reference\":\"(\\d+)\""); order.OnlinePay_Code = order1.id; JObject jo = new JObject(); jo["reference"] = reference; jo["money"] = money; order.weixin_prepay_id = "oxxopay:" + JsonConvert.SerializeObject(jo) + ";"; B_Lebi_Order.Update(order); } catch (ConektaException ex) { foreach (JObject obj in ex.details) { Response.Write("message:\t" + obj.GetValue("message") + "___" + "debug:\t" + obj.GetValue("debug_message") + "___" + "code:\t" + obj.GetValue("code")); Response.End(); SystemLog.Add("message:\t" + obj.GetValue("message") + "___" + "debug:\t" + obj.GetValue("debug_message") + "___" + "code:\t" + obj.GetValue("code")); //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")); } } }