conekta-kiss
v0.1.5
Published
Conekta SDK for Node
Downloads
6
Readme
Conekta Node SDK
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