Thawani node is a nodejs client for Thawani API
this document is didicated for the pure purpose of
migration of the plugin before the version 1.1.0
if you have the early version before 1.1.0
the the class initialization will be this way
The documentation of the previous version prior to version 1.1.0 is here
const api = new ThawaniClient(
"your_secret_key",
"your_publishable_key",
"dev|prod"
);
and now it's like this
const api = new ThawaniClient({
secretKey: 'your_app_secret_key',
publishableKey : 'your_app_publishable_key',
dev : true // false to set it for production
});
and this change can break your code or application
Take a look in the developer docs so you have a better about the idea and the payload of each endpoint & you may not need this package if you are aiming to use only 1 or 2 end-points
The package does not provide any helper function for formatting the payload
The package does not validate your payload
const api = new ThawaniClient({
secretKey: 'your_app_secret_key',
publishableKey : 'your_app_publishable_key',
dev : true, // false to set it for production
filter: { // optional
skip: 1,
limit:10
}
});
secretKey
- required the secret key provided by ThawanipublishableKey
- require the publishable key provided by Thawanidev
- required if this value set to true
then the API will call the development end-pointsfilter
- optional by default the filter object has two keys skip
and limit
and they represent the page number and the result in each page
skip
- optional page number default set to 1limit
- optional number of result in each page default is 10 and the max is 50.Sessions API are responsible of creating the payment and redirecting the user to Thawani checkout page
note all the function are promised based.
await api.session.create(payload);
const redirectFullURL = api.redirect(session_id);
await api.sesssion.getSessionByID(session_id); // return a promise
await api.session.findAll();
or you can pass filter
object same as the class construct
await api.session.findAll({
skip :2,
limit: 20
});
await api.session.findSessionByReference(session_number);
await api.session.findSessionByReceipt(receipt_number);
The customer endpoint allow you to create a customer token in order for saving the customer credit card in Thawani servers and skipping the payment method when purchasing again
all the endpoints returns a promise
You can pass any thing is unique to the customer his email or phone number
await api.customer.create(customer_id)
By passing the customer token
await api.customer.find(customer_token);
await api.customer.findAll();
or by passing a filter
await api.customer.findAll({
skip:1,
limit:30
});
await api.customer.remove(customer_token);
Payments endpoint shows the card type the customer uses
await api.payment.find(customer_token)
await api.payment.remove(card_token)
Get the payment transaction details
await api.paymentTransaction.find(payment_id);
await api.paymentTransaction.findAll();
Or by passing a filter
as a parameter
await api.paymentTransaction.findAll({
skip:1,
limit:12
});
Refund APi for getting refund to the client directly before the amount transferred to your account
await api.refund.create(payload);
await api.refund.find();
await api.refund.findAll();
or by passing a filter
await api.refund.findAll({
skip:2,
limit:12
});
This endpoint to create a quick payments
await api.paymentIntent.create(payload);
await api.paymentIntent.confirm(paymentIntent_id);
await api.paymentIntent.create(paymentIntent_id);
await api.paymentIntent.find(paymentIntent_id);
await api.paymentIntent.findByReference(reference_id);
await api.paymentIntent.findAll();
or by passing a filter
as parameter
await api.paymentIntent.findAll({
skip:2,
limit:10
});