> ## Documentation Index
> Fetch the complete documentation index at: https://developers.pcibooking.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Library Reference

> JavaScript API reference for PCI Booking's Payments Library. Methods, events, configuration options, and callbacks.

## Constructor

```javascript theme={null}
const engine = new eWallet.Engine(sessionToken, requiredAncillaryInfo, language, uiOptions);
```

### Parameters

| Parameter               | Type     | Required | Description                                     |
| ----------------------- | -------- | -------- | ----------------------------------------------- |
| `sessionToken`          | `string` | Yes      | Session token obtained from the PCI Booking API |
| `requiredAncillaryInfo` | `object` | No       | Billing and shipping data requirements          |
| `language`              | `string` | No       | UI language code (auto-detected if omitted)     |
| `uiOptions`             | `object` | No       | UI display configuration                        |

### Supported Languages

`EN`, `ES`, `FR`, `DE`, `IT`, `PT`, `NL`, `PL`, `RU`, `JA`, `ZH`, `KO`, `AR`, `HE`, `TR`, `SV`, `NO`, `DA`, `FI`, and more.

### UI Options

| Property                  | Type      | Default   | Description                                                               |
| ------------------------- | --------- | --------- | ------------------------------------------------------------------------- |
| `hideLogo`                | `boolean` | `false`   | Hide the merchant logo in the payment UI                                  |
| `displayMode`             | `string`  | `'popup'` | Card form display mode: `'popup'` or `'iframe'`                           |
| `iframeContainerSelector` | `string`  |           | CSS selector for the container element when using `'iframe'` display mode |

```javascript theme={null}
const engine = new eWallet.Engine(sessionToken, null, 'EN', {
  displayMode: 'iframe',
  iframeContainerSelector: '#card-form-container',
  hideLogo: true
});
```

## Methods

### `checkAvailability()`

Returns a Promise that resolves to a list of payment methods available for the current session and device. **This method is async.**

```javascript theme={null}
const methods = await engine.checkAvailability();
// e.g. ['CardPay', 'ApplePay', 'GooglePay']
```

The result depends on the session configuration, browser capabilities, and device support. For example, Apple Pay only appears in Safari.

### `payBy(eWalletList, callback, buttonProperties)`

Renders payment buttons and starts the payment flow.

| Parameter          | Type       | Description                                                                 |
| ------------------ | ---------- | --------------------------------------------------------------------------- |
| `eWalletList`      | `array`    | Payment methods to display (from `checkAvailability()`)                     |
| `callback`         | `function` | Called with the result object on completion, or `undefined` on cancellation |
| `buttonProperties` | `object`   | Button rendering options (container selector, styling)                      |

```javascript theme={null}
engine.payBy(['CardPay', 'ApplePay'], function(result) {
  if (!result) return; // cancelled
  console.log(result.token);
}, {
  containerSelector: '#payment-buttons'
});
```

### `parseResultToken(token)`

Decodes a result token into structured data.

```javascript theme={null}
const [data, success] = engine.parseResultToken(result.token);
```

Returns a tuple of `[data, success]` where `data` contains transaction details and `success` is a boolean indicating client-side success.

### `getSessionType()`

Returns the operation type for the current session.

```javascript theme={null}
const type = engine.getSessionType();
// e.g. 'CHARGE', 'TOKENIZE', 'CHARGE_AND_TOKENIZE'
```

### `getSelectedProviderName()`

Returns the name of the payment method the user selected.

```javascript theme={null}
const provider = engine.getSelectedProviderName();
// e.g. 'CardPay', 'ApplePay'
```

### `getBillingInfo()`

Returns billing address data collected during the payment flow, if applicable.

### `getShippingInfo()`

Returns shipping address data collected during the payment flow, if applicable.

## Operations

| Operation              | Description                                              |
| ---------------------- | -------------------------------------------------------- |
| `CHARGE`               | Process a one-time payment                               |
| `TOKENIZE`             | Store the payment method for future use without charging |
| `CHARGE_AND_TOKENIZE`  | Process a payment and store the method for future use    |
| `PREAUTH_AND_TOKENIZE` | Pre-authorize an amount and store the method             |
| `GATEWAY_TOKENIZE`     | Tokenize directly with the payment gateway               |

The operation type is set when creating the session via the PCI Booking API and determines which payment methods and flows are available.

## Related

* [Payments Library Overview](/payments-library/overview) - Introduction and architecture
* [Setup Guide](/payments-library/setup) - Integration steps and session creation
* [Supported Methods](/payments-library/supported-methods) - Available payment methods and browser compatibility
