This documentation is before
the version 1.1.0 - you don't need to change the version if don't need but it's always better to be up-2-date 😃
please refer to Thawani developer Documentation
npm i thawani-node
const ThawaniClient = require("thawani-node");
const api = new ThawaniClient(
"your_secret_key",
"your_publishable_key",
"dev|prod"
);
api
.create_customer({
client_customer_id: "Muhannad.alrisi@gmail.com",
})
.then((data) => {
console.log(data);
})
.catch((err) => console.error(err));
The following methods/functions are performing the customer endpoint API
Get a single customer by passing the the customer token
api
.find_customer((customer_token: string))
.then((data) => console.log(data))
.catch((err) => console.error(err));
Get all customers please refer to the Developer Docs
api
.findAll_customers()
.then((data) => console.log(data))
.catch((err) => console.error(err));
or
api
.findAll_customers({ skip: 1, limit: 10 })
.then((data) => console.log(data))
.catch((err) => console.error(err));
Create a new customer
api
.create_customer({
client_customer_id: "Muhannad.alrisi@gmail.com",
})
.then((data) => {
console.log(data);
})
.catch((err) => console.error(err));
To delete a customer
api
.delete_customer(customer_key)
.then((data) => console.log(data))
.catch((err) => console.error(err));
The following functions/methods are related to Session endpoint please refer to the developer docs
Create a session to get the session token to use it later for the payment process
api
.create_session(payload)
.then((data) => console.log(data))
.catch((err) => console.error(err));
to get the information about a session by passing the session id
api
.find_session(session_id)
.then((data) => console.log(data))
.catch((err) => console.error(err));
To get all the sessions
api
.findAll_sessions()
.then((data) => console.log(data))
.catch((err) => console.error(err));
or
api
.findAll_sessions({ skip: 1, limit: 10 })
.then((data) => console.log(data))
.catch((err) => console.error(err));
pass the session id after a success creation to get the full path for the payment API
const full_redirect_uri = api.redirect(session_id);
the following API are related to the customer payments methods please refer to the developer docs
To get customer payment method
api
.get_customer_payment({
customerId: "customer_id",
})
.then((data) => console.log(data))
.catch((err) => console.error(err));
To remove customer payment methods
api
.remove_customer_payment(card_token)
.then((data) => console.log(data))
.ctach((err) => console.error(err));