GithubHelp home page GithubHelp logo

conekta-kiss's Introduction

Conekta KISS banner

Conekta Node SDK

npm version Dependencies Dependencies

Maintainability

Based on KISS principle

Conekta NodeJS SDK for people who like modern JS, small dependencies and code that can be written and understood.

Installation

~ npm i conekta-kiss # yarn add conekta-kiss

Documentation

Requirements

  • node >= 6.0.0

Setup

Get your Conekta API keys at https://admin.conekta.com/

Usage example

import conekta from 'conekta-kiss'

// Add your Conekta API private key
conekta.configure('9YxqfRnx4sMQDnRsqdYn')

try {
  // Create customer
  const customer = await new conekta.Customer({
    name: 'John Appleseed',
    email: '[email protected]',
  }).save()

  // Update customer attributes
  customer.name = 'Mr. John Appleseed'
  await customer.save()

  // Add payment sources
  const paymentSource = await customer.addPaymentSource({
    tokenId: 'a0s9j0as9dj32',
    // default type: 'card'
  })

  // Get customer by id
  const otherCustomer = await conekta.Customer.findById('9j821831283huas')
} catch (error) {
  console.log('Some error ocurred', error)
}

API

Customer

conekta.Customer

Attributes

Name Type
id String
email String
name String
phone optional String
shippingContacts optional [conekta.ShippingContact]
paymentSources optional [conekta.PaymentSource]
defaultPaymentSourceId optional String
defaultShippingContactId optional String

Functions

Name Returns Description
Customer({ name: String, email: String, phone: String }) conekta.Customer Constructor Creates conekta.Customer instance, to save to call .save()
Customer.findById(id: String) Promise => conekta.Customer Finds customer by given id (static)
Customer.deleteById(id: String) Promise => Boolean Removes customer by given id (static)
Customer.update(id: String, customer: Object) Promise => conekta.Customer Updates existing customer
save() Promise => Boolean Saves customer instance, creating new or updating
remove() Promise => Boolean Removes existing customer
addPaymentSource(paymentSource: Object) Promise => conekta.PaymentSource Adds payment source to existing customer
removePaymentSource(id: String) Promise => Boolean Removes payment source from existing customer

PaymentSource

conekta.PaymentSource

Attributes

Name Type Description
id String
last4 String Last 4 digits of card
type String Payment type ['card']
createdAt Date
bin Int Bank Identification Number
expMonth Int Month of expiry (1 - 12)
expYear Int Year of expiry (four-digit)
brand String Card brand ['VISA', 'MC', 'AMERICAN_EXPRESS']
name String Cardholder's name
customerId String
isDefault Boolean

Functions

Name Returns Description
PaymentSource({ token: String, customer: String, type: String }) Promise => conekta.PaymentSource Constructor
PaymentSource.update(id: String, paymentSource: Object) Promise => conekta.PaymentSource Updates payment source by given id
save() Promise => conekta.PaymentSource Updates payment source instance
remove() Promise => Boolean Deletes payment source

Order

conekta.Orders

Attributes

Name Type Description
currency String Currency of the charge
customerInfo Object
lineItems Int
charges [Object]
taxLines String optional

Functions

Name Returns Description
Order({ currency: String, customerInfo: Object, lineItems: [Object], charges: [Object] }) Promise => conekta.Order Constructor

Todo

  • Plans
  • Subscriptions

License

MIT

conekta-kiss's People

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

jtapia

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.