# Node.js Admin SDK

In order to use it you will need to install it through the following *npm* command :

```
$ npm i @kkiapay-org/nodejs-sdk
```

## Module import

```typescript
const { kkiapay } = require("@kkiapay-org/nodejs-sdk"); // javascript
ou
import { kkiapay } from "@kkiapay-org/nodejs-sdk"; // typescript
```

## Initialization&#x20;

The use of the server Admin SDK requires the creation of a *kkiapay* object. In order to create that object, you will need to retrieve your API keys and to use the following commands whether you are in Sandbox mode or in production.

* In Sandbox

```javascript
const k = kkiapay({privatekey:"xxxxxxx",
                   publickey:"xxxxxxx",
                   secretkey:"xxxxxxx",
                   sandbox:true})
```

{% hint style="info" %}
When the attribute`sandbox`is set to ***true*** you're in test mode.
{% endhint %}

* In live

```javascript
const k = kkiapay({privatekey:"xxxxxxx",
                   publickey:"xxxxxxx",
                   secretkey:"xxxxxxx"})
```

## Status of a transaction

KKiaPay allow you to retrieve all the information related to a transaction. To do this, you will need to fill in the following fields:&#x20;

* Your public, private and secret API keys
* The reference of the operation (see the image below)

![](/files/-LhkBg3LnqA8lHNZqn1i)

### Example&#x20;

You can use the following code to test this feature:

```javascript
k.verify("transactionId").
then((response) => {
    "performed_at": "2025-04-10T15:01:49.499Z",
    "type": "DEBIT",
    "status": "SUCCESS",
    "source": "MOBILE_MONEY",
    "source_common_name": "mtn-benin",
    "amount": 40,
    "fees": 1,
    "reason": "payment",
    "failureCode": "",
    "failureMessage": "",
    "state": null,
    "partnerId": "",
    "feeSupportedBy": "customer",
    "income": 40,
    "transactionId": "0845058258857440",
    "performedAt": "10/04/2025",
    "client": {
        "fullname": "John Doe",
        "phone": "22997000000",
        "email": "john.doe@gmail.com"
    }
}).
catch((error) => {
    //Gérer l'erreur
})
```

## **Refund a transaction**

Any ***success*** transaction made by mobile money can be subject to a refund operation. You have the possibility to make a refund if your customer hasn't obtained satisfaction for the service for which he paid or if you consider it necessary. In order to carry out such an operation, you will need to provide the following information:

* Your public, private and secret API keys
* The reference of the operation (see the image below)

![](/files/-LhkBg3LnqA8lHNZqn1i)

{% hint style="info" %}
The refund of a transaction doesn't include the refund of the fees related to.
{% endhint %}

### Example&#x20;

You can use the following code to test this feature:

```javascript
k.refund("transactionId").
then((response) => {
    //Handle the response
}).
catch((error) => {
    //Handle the error
})
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kkiapay.me/v1/en-1.0.0/plugin-et-sdk/admin-sdks-server-side/node.js-admin-sdk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
