open-index/open-npm huggingface dataset:
npm package: @pay3/sdk
Description: <br>
Latest version: 1.8.1

# **Pay3 JS SDK**

<br>

## **Installation and Usage**

### Installation

Install the package by running the command,

`npm install @pay3/sdk`

<br>

Import the package into your project using,

`import { initPay3 } from '@pay3/sdk';`

<br>

Initialise Pay3 SDK,

```
const pay3 = initPay3({ clientId, hostname, isPaymentMode: true });
```

* `clientId` - A unique client ID is created for each client application. The client ID is environment dependent.
* `hostname` - Pay3 will be opened in a new window using this hostname prefix. The host name is environment dependent.
* `isPaymentMode` (optional. default: `false`) - Pass true for fiat checkout in payments only mode.

<hr>

### Event Listeners

Login status change
```
pay3.on('pay3-sdk-login-status', (event) => {
    const { data: { isLoggedIn, address } } = event;
    // Your code here
});
```

<br>

Transaction status change
```
pay3.on('pay3-sdk-transaction-status', (event) => {
    const { data: { message, requestId, receipt, status, orderId } } = event;
    // Your code here
});
```

<hr>

### Functions

#### Connect
This function is used to open the EasySign modal in a new window

```
pay3.connect({ requestId });
```

* `requestId` (optional) - Can pass a random id string to identify the request. This requestId will be present in the `pay3-sdk-login-status` event data.

<br>

#### Open Checkout
This function will open the fiat checkout flow
```
const checkoutRequest = {
    requestId,
    user: {
        email: "user@email.address"  // User's email address
    },
    payment: [
        {
            amount: 6.00",             // Amount in fiat currency
            name: "brl_bz",         // Currency code (e.g. brl_bz)
        },
        {
            amount: "4.05",
            name: "usd_usa",
        }
    ],
    checkout: {
        description: "Checkout Description",
        imgUrl: "https://sample-image-url.com",
    },
    userMessage: "Some message for the user"
};


pay3.openCheckout(checkoutRequest);
```

<br>

Link to Documentation 
https://docs.pay3.money/pay3-javascript-sdk