GithubHelp home page GithubHelp logo

icueto / culqi-java Goto Github PK

View Code? Open in Web Editor NEW

This project forked from culqi/culqi-java

0.0 2.0 0.0 106 KB

Una implementación de Culqi en Java

Home Page: https://developers.culqi.com

License: MIT License

Java 100.00%

culqi-java's Introduction

Culqi Java

Code Climate Build Status

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

Requisitos

  • Java 1.7+
  • Credenciales de comercio en Culqi (1).

Instalación

Instalación usando Maven: Solo necesita agregar el siguiente repositorio en el pom.xml

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

Y Luego agregar la dependencia

<dependency>
    <groupId>com.github.culqi</groupId>
    <artifactId>culqi-java</artifactId>
    <version>v1.1.9</version>
</dependency>

Ejemplos

Inicialización

Culqi culqi = new Culqi();
culqi.public_key = "{LLAVE PUBLICA}";
culqi.secret_key =  "{LLAVE SECRETA}"

Crear Token

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);

Crear Cargo

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);

Crear Plan

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);

Crear Cliente

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);

Crear Tarjeta

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);

Crear Suscripción

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);

Crear Devolución

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);

Documentación

¿Necesitas más información para integrar culqi-java? La documentación completa se encuentra en https://culqi.com/docs/

Changelog

Todos los cambios en las versiones de esta biblioteca están listados en CHANGELOG.

Dependencias para el desarrollo

Build

mvn package -DskipTests

Testing

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

¿Cómo instalar el jar de Culqi en un proyecto Maven?

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>

Autor

Willy Aguirre (@marti1125 - Team Culqi)

Licencia

El código fuente de culqi-java está distribuido bajo MIT License, revisar el archivo LICENSE.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.