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
// Add your Conekta API private keyconekta try // Create customer const customer = await name: 'John Appleseed' email: 'johnappleseed@mail.com' // Update customer attributes customername = 'Mr. John Appleseed' await customer // Add payment sources const paymentSource = await customer // Get customer by id const otherCustomer = await conektaCustomer catch error console
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