Skip to content

Commit 29802b9

Browse files
readme
1 parent fcbdef6 commit 29802b9

File tree

3 files changed

+306
-0
lines changed

3 files changed

+306
-0
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
### versión 1.0.1 - 27-12-2022
2+
* Add status code
3+
* Add encrypt RSA
4+
5+
### versión 1.0.0 - 27-12-2022
6+
* Add Yape y Confirm Order

LICENCE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2016 CULQI
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+279
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
# Culqi-Net-Framework
2+
Nuestra Biblioteca NET FRAMEWORK oficial, es compatible con la v2.0 del Culqi API, con el cual tendrás la posibilidad de realizar cobros con tarjetas de débito y crédito, Yape, PagoEfectivo, billeteras móviles y Cuotéalo con solo unos simples pasos de configuración.
3+
4+
Nuestra biblioteca te da la posibilidad de capturar el `status_code` de la solicitud HTTP que se realiza al API de Culqi, así como el `response` que contiene el cuerpo de la respuesta obtenida.
5+
6+
## Requisitos
7+
8+
- NET FrameWork 3.6+
9+
* Afiliate [aquí](https://afiliate.culqi.com/).
10+
* Si vas a realizar pruebas obtén tus llaves desde [aquí](https://integ-panel.culqi.com/#/registro), si vas a realizar transacciones reales obtén tus llaves desde [aquí](https://panel.culqi.com/#/registro).
11+
12+
> Recuerda que para obtener tus llaves debes ingresar a tu CulqiPanel > Desarrollo > ***API Keys***.
13+
14+
![alt tag](http://i.imgur.com/NhE6mS9.png)
15+
16+
> Recuerda que las credenciales son enviadas al correo que registraste en el proceso de afiliación.
17+
18+
* Para encriptar el payload debes generar un id y llave RSA ingresando a CulqiPanel > Desarrollo > RSA Keys.
19+
20+
## Instalación
21+
22+
Ejecuta los siguientes comandos usando la consola de comandos NuGet:
23+
24+
```bash
25+
Install-Package RestSharp
26+
Install-Package Newtonsoft.Json
27+
```
28+
29+
30+
## Configuracion
31+
32+
Para empezar a enviar peticiones al API de Culqi debes configurar tu llave pública (pk), llave privada (sk). Para habilitar encriptación de payload debes configurar tu rsa_id y rsa_public_key.
33+
34+
```cs
35+
security = new Security();
36+
security.public_key = "pk_test_e94078b9b248675d";
37+
security.secret_key = "sk_test_c2267b5b262745f0";
38+
security.rsa_id = "de35e120-e297-4b96-97ef-10a43423ddec";
39+
40+
security.rsa_key = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDswQycch0x/7GZ0oFojkWCYv+gr5CyfBKXc3Izq+btIEMCrkDrIsz4Lnl5E3FSD7/htFn1oE84SaDKl5DgbNoev3pMC7MDDgdCFrHODOp7aXwjG8NaiCbiymyBglXyEN28hLvgHpvZmAn6KFo0lMGuKnz8HiuTfpBl6HpD6+02SQIDAQAB";
41+
42+
```
43+
44+
### Encriptar payload
45+
46+
Para encriptar el payload necesitas agregar el parámetros que contiene tu id y llave RSA.
47+
48+
Ejemplo
49+
50+
```cs
51+
public HttpResponseMessage CreateTokenEncrypt()
52+
{
53+
return new Token(security).Create(jsonData.JsonToken(), security.rsa_id, security.rsa_key);
54+
}
55+
```
56+
57+
## Servicios
58+
59+
### Crear Token
60+
61+
Antes de crear un Cargo o Card es necesario crear un `token` de tarjeta.
62+
Lo recomendable es generar los 'tokens' con [Culqi Checkout v4](https://docs.culqi.com/es/documentacion/checkout/v4/culqi-checkout/) o [Culqi JS v4](https://docs.culqi.com/es/documentacion/culqi-js/v4/culqi-js/) **debido a que es muy importante que los datos de tarjeta sean enviados desde el dispositivo de tus clientes directamente a los servidores de Culqi**, para no poner en riesgo los datos sensibles de la tarjeta de crédito/débito.
63+
64+
> Recuerda que cuando interactúas directamente con el [API Token](https://apidocs.culqi.com/#tag/Tokens/operation/crear-token) necesitas cumplir la normativa de PCI DSS 3.2. Por ello, te pedimos que llenes el [formulario SAQ-D](https://listings.pcisecuritystandards.org/documents/SAQ_D_v3_Merchant.pdf) y lo envíes al buzón de riesgos Culqi.
65+
66+
```cs
67+
Dictionary<string, object> token = new Dictionary<string, object>
68+
{
69+
{"card_number", "4111111111111111"},
70+
{"cvv", "123"},
71+
{"expiration_month", 9},
72+
{"expiration_year", 2020},
73+
{"email", "[email protected]"}
74+
};
75+
HttpResponseMessage token_created = new Token(security).Create(token);
76+
```
77+
78+
79+
### Crear Cargo
80+
81+
Crear un cargo significa cobrar una venta a una tarjeta. Para esto previamente deberías generar el `token` y enviarlo en parámetro **source_id**.
82+
83+
Los cargos pueden ser creados vía [API de cargo](https://apidocs.culqi.com/#tag/Cargos/operation/crear-cargo).
84+
85+
```cs
86+
var json_token = JObject.Parse(token_created);
87+
88+
Dictionary<string, object> metadata = new Dictionary<string, object>
89+
{
90+
{"order_id", "777"}
91+
};
92+
93+
Dictionary<string, object> charge = new Dictionary<string, object>
94+
{
95+
{"amount", 1000},
96+
{"capture", true},
97+
{"currency_code", "PEN"},
98+
{"description", "Venta de prueba"},
99+
{"email", "[email protected]"},
100+
{"installments", 0},
101+
{"metadata", metadata},
102+
{"source_id", (string)json_token["id"]}
103+
};
104+
105+
HttpResponseMessage charge_created = new Charge(security).Create(charge);
106+
```
107+
108+
### Crear Devolución
109+
110+
Solicita la devolución de las compras de tus clientes (parcial o total) de forma gratuita a través del API y CulqiPanel.
111+
112+
Las devoluciones pueden ser creados vía [API de devolución](https://apidocs.culqi.com/#tag/Devoluciones/operation/crear-devolucion).
113+
114+
```cs
115+
var json_charge = JObject.Parse(charge_created);
116+
117+
Dictionary<string, object> refund = new Dictionary<string, object>
118+
{
119+
{"amount", 500},
120+
{"charge_id", (string)json_charge["id"]},
121+
{"reason", "solicitud_comprador"}
122+
};
123+
124+
HttpResponseMessage refund_created = Refund(security).Create(refund);
125+
```
126+
127+
### Crear Cliente
128+
129+
El **cliente** es un servicio que te permite guardar la información de tus clientes. Es un paso necesario para generar una [tarjeta](/es/documentacion/pagos-online/recurrencia/one-click/tarjetas).
130+
131+
Los clientes pueden ser creados vía [API de cliente](https://apidocs.culqi.com/#tag/Clientes/operation/crear-cliente).
132+
133+
```cs
134+
Dictionary<string, object> customer = new Dictionary<string, object>
135+
{
136+
{"address", "Av Lima 123"},
137+
{"address_city", "Lima"},
138+
{"country_code", "PE"},
139+
{"email", "test"+GetRandomString()+"@culqi.com"},
140+
{"first_name", "Test"},
141+
{"last_name", "Culqi"},
142+
{"phone_number", 99004356}
143+
};
144+
145+
HttpResponseMessage customer_created = new Customer(security).Create(customer);
146+
```
147+
148+
### Crear Tarjeta
149+
150+
La **tarjeta** es un servicio que te permite guardar la información de las tarjetas de crédito o débito de tus clientes para luego realizarles cargos one click o recurrentes (cargos posteriores sin que tus clientes vuelvan a ingresar los datos de su tarjeta).
151+
152+
Las tarjetas pueden ser creadas vía [API de tarjeta](https://apidocs.culqi.com/#tag/Tarjetas/operation/crear-tarjeta).
153+
154+
```cs
155+
Dictionary<string, object> card = new Dictionary<string, object>
156+
{
157+
{"customer_id", (string)json_customer["id"]},
158+
{"token_id", (string)json_token["id"]}
159+
};
160+
161+
HttpResponseMessage card_created = new Card(security).Create(card);
162+
```
163+
164+
### Crear Plan
165+
166+
El plan es un servicio que te permite definir con qué frecuencia deseas realizar cobros a tus clientes.
167+
168+
Un plan define el comportamiento de las suscripciones. Los planes pueden ser creados vía el [API de Plan](https://apidocs.culqi.com/#/planes#create) o desde el **CulqiPanel**.
169+
170+
```cs
171+
Dictionary<string, object> metadata = new Dictionary<string, object>
172+
{
173+
{"alias", "plan-test"}
174+
};
175+
176+
Dictionary<string, object> plan = new Dictionary<string, object>
177+
{
178+
{"amount", 10000},
179+
{"currency_code", "PEN"},
180+
{"interval", "dias"},
181+
{"interval_count", 15},
182+
{"limit", 2},
183+
{"metadata", metadata},
184+
{"name", "plan-culqi-"+GetRandomString()},
185+
{"trial_days", 15}
186+
};
187+
188+
HttpResponseMessage plan_created = new Plan(security).Create(plan);
189+
```
190+
191+
### Crear Suscripción
192+
193+
La suscripción es un servicio que asocia la tarjeta de un cliente con un plan establecido por el comercio.
194+
195+
Las suscripciones pueden ser creadas vía [API de suscripción](https://apidocs.culqi.com/#tag/Suscripciones/operation/crear-suscripcion).
196+
197+
```cs
198+
var json_plan = JObject.Parse(plan_created);
199+
var json_card = JObject.Parse(card_created);
200+
201+
Dictionary<string, object> subscription = new Dictionary<string, object>
202+
{
203+
{"card_id", (string)json_card["id"]},
204+
{"plan_id", (string)json_plan["id"]}
205+
};
206+
207+
string subscription_created = new Subscription(security).Create(subscription);
208+
```
209+
210+
### Crear Orden
211+
212+
Es un servicio que te permite generar una orden de pago para una compra potencial.
213+
La orden contiene la información necesaria para la venta y es usado por el sistema de **PagoEfectivo** para realizar los pagos diferidos.
214+
215+
Las órdenes pueden ser creadas vía [API de orden](https://apidocs.culqi.com/#tag/Ordenes/operation/crear-orden).
216+
217+
```cs
218+
Dictionary<string, object> client_details = new Dictionary<string, object>
219+
{
220+
{"first_name", "Juan"},
221+
{"last_name", "Diaz"},
222+
{"email", "[email protected]"},
223+
{"phone_number", "+51948747421"},
224+
225+
};
226+
227+
Dictionary<string, object> order = new Dictionary<string, object>
228+
{
229+
{"amount", 1000},
230+
{"currency_code", "PEN"},
231+
{"description", "Venta de prueba"},
232+
{"order_number", "pedido"+Convert.ToString(order)},
233+
{"client_details", client_details},
234+
{"expiration_date", secondsSinceEpoch},
235+
{"confirm", true}
236+
237+
};
238+
239+
HttpResponseMessage order_created = new Order(security).Create(order);
240+
```
241+
242+
## Pruebas
243+
244+
En la caperta **/Pruebas** econtraras ejemplo para crear un token, charge, plan, órdenes, card, suscupciones, etc.
245+
246+
> Recuerda que si quieres probar tu integración, puedes utilizar nuestras [tarjetas de prueba.](https://docs.culqi.com/es/documentacion/pagos-online/tarjetas-de-prueba/)
247+
248+
### Ejemplo Prueba Token
249+
250+
```cs
251+
HttpResponseMessage data = culqiCRUD.CreateToken();
252+
var json_object = JObject.Parse(data.Content.ReadAsStringAsync().Result);
253+
Assert.AreEqual("token",(string)json_object["object"]);
254+
```
255+
256+
### Ejemplo Prueba Cargo
257+
258+
```cs
259+
HttpResponseMessage data = culqiCRUD.CreateCharge();
260+
var json_object = JObject.Parse(data.Content.ReadAsStringAsync().Result);
261+
Assert.AreEqual("charge", (string)json_object["object"]);
262+
```
263+
264+
## Documentación
265+
266+
- [Referencia de Documentación](https://docs.culqi.com/)
267+
- [Referencia de API](https://apidocs.culqi.com/)
268+
- [Demo Checkout V4 + Culqi 3DS](https://github.com/culqi/culqi-netframework-demo-checkoutv4-culqi3ds)
269+
- [Wiki](https://github.com/culqi/culqi-net_framework/wiki)
270+
271+
## Changelog
272+
273+
Todos los cambios en las versiones de esta biblioteca están listados en [CHANGELOG.md](CHANGELOG.md).
274+
275+
## Autor
276+
Team Culqi
277+
278+
## Licencia
279+
El código fuente de culqi-net-framework está distribuido bajo MIT License, revisar el archivo LICENSE.

0 commit comments

Comments
 (0)