paycools
v1.0.1
Published
PayCools SDK for Node.js.
Maintainers
Readme
paycools
PayCools SDK for Node.js.
Install
$ npm i paycools --saveExample
import PayCools from 'paycools'
const payCoolsClient = new PayCools({
appId: 'xxx',
apiHost: 'xxx',
secretKey: 'xxx',
webhookPublicKey: 'xxx'
})
;(async () => {
/*
{
code: 10000,
message: 'Success',
data: {
checkoutId: 'xxx',
checkoutUrl: 'https://globalapi-dev.paycools.com:8904/cashier/checkout/UIueruXflQmagScTtcLUfdxouXAvCuDh2lMuahSLAUw=',
status: 'PENDING',
expiresTime: '2026-03-02 09:56:45'
}
}
*/
console.log(await payCoolsClient.execute({
method: 'POST',
url: '/open-api/payment/checkout/generate',
body: {
appId: 'xxx',
param: {
timestamp: Date.now(),
mchOrderId: String(Date.now()),
countryCode: 'RU',
currency: 'RUB',
settlementCurrency: 'RUB',
amount: 100,
customerName: 'test',
email: '[email protected]',
mobile: '9516652989',
notifyUrl: 'https://webhook.site/6ffb6916-6de8-46c4-8c82-bbdd081345f0',
redirectUrl: 'https://google.com',
}
}
}))
/*
{
code: 10000,
message: 'Success',
data: {
checkoutId: 'xxx',
status: 'CLOSED',
expiresTime: '2026-03-02 09:56:45'
}
}
*/
console.log(await paycoolsClient.execute({
method: 'POST',
url: '/open-api/payment/checkout/query',
body: {
appId: 'xxx',
param: {
timestamp: Date.now(),
checkoutId: 'xxx'
}
}
}))
/*
verify webhook sign:
{
"param": "xxx",
"sign": "xxx"
}
*/
console.log(await paycoolsClient.verifyWebhookSign("xxx", "xxx"))
})().catch(console.error)