Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.2.1

- The README documents the enums and uses them in its examples, instead of the bare strings it
still showed.

## 0.2.0

- Enums for the values the API uses: `Status`, `CardStatus`, `InvoiceStatus`, `B2BStatus`,
Expand Down
40 changes: 38 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ try {
## Configuration

```ts
import { Currency, EpointClient, Language } from '@martian56/epoint'

new EpointClient({
publicKey: 'i000000001',
privateKey: 'your-private-key',
baseUrl: 'https://epoint.az',
language: 'az',
currency: 'AZN',
language: Language.AZ,
currency: Currency.AZN,
successRedirectUrl: 'https://shop.example/thanks',
errorRedirectUrl: 'https://shop.example/failed',
})
Expand Down Expand Up @@ -91,6 +93,40 @@ status.raw // the full response object, snake_case

`getInstallmentPlans` resolves to an array and `listWallets` to a record.

## Enums

Every value the API uses has an enum. They come from the sandbox's own definitions, so they match
what production sends. Each is a const object with a matching type, so you get both the values
and the union, and a plain string still works anywhere an enum is accepted.

```ts
import { Currency, EpointClient, Language, Status } from '@martian56/epoint'

const client = EpointClient.fromEnv({ language: Language.EN, currency: Currency.USD })

const status = await client.getStatus(transaction)
if (status.status === Status.SUCCESS) {
await fulfil(orderId)
}
```

| Enum | Values |
|---|---|
| `Status` | new, success, failed, error, returned, server_error |
| `CardStatus` | new, active, pending, rejected, expired, session_expired |
| `InvoiceStatus` | waiting_for_payment, paid, canceled |
| `B2BStatus` | PENDING, PROCESSING, SUCCESS, FAILED |
| `OperationCode` | 001 card registration, 100 payment, 200 registration with payment |
| `Language` | az, en, ru |
| `Currency` | AZN, USD, EUR, RUB |

Currency is not uniform across the API. Checkout takes all four, but split, pre-auth, refund,
reverse, payout and wallet take AZN and nothing else. `SUPPORTED_CURRENCIES` and `AZN_ONLY` hold
those two sets.

`SETTLED_STATUSES` is what `ok` checks, and `USABLE_CARD_STATUSES` is the set a card has to be in
before you can charge it.

## Methods

| Group | Methods |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@martian56/epoint",
"version": "0.2.0",
"version": "0.2.1",
"description": "TypeScript client for the epoint.az payment gateway",
"type": "module",
"license": "MIT",
Expand Down
Loading