Khipu payments API client for Node.js applications.
npm install --save fi-khipu
var khipu = require('fi-khipu');
This module must be configured with your receiver ID and secret before using it:
khipu.configure(receiverId, secret);
Any other configuration options can be done directly to the config
property:
khipu.config.sslVerification = false;
A list with full configuration options will be added soon.
This module exposes convenient methods to perform the API calls:
This method is called with just a callback Function
that will receive a KhipuException
custom error object if any and a bank
Array
if any:
khipu.listBanks(function callback(err, banks) {
if (err) {
throw err;
}
//...
});
This method must be called with the payment Object
and a callback Function
that will receive a KhipuException
custom error if any and the created payment information if any:
var payment = {
subject: 'Payment subject',
amount: 100
//...
};
khipu.createPayment(payment, function callback(err, payment) {
if (err) {
throw err;
}
//...
});
This method must be called with the payment ID String
and a callback Function
that will receive a KhipuException
custom error if any and the requested payment information if any:
var paymentId = 'Aa1...Jw1';
khipu.getPaymentById(paymentId, function (err, payment) {
if (err) {
throw err;
}
//...
});
This method must be called with the payment's notification token String
and a callback Function
that will receive a KhipuException
custom error if any and the requested payment information if any:
var notificationToken = 'Aa1bB2...KhqJw1';
khipu.getPaymentByNotificationToken(notificationToken, function (err, payment) {
if (err) {
throw err;
}
//...
});
This method must be called with the payment ID String
and a callback Function
that will receive a KhipuException
custom error if any and the deleted payment information if any:
var paymentId = 'Aa1...Jw1';
khipu.deletePayment(paymentId, function (err, payment) {
if (err) {
throw err;
}
//...
});
This method must be called with the payment ID String
and a callback Function
that will receive a KhipuException
custom error if any and the refunded payment information if any:
var paymentId = 'Aa1...Jw1';
khipu.refundPayment(paymentId, function (err, payment) {
if (err) {
throw err;
}
//...
});
This is an extended Error
Object
with the following additional properties:
- notice: A short version of the error message that does not exposes request data.
- headers: The associated array headers as an
Object
if possible. - body: The request response body as an
Object
if possible. - code: The request response code if available.
To test this module you must first clone the repository as the test
folder is excluded from npm
installations. After you've cloned the repository you must create a config.json
inside the test
folder with your receiverId
and secret
:
{
"receiverId": 10101,
"secret": "30519b...d85c51"
}
This file is git-ignored to keep this data safe.
Each test will generate a test/tests.log
file with additional information on the tests. This file is deleted and created again on each test.