Based on KISS principle
Conekta NodeJS SDK for people who like modern JS, small dependencies and code that can be written and understood.
~ npm i conekta-kiss # yarn add conekta-kiss
node >= 6.0.0
Get your Conekta API keys at https://admin.conekta.com/
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)
}
conekta.Customer
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 |
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 |
conekta.PaymentSource
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 |
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 |
conekta.Orders
Name | Type | Description |
---|---|---|
currency |
String |
Currency of the charge |
customerInfo |
Object |
|
lineItems |
Int |
|
charges |
[Object] |
|
taxLines |
String optional |
Name | Returns | Description |
---|---|---|
Order({ currency: String, customerInfo: Object, lineItems: [Object], charges: [Object] }) |
Promise => conekta.Order |
Constructor |
- Plans
- Subscriptions
MIT