From 35354409cf0b32f7fc35d6c7d5c15013c4b8fb56 Mon Sep 17 00:00:00 2001 From: Willy Aguirre Date: Mon, 20 Feb 2017 10:32:07 -0500 Subject: [PATCH] update README.md --- README.md | 164 ++++++++++++++++++++++++++++++++++ culqi.net/culqi.net.userprefs | 4 +- 2 files changed, 165 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f7777a2..79c3082 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,166 @@ # culqi-net Una implementación de Culqi para .NET + +| Versión actual|Culqi API| +|----|----| +| 0.1 (2017-02-19) |[v2](https://beta.culqi.com)| + +## Requisitos + +- NET Framework 4.* +- Credenciales de comercio en Culqi (1). + +## Ejemplos + +#### Generar nombres aleatorios + +```cs +protected static string GetRandomString() +{ + string path = Path.GetRandomFileName(); + path = path.Replace(".", ""); + return path; +} +``` + +#### Inicialización + +```cs +Security security = new Security(); +security.code_commerce = "{LLAVE PUBLICA}"; +security.api_key = "{LLAVE SECRETA}"; +``` + +#### Crear Token + +```cs +Dictionary token = new Dictionary +{ + {"card_number", "4111111111111111"}, + {"cvv", "123"}, + {"expiration_month", 9}, + {"expiration_year", 2020}, + {"email", "wmuro@me.com"} +}; +string token_created = new Token(security).Create(token); +``` + + +#### Crear Cargo + +```cs +var json_token = JObject.Parse(token_created); + +Dictionary metadata = new Dictionary +{ + {"order_id", "777"} +}; + +Dictionary charge = new Dictionary +{ + {"amount", 1000}, + {"capture", true}, + {"currency_code", "PEN"}, + {"description", "Venta de prueba"}, + {"email", "wmuro@me.com"}, + {"installments", 0}, + {"metadata", metadata}, + {"source_id", (string)json_token["id"]} +}; + +string charge_created = new Charge(security).Create(charge); +``` + +#### Crear Plan + +```cs +Dictionary metadata = new Dictionary +{ + {"alias", "plan-test"} +}; + +Dictionary plan = new Dictionary +{ + {"amount", 10000}, + {"currency_code", "PEN"}, + {"interval", "dias"}, + {"interval_count", 15}, + {"limit", 2}, + {"metadata", metadata}, + {"name", "plan-culqi-"+GetRandomString()}, + {"trial_days", 15} +}; + +string plan_created = new Plan(security).Create(plan); +``` + +#### Crear Cliente + +```cs +Dictionary customer = new Dictionary +{ + {"address", "Av Lima 123"}, + {"address_city", "Lima"}, + {"country_code", "PE"}, + {"email", "test"+GetRandomString()+"@culqi.com"}, + {"first_name", "Test"}, + {"last_name", "Culqi"}, + {"phone_number", 99004356} +}; + +string customer_created = new Customer(security).Create(customer); +``` + +#### Crear Tarjeta + +```cs +var json_customer = JObject.Parse(customer_created); + +Dictionary card = new Dictionary +{ + {"customer_id", (string)json_customer["id"]}, + {"token_id", (string)json_token["id"]} +}; + +string card_created = new Card(security).Create(card); +``` + +#### Crear Suscripción + +```cs +var json_plan = JObject.Parse(plan_created); +var json_card = JObject.Parse(card_created); + +Dictionary subscription = new Dictionary +{ + {"card_id", (string)json_card["id"]}, + {"plan_id", (string)json_plan["id"]} +}; + +string subscription_created = new Subscription(security).Create(subscription); +``` + +#### Crear Devolución + +```cs +var json_charge = JObject.Parse(charge_created); + +Dictionary refund = new Dictionary +{ + {"amount", 500}, + {"charge_id", (string)json_charge["id"]}, + {"reason", "bought an incorrect product"} +}; + +return new Refund(security).Create(refund); +``` + + +## Autor + +Willy Aguirre ([@marti1125](https://github.com/marti1125) - Team Culqi) + +## Licencia + +El código fuente de culqi-net está distribuido bajo MIT License, revisar el archivo +[LICENSE](https://github.com/culqi/culqi-net/blob/master/LICENSE). diff --git a/culqi.net/culqi.net.userprefs b/culqi.net/culqi.net.userprefs index 049e213..aacdc25 100644 --- a/culqi.net/culqi.net.userprefs +++ b/culqi.net/culqi.net.userprefs @@ -1,9 +1,7 @@  - - - +