0.1.5 • Published 6 years ago

conekta-kiss v0.1.5

Weekly downloads
8
License
MIT
Repository
github
Last release
6 years ago

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: 'johnappleseed@mail.com',
  }).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

NameType
idString
emailString
nameString
phone optionalString
shippingContacts optional[conekta.ShippingContact]
paymentSources optional[conekta.PaymentSource]
defaultPaymentSourceId optionalString
defaultShippingContactId optionalString

Functions

NameReturnsDescription
Customer({ name: String, email: String, phone: String })conekta.CustomerConstructor Creates conekta.Customer instance, to save to call .save()
Customer.findById(id: String)Promise => conekta.CustomerFinds customer by given id (static)
Customer.deleteById(id: String)Promise => BooleanRemoves customer by given id (static)
Customer.update(id: String, customer: Object)Promise => conekta.CustomerUpdates existing customer
save()Promise => BooleanSaves customer instance, creating new or updating
remove()Promise => BooleanRemoves existing customer
addPaymentSource(paymentSource: Object)Promise => conekta.PaymentSourceAdds payment source to existing customer
removePaymentSource(id: String)Promise => BooleanRemoves payment source from existing customer

PaymentSource

conekta.PaymentSource

Attributes

NameTypeDescription
idString
last4StringLast 4 digits of card
typeStringPayment type ['card']
createdAtDate
binIntBank Identification Number
expMonthIntMonth of expiry (1 - 12)
expYearIntYear of expiry (four-digit)
brandStringCard brand ['VISA', 'MC', 'AMERICAN_EXPRESS']
nameStringCardholder's name
customerIdString
isDefaultBoolean

Functions

NameReturnsDescription
PaymentSource({ token: String, customer: String, type: String })Promise => conekta.PaymentSourceConstructor
PaymentSource.update(id: String, paymentSource: Object)Promise => conekta.PaymentSourceUpdates payment source by given id
save()Promise => conekta.PaymentSourceUpdates payment source instance
remove()Promise => BooleanDeletes payment source

Order

conekta.Orders

Attributes

NameTypeDescription
currencyStringCurrency of the charge
customerInfoObject
lineItemsInt
charges[Object]
taxLinesString optional

Functions

NameReturnsDescription
Order({ currency: String, customerInfo: Object, lineItems: [Object], charges: [Object] })Promise => conekta.OrderConstructor

Todo

  • Plans
  • Subscriptions

License

MIT

0.1.5

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago