GithubHelp home page GithubHelp logo

culqi-ruby's Introduction

culqi-ruby

Gem Version

Biblioteca de CULQI para el lenguaje Ruby, pagos simples en tu sitio web. Consume el Culqi API.

Versión actual Culqi API
0.0.7 (2017-04-08) v2

Requisitos

  • Ruby >= 2.0.0
  • Credenciales de comercio en Culqi (1).

Ejemplos

Inicialización

require 'securerandom'
require 'culqi-ruby'

Culqi.public_key = '{LLAVE_PUBLICA}'
Culqi.secret_key = '{LLAVE_SECRETA}'

Crear Token

token = Culqi::Token.create(
    :card_number => '4111111111111111',
    :cvv => '123',
    :currency_code => 'PEN',
    :email => '[email protected]',
    :expiration_month => 9,
    :expiration_year => 2020
)

jsonToken = JSON.parse(token)

puts jsonToken['id']

Crear Cargo

charge = Culqi::Charge.create(
    :amount => 1000,
    :capture => true,
    :currency_code => 'PEN',
    :description => 'Venta de prueba',
    :email => '[email protected]',
    :installments => 0,
    :metadata => ({
        :test => 'test123'
    }),
    :source_id => jsonToken['id']
)

jsonCharge = JSON.parse(charge)

Crear Plan

plan = Culqi::Plan.create(
    :amount => 1000,
    :currency_code => 'PEN',
    :interval => 'dias',
    :interval_count => 2,
    :limit => 10,
    :metadata => ({
    :alias => 'plan_test'
    }),
    :name => 'plan-test-'+SecureRandom.uuid,
    :trial_days => 50
)

jsonPlan = JSON.parse(plan)

Crear Costumer

customer = Culqi::Customer.create(
    :address => 'Avenida Lima 123213',
    :address_city => 'LIMA',
    :country_code => 'PE',
    :email => 'test'+SecureRandom.uuid+'@culqi.com',
    :first_name => 'William',
    :last_name => 'Muro',
    :metadata => ({
      :other_number => '789953655'
    }),
    :phone_number => 998989789
)

jsonCustomer = JSON.parse(customer)

Actualizar Costumer

updatecustomer = Culqi::Customer.update('cus_test_F5voBd1yHsCkjSwF',
      :address => 'Av. Lima 123',
      :first_name => 'Will')

Obtener Costumer

getcustomer = Culqi::Customer.get('cus_test_F5voBd1yHsCkjSwF')

Crear Card

card = Culqi::Card.create(
  :customer_id => jsonCustomer['id'],
  :token_id => jsonToken['id']
)

jsonCard = JSON.parse(card)

Crear Suscripción

subscription = Culqi::Subscription.create(
  :card_id => jsonCard['id'],
  :plan_id => jsonPlan['id']
)

jsonSubscription = JSON.parse(subscription)

Crear Reembolso

refund = Culqi::Refund.create(
  :amount => 500,
  :charge_id => jsonCharge['id'],
  :reason => 'solicitud_comprador'
)

jsonRefund = JSON.parse(refund)

Documentación

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

Build

gem build culqi-ruby.gemspec
gem install ./culqi-ruby-{VERSION}.gem
gem push culqi-ruby-{VERSION}.gem

Changelog

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

Testing

Solo debe ejecutar el siguiente comando

rake test

Autor

Willy Aguirre (@marti1125 - Team Culqi)

Licencia

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

culqi-ruby's People

Contributors

brayancruces avatar marti1125 avatar william-muro-culqi avatar

Watchers

 avatar  avatar  avatar

Forkers

ignaciosm

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.