This library is an implementation made in javascript of the Khipu API, it is incomplete and only contemplates functionalities that will be used by banks and payments, if you want to add the rest, do it without problems.
Current support Khipu API version 2.0
Npm:
npm install --save khipujs
Yarn:
yarn add khipujs
Make sure you have created your free account on Khipu and that you have your Credentials.
import Khipu from 'khipujs'
const khipu = new Khipu({
commerceId: 'COMMERCE_ID',
secretKey: 'YOUR_SECRET_KEY'
})
khipu.payments
.withNotificationToken({
notification_token: 'string'
})
.then(response => {})
.catch(error => console.log(error)) // Handle the error.
khipu.payments
.create({
subject: 'First Product',
currency: 'CLP',
amount: '1000'
})
.then(response => {})
.catch(error => console.log(error)) // Handle the error.
khipu.payments
.read(paymentId)
.then(response => {})
.catch(error => console.log(error)) // Handle the error.
khipu.payments
.delete(paymentId)
.then(response => {})
.catch(error => console.log(error)) // Handle the error.
khipu.banks
.list()
.then(response => {})
.catch(error => console.log(error)) // Handle the error.