Biblioteca de CULQI para el lenguaje Java, pagos simples en tu sitio web. Consume el Culqi API.
Versión actual | Culqi API |
---|---|
1.1.9 (2017-05-31) | v2 |
- Java 1.7+
- Credenciales de comercio en Culqi (1).
Instalación usando Maven:
Solo necesita agregar el siguiente repositorio en el archivo pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Luego agregar la dependencia:
<dependency>
<groupId>com.github.culqi</groupId>
<artifactId>culqi-java</artifactId>
<version>v1.1.9</version>
</dependency>
Culqi culqi = new Culqi();
culqi.public_key = "{LLAVE PUBLICA}";
culqi.secret_key = "{LLAVE SECRETA}"
Map<String, Object> token = new HashMap<String, Object>();
token.put("card_number", "4111111111111111");
token.put("cvv", "123");
token.put("email", "[email protected]");
token.put("expiration_month", 9);
token.put("expiration_year", 2020);
Map<String, Object> token_created = culqi.token.create(token);
Map<String, Object> charge = new HashMap<String, Object>();
Map<String, Object> antifraudDetails = new HashMap<String, Object>();
antifraudDetails.put("address", "Calle Narciso de Colina 421 Miraflores");
antifraudDetails.put("address_city", "LIMA");
antifraudDetails.put("country_code", "PE");
antifraudDetails.put("first_name", "Willy");
antifraudDetails.put("last_name", "Aguirre");
antifraudDetails.put("phone_number", "012767623");
Map<String, Object> metadata = new HashMap<String, Object>();
metadata.put("oder_id", "124");
charge.put("amount",1000);
charge.put("capture", true);
charge.put("currency_code",CurrencyCode.PEN);
charge.put("description","Venta de prueba");
charge.put("email","[email protected]");
charge.put("installments", 0);
charge.put("antifraud_details", antifraudDetails);
charge.put("metadata", metadata);
charge.put("source_id", token_created.get("id").toString());
Map<String, Object> charge_created = culqi.charge.create(charge);
Map<String, Object> plan = new HashMap<String, Object>();
Map<String, Object> metadata = new HashMap<String, Object>();
metadata.put("oder_id", "124");
plan.put("amount",1000);
plan.put("currency_code",CurrencyCode.PEN);
plan.put("interval","dias");
plan.put("interval_count",30);
plan.put("limit", 4);
plan.put("metadata", metadata);
plan.put("name", "plan-test");
plan.put("trial_days", 15);
Map<String, Object> plan_created = culqi.plan.create(plan);
Map<String, Object> customer = new HashMap<String, Object>();
customer.put("address","Av Lima 123");
customer.put("address_city","Lima");
customer.put("country_code","PE");
customer.put("email","[email protected]");
customer.put("first_name","Test");
customer.put("last_name","Cuqli");
customer.put("phone_number",99004356);
Map<String, Object> customer_created = culqi.customer.create(customer);
Map<String, Object> card = new HashMap<String, Object>();
card.put("customer_id",customer_created.get("id").toString());
card.put("token_id",token_created.get("id").toString());
Map<String, Object> card_created = culqi.card.create(card);
Map<String, Object> subscription = new HashMap<String, Object>();
subscription.put("card_id",card_created.get("id").toString());
subscription.put("plan_id",plan_created.get("id").toString());
Map<String, Object> suscription_created = culqi.subscription.create(subscription);
Map<String, Object> refund = new HashMap<String, Object>();
refund.put("amount",900);
refund.put("charge_id",charge_created.get("id").toString());
refund.put("reason",Reason.solicitud_comprador);
Map<String, Object> refund_created = culqi.refund.create(refund);
¿Necesitas más información para integrar culqi-java
? La documentación completa se encuentra en https://culqi.com/docs/
Todos los cambios en las versiones de esta biblioteca están listados en CHANGELOG.
mvn package -DskipTests
Debes tener instalado Maven para poder ejecutar los tests
mvn test
Puede ejecutar estos unitarios independientemente
mvn test -D test=CulqiCreateTest#test1ValidCreateToken
mvn test -D test=CulqiCreateTest#test2ValidCreateCharge
mvn test -D test=CulqiCreateTest#test3ValidCreatePlan
mvn test -D test=CulqiCreateTest#test4ValidCreateCustomer
mvn test -D test=CulqiCreateTest#test5ValidCreateCard
mvn test -D test=CulqiCreateTest#test6ValidCreateSubscription
mvn test -D test=CulqiCreateTest#test7ChargeCapture
mvn install:install-file -Dfile={dir}/culqi-java-1.1.8.jar -DgroupId=com.culqi -DartifactId=culqi-java -Dversion={version} -Dpackaging=jar
Luego agregas la siguiente dependencia en el pom.xml
<dependency>
<groupId>com.culqi</groupId>
<artifactId>culqi-java</artifactId>
<version>{version}</version>
</dependency>
Willy Aguirre (@marti1125 - Team Culqi)
El código fuente de culqi-java está distribuido bajo MIT License, revisar el archivo LICENSE.