velirapay 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +699 -51
- package/dist/cjs/client.d.ts +1 -1
- package/dist/cjs/enums.d.ts +159 -27
- package/dist/cjs/enums.js +150 -25
- package/dist/cjs/errors.d.ts +10 -1
- package/dist/cjs/errors.js +12 -1
- package/dist/cjs/http/transport.js +18 -3
- package/dist/cjs/index.d.ts +3 -3
- package/dist/cjs/index.js +12 -2
- package/dist/cjs/page.d.ts +14 -2
- package/dist/cjs/page.js +19 -2
- package/dist/cjs/params.d.ts +17 -10
- package/dist/cjs/resources/account.d.ts +13 -13
- package/dist/cjs/resources/account.js +7 -7
- package/dist/cjs/resources/activity.d.ts +4 -3
- package/dist/cjs/resources/activity.js +1 -1
- package/dist/cjs/resources/api-key.d.ts +3 -2
- package/dist/cjs/resources/api-resource.d.ts +2 -0
- package/dist/cjs/resources/api-resource.js +5 -0
- package/dist/cjs/resources/charge.d.ts +7 -3
- package/dist/cjs/resources/charge.js +6 -0
- package/dist/cjs/resources/coupon.d.ts +2 -1
- package/dist/cjs/resources/event.d.ts +3 -3
- package/dist/cjs/resources/event.js +1 -1
- package/dist/cjs/resources/invoice.d.ts +4 -4
- package/dist/cjs/resources/member.d.ts +5 -4
- package/dist/cjs/resources/member.js +2 -2
- package/dist/cjs/resources/overview.d.ts +116 -4
- package/dist/cjs/resources/overview.js +76 -3
- package/dist/cjs/resources/payment-link.d.ts +3 -3
- package/dist/cjs/resources/payout.d.ts +5 -5
- package/dist/cjs/resources/payout.js +1 -1
- package/dist/cjs/resources/pro-payment.d.ts +3 -2
- package/dist/cjs/resources/supported-asset.d.ts +2 -2
- package/dist/cjs/resources/webhook-endpoint.d.ts +5 -4
- package/dist/cjs/resources/webhook-endpoint.js +3 -2
- package/dist/cjs/services/account.js +1 -1
- package/dist/cjs/services/api-keys.d.ts +7 -1
- package/dist/cjs/services/api-keys.js +7 -1
- package/dist/cjs/services/assets.d.ts +3 -4
- package/dist/cjs/services/assets.js +3 -2
- package/dist/cjs/services/charges.js +3 -3
- package/dist/cjs/services/coupons.js +1 -1
- package/dist/cjs/services/invoices.js +5 -1
- package/dist/cjs/services/members.d.ts +2 -2
- package/dist/cjs/services/members.js +2 -2
- package/dist/cjs/services/overview.d.ts +1 -1
- package/dist/cjs/services/overview.js +3 -2
- package/dist/cjs/services/payment-links.js +4 -2
- package/dist/cjs/services/payout-addresses.d.ts +9 -4
- package/dist/cjs/services/payout-addresses.js +6 -2
- package/dist/cjs/services/service.d.ts +8 -3
- package/dist/cjs/services/service.js +45 -10
- package/dist/cjs/services/webhook-endpoints.d.ts +15 -2
- package/dist/cjs/services/webhook-endpoints.js +15 -2
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/client.d.ts +1 -1
- package/dist/esm/enums.d.ts +159 -27
- package/dist/esm/enums.js +149 -24
- package/dist/esm/errors.d.ts +10 -1
- package/dist/esm/errors.js +12 -1
- package/dist/esm/http/transport.js +18 -3
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.js +3 -3
- package/dist/esm/page.d.ts +14 -2
- package/dist/esm/page.js +17 -1
- package/dist/esm/params.d.ts +17 -10
- package/dist/esm/resources/account.d.ts +13 -13
- package/dist/esm/resources/account.js +8 -8
- package/dist/esm/resources/activity.d.ts +4 -3
- package/dist/esm/resources/activity.js +1 -1
- package/dist/esm/resources/api-key.d.ts +3 -2
- package/dist/esm/resources/api-resource.d.ts +2 -0
- package/dist/esm/resources/api-resource.js +4 -0
- package/dist/esm/resources/charge.d.ts +7 -3
- package/dist/esm/resources/charge.js +6 -0
- package/dist/esm/resources/coupon.d.ts +2 -1
- package/dist/esm/resources/event.d.ts +3 -3
- package/dist/esm/resources/event.js +1 -1
- package/dist/esm/resources/invoice.d.ts +4 -4
- package/dist/esm/resources/member.d.ts +5 -4
- package/dist/esm/resources/member.js +2 -2
- package/dist/esm/resources/overview.d.ts +116 -4
- package/dist/esm/resources/overview.js +77 -4
- package/dist/esm/resources/payment-link.d.ts +3 -3
- package/dist/esm/resources/payout.d.ts +5 -5
- package/dist/esm/resources/payout.js +1 -1
- package/dist/esm/resources/pro-payment.d.ts +3 -2
- package/dist/esm/resources/supported-asset.d.ts +2 -2
- package/dist/esm/resources/webhook-endpoint.d.ts +5 -4
- package/dist/esm/resources/webhook-endpoint.js +3 -2
- package/dist/esm/services/account.js +2 -2
- package/dist/esm/services/api-keys.d.ts +7 -1
- package/dist/esm/services/api-keys.js +7 -1
- package/dist/esm/services/assets.d.ts +3 -4
- package/dist/esm/services/assets.js +3 -2
- package/dist/esm/services/charges.js +4 -4
- package/dist/esm/services/coupons.js +2 -2
- package/dist/esm/services/invoices.js +6 -2
- package/dist/esm/services/members.d.ts +2 -2
- package/dist/esm/services/members.js +2 -2
- package/dist/esm/services/overview.d.ts +1 -1
- package/dist/esm/services/overview.js +4 -3
- package/dist/esm/services/payment-links.js +5 -3
- package/dist/esm/services/payout-addresses.d.ts +9 -4
- package/dist/esm/services/payout-addresses.js +6 -2
- package/dist/esm/services/service.d.ts +8 -3
- package/dist/esm/services/service.js +44 -10
- package/dist/esm/services/webhook-endpoints.d.ts +15 -2
- package/dist/esm/services/webhook-endpoints.js +15 -2
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +12 -2
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import type { ActivityAction, Mode, OrString } from '../enums.ts';
|
|
1
2
|
import { ApiResource, type Attributes } from './api-resource.ts';
|
|
2
3
|
/** One thing done in the account, from its activity log. */
|
|
3
4
|
export declare class Activity extends ApiResource {
|
|
4
5
|
/** The entry's id. */
|
|
5
6
|
readonly id: string;
|
|
6
|
-
/**
|
|
7
|
-
readonly action:
|
|
7
|
+
/** One of the ActivityAction values, such as "api_key.created". */
|
|
8
|
+
readonly action: OrString<ActivityAction>;
|
|
8
9
|
/** What was done, in words. */
|
|
9
10
|
readonly description: string;
|
|
10
11
|
/** Who did it: a member's name or an API key's. */
|
|
@@ -16,7 +17,7 @@ export declare class Activity extends ApiResource {
|
|
|
16
17
|
/** The address it came from. */
|
|
17
18
|
readonly ipAddress: string | null;
|
|
18
19
|
/** "live" or "test", or null for what belongs to neither, such as a sign-in. */
|
|
19
|
-
readonly mode:
|
|
20
|
+
readonly mode: OrString<Mode> | null;
|
|
20
21
|
/** When it was done. */
|
|
21
22
|
readonly createdAt: Date | null;
|
|
22
23
|
constructor(attributes: Attributes);
|
|
@@ -3,7 +3,7 @@ import { ApiResource, date, map, nullableString, string } from './api-resource.j
|
|
|
3
3
|
export class Activity extends ApiResource {
|
|
4
4
|
/** The entry's id. */
|
|
5
5
|
id;
|
|
6
|
-
/**
|
|
6
|
+
/** One of the ActivityAction values, such as "api_key.created". */
|
|
7
7
|
action;
|
|
8
8
|
/** What was done, in words. */
|
|
9
9
|
description;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ApiKeyPermission, Mode, OrString } from '../enums.ts';
|
|
1
2
|
import { ApiResource, type Attributes } from './api-resource.ts';
|
|
2
3
|
/** An API key of the account. The key itself is only in the answer that creates it. */
|
|
3
4
|
export declare class ApiKey extends ApiResource {
|
|
@@ -10,9 +11,9 @@ export declare class ApiKey extends ApiResource {
|
|
|
10
11
|
/** The key itself, only in the answer that created it. */
|
|
11
12
|
readonly key: string | null;
|
|
12
13
|
/** "live" or "test". */
|
|
13
|
-
readonly mode:
|
|
14
|
+
readonly mode: OrString<Mode>;
|
|
14
15
|
/** The ApiKeyPermission values the key has, null for full access. */
|
|
15
|
-
readonly permissions:
|
|
16
|
+
readonly permissions: OrString<ApiKeyPermission>[] | null;
|
|
16
17
|
/** The addresses and ranges it may be used from, null for anywhere. */
|
|
17
18
|
readonly allowedIps: string[] | null;
|
|
18
19
|
/** The name of the member who made it. */
|
|
@@ -23,6 +23,8 @@ export declare function nullableBool(data: Attributes, key: string): boolean | n
|
|
|
23
23
|
export declare function int(data: Attributes, key: string, fallback?: number): number;
|
|
24
24
|
/** Read an integer attribute that may be null. */
|
|
25
25
|
export declare function nullableInt(data: Attributes, key: string): number | null;
|
|
26
|
+
/** Read a number attribute. */
|
|
27
|
+
export declare function number(data: Attributes, key: string, fallback?: number): number;
|
|
26
28
|
/** Read a number attribute that may be null. */
|
|
27
29
|
export declare function nullableNumber(data: Attributes, key: string): number | null;
|
|
28
30
|
/** Read a timestamp or a date, which is taken as midnight UTC. */
|
|
@@ -50,6 +50,10 @@ export function nullableInt(data, key) {
|
|
|
50
50
|
}
|
|
51
51
|
return typeof value === 'string' && /^\d+$/.test(value) ? Number(value) : null;
|
|
52
52
|
}
|
|
53
|
+
/** Read a number attribute. */
|
|
54
|
+
export function number(data, key, fallback = 0) {
|
|
55
|
+
return nullableNumber(data, key) ?? fallback;
|
|
56
|
+
}
|
|
53
57
|
/** Read a number attribute that may be null. */
|
|
54
58
|
export function nullableNumber(data, key) {
|
|
55
59
|
const value = data[key];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChargeStatus, type Asset, type OrString } from '../enums.ts';
|
|
1
|
+
import { ChargeStatus, type Asset, type Currency, type OrString } from '../enums.ts';
|
|
2
2
|
import { ApiResource, type Attributes } from './api-resource.ts';
|
|
3
3
|
/** One entry of a charge's history. */
|
|
4
4
|
export interface ChargeTimelineEntry {
|
|
@@ -18,14 +18,18 @@ export declare class Charge extends ApiResource {
|
|
|
18
18
|
readonly status: OrString<ChargeStatus>;
|
|
19
19
|
/** The code of the payment link the charge was made through. */
|
|
20
20
|
readonly paymentLink: string | null;
|
|
21
|
+
/** The title of that payment link, in webhooks alone; null in the API's answers, which only give its code. */
|
|
22
|
+
readonly paymentLinkTitle: string | null;
|
|
21
23
|
/** The code of the invoice the charge pays. */
|
|
22
24
|
readonly invoice: string | null;
|
|
25
|
+
/** The number of that invoice, such as "INV-0042", in webhooks alone; null in the API's answers, which only give its code. */
|
|
26
|
+
readonly invoiceNumber: string | null;
|
|
23
27
|
/** The merchant's description of the charge. */
|
|
24
28
|
readonly description: string | null;
|
|
25
29
|
/** What the customer owes, in fiat. */
|
|
26
30
|
readonly fiatAmount: string;
|
|
27
31
|
/** The fiat currency, such as "USD". */
|
|
28
|
-
readonly fiatCurrency:
|
|
32
|
+
readonly fiatCurrency: OrString<Currency>;
|
|
29
33
|
/** The coin and network paid with, such as "BTC" or "USDT". */
|
|
30
34
|
readonly asset: OrString<Asset>;
|
|
31
35
|
/** The exact amount of the coin to send. */
|
|
@@ -96,7 +100,7 @@ export declare class Charge extends ApiResource {
|
|
|
96
100
|
/** Whether the charge can still be paid. */
|
|
97
101
|
isOpen(): boolean;
|
|
98
102
|
}
|
|
99
|
-
/** A charge as the API answers with it, which always has its checkout page. Charges in webhooks
|
|
103
|
+
/** A charge as the API answers with it, the charges events carry included, which always has its checkout page. Charges in webhooks stay plain charges, without one. */
|
|
100
104
|
export type ApiCharge = Charge & {
|
|
101
105
|
readonly checkoutUrl: string;
|
|
102
106
|
};
|
|
@@ -8,8 +8,12 @@ export class Charge extends ApiResource {
|
|
|
8
8
|
status;
|
|
9
9
|
/** The code of the payment link the charge was made through. */
|
|
10
10
|
paymentLink;
|
|
11
|
+
/** The title of that payment link, in webhooks alone; null in the API's answers, which only give its code. */
|
|
12
|
+
paymentLinkTitle;
|
|
11
13
|
/** The code of the invoice the charge pays. */
|
|
12
14
|
invoice;
|
|
15
|
+
/** The number of that invoice, such as "INV-0042", in webhooks alone; null in the API's answers, which only give its code. */
|
|
16
|
+
invoiceNumber;
|
|
13
17
|
/** The merchant's description of the charge. */
|
|
14
18
|
description;
|
|
15
19
|
/** What the customer owes, in fiat. */
|
|
@@ -77,7 +81,9 @@ export class Charge extends ApiResource {
|
|
|
77
81
|
this.id = string(attributes, 'id', string(attributes, 'code'));
|
|
78
82
|
this.status = string(attributes, 'status');
|
|
79
83
|
this.paymentLink = reference(attributes, 'payment_link');
|
|
84
|
+
this.paymentLinkTitle = nullableString(map(attributes, 'payment_link'), 'title');
|
|
80
85
|
this.invoice = reference(attributes, 'invoice');
|
|
86
|
+
this.invoiceNumber = nullableString(map(attributes, 'invoice'), 'number');
|
|
81
87
|
this.description = nullableString(attributes, 'description');
|
|
82
88
|
this.fiatAmount = string(attributes, 'fiat_amount', '0');
|
|
83
89
|
this.fiatCurrency = string(attributes, 'fiat_currency');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Currency, OrString } from '../enums.ts';
|
|
1
2
|
import { ApiResource, type Attributes } from './api-resource.ts';
|
|
2
3
|
/** A discount code customers enter at checkout, or that is applied for them through a payment link's URL or the API. */
|
|
3
4
|
export declare class Coupon extends ApiResource {
|
|
@@ -10,7 +11,7 @@ export declare class Coupon extends ApiResource {
|
|
|
10
11
|
/** The amount taken off, or null for a percentage. */
|
|
11
12
|
readonly amountOff: string | null;
|
|
12
13
|
/** The only fiat currency the coupon works in, or null for a percentage that works in every one. */
|
|
13
|
-
readonly currency:
|
|
14
|
+
readonly currency: OrString<Currency> | null;
|
|
14
15
|
/** The least the price before the discount must be. */
|
|
15
16
|
readonly minAmount: string | null;
|
|
16
17
|
/** How many payments may use the coupon, or null for no limit. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EventType, OrString } from '../enums.ts';
|
|
2
2
|
import { ApiResource, type Attributes } from './api-resource.ts';
|
|
3
|
-
import {
|
|
3
|
+
import { type ApiCharge } from './charge.ts';
|
|
4
4
|
import { Invoice } from './invoice.ts';
|
|
5
5
|
/** Something that happened to a charge or an invoice, as the events API lists it. */
|
|
6
6
|
export declare class Event extends ApiResource {
|
|
@@ -12,8 +12,8 @@ export declare class Event extends ApiResource {
|
|
|
12
12
|
readonly details: Record<string, unknown>;
|
|
13
13
|
/** When it happened. */
|
|
14
14
|
readonly createdAt: Date | null;
|
|
15
|
-
/** The charge the event is about, as it is now, without its timeline. */
|
|
16
|
-
readonly charge:
|
|
15
|
+
/** The charge the event is about, as it is now, with its checkout page but without its timeline. */
|
|
16
|
+
readonly charge: ApiCharge | null;
|
|
17
17
|
/** The invoice the event is about. */
|
|
18
18
|
readonly invoice: Invoice | null;
|
|
19
19
|
constructor(attributes: Attributes);
|
|
@@ -11,7 +11,7 @@ export class Event extends ApiResource {
|
|
|
11
11
|
details;
|
|
12
12
|
/** When it happened. */
|
|
13
13
|
createdAt;
|
|
14
|
-
/** The charge the event is about, as it is now, without its timeline. */
|
|
14
|
+
/** The charge the event is about, as it is now, with its checkout page but without its timeline. */
|
|
15
15
|
charge;
|
|
16
16
|
/** The invoice the event is about. */
|
|
17
17
|
invoice;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { InvoiceStatus, type OrString } from '../enums.ts';
|
|
1
|
+
import { InvoiceStatus, type Asset, type ChargeStatus, type Currency, type OrString } from '../enums.ts';
|
|
2
2
|
import { ApiResource, type Attributes } from './api-resource.ts';
|
|
3
3
|
/** A charge made to pay an invoice, one per coin the customer tried. */
|
|
4
4
|
export interface InvoiceCharge {
|
|
5
5
|
id: string;
|
|
6
|
-
status:
|
|
7
|
-
asset:
|
|
6
|
+
status: OrString<ChargeStatus>;
|
|
7
|
+
asset: OrString<Asset>;
|
|
8
8
|
}
|
|
9
9
|
/** A bill sent to one customer, paid through a hosted page in the coin they choose. */
|
|
10
10
|
export declare class Invoice extends ApiResource {
|
|
@@ -25,7 +25,7 @@ export declare class Invoice extends ApiResource {
|
|
|
25
25
|
/** The total due. */
|
|
26
26
|
readonly amount: string;
|
|
27
27
|
/** The fiat currency, such as "USD". */
|
|
28
|
-
readonly currency:
|
|
28
|
+
readonly currency: OrString<Currency>;
|
|
29
29
|
/** The lines of an itemised invoice. */
|
|
30
30
|
readonly items: InvoiceItem[];
|
|
31
31
|
/** The day the invoice is due, at midnight UTC. */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MemberRole, OrString } from '../enums.ts';
|
|
1
2
|
import { ApiResource, type Attributes } from './api-resource.ts';
|
|
2
3
|
/** A person in the account, with their role. */
|
|
3
4
|
export declare class Member extends ApiResource {
|
|
@@ -7,8 +8,8 @@ export declare class Member extends ApiResource {
|
|
|
7
8
|
readonly name: string;
|
|
8
9
|
/** The address they sign in with. */
|
|
9
10
|
readonly email: string;
|
|
10
|
-
/**
|
|
11
|
-
readonly role:
|
|
11
|
+
/** One of the MemberRole values: owner, admin, finance, support or viewer. */
|
|
12
|
+
readonly role: OrString<MemberRole> | null;
|
|
12
13
|
/** When they joined. */
|
|
13
14
|
readonly joinedAt: Date | null;
|
|
14
15
|
constructor(attributes: Attributes);
|
|
@@ -19,8 +20,8 @@ export declare class Invitation extends ApiResource {
|
|
|
19
20
|
readonly id: string;
|
|
20
21
|
/** Where it was sent. */
|
|
21
22
|
readonly email: string;
|
|
22
|
-
/** The role it gives once accepted:
|
|
23
|
-
readonly role:
|
|
23
|
+
/** The role it gives once accepted: admin, finance, support or viewer. */
|
|
24
|
+
readonly role: OrString<MemberRole>;
|
|
24
25
|
/** The name of the member who sent it. */
|
|
25
26
|
readonly invitedBy: string | null;
|
|
26
27
|
/** Whether it can no longer be accepted. */
|
|
@@ -7,7 +7,7 @@ export class Member extends ApiResource {
|
|
|
7
7
|
name;
|
|
8
8
|
/** The address they sign in with. */
|
|
9
9
|
email;
|
|
10
|
-
/**
|
|
10
|
+
/** One of the MemberRole values: owner, admin, finance, support or viewer. */
|
|
11
11
|
role;
|
|
12
12
|
/** When they joined. */
|
|
13
13
|
joinedAt;
|
|
@@ -26,7 +26,7 @@ export class Invitation extends ApiResource {
|
|
|
26
26
|
id;
|
|
27
27
|
/** Where it was sent. */
|
|
28
28
|
email;
|
|
29
|
-
/** The role it gives once accepted:
|
|
29
|
+
/** The role it gives once accepted: admin, finance, support or viewer. */
|
|
30
30
|
role;
|
|
31
31
|
/** The name of the member who sent it. */
|
|
32
32
|
invitedBy;
|
|
@@ -1,8 +1,106 @@
|
|
|
1
|
+
import type { Asset, Currency, Mode, OrString } from '../enums.ts';
|
|
1
2
|
import { ApiResource, type Attributes } from './api-resource.ts';
|
|
2
|
-
/** The
|
|
3
|
+
/** The days an overview covers: the last 30, today included. */
|
|
4
|
+
export interface OverviewPeriod {
|
|
5
|
+
/** The first day, at midnight UTC. */
|
|
6
|
+
from: Date | null;
|
|
7
|
+
/** The last day, today, at midnight UTC. */
|
|
8
|
+
to: Date | null;
|
|
9
|
+
}
|
|
10
|
+
/** How the period's attempts to pay ended, each in exactly one bucket; a new quote or a switch of coin carries an attempt on rather than starting another. */
|
|
11
|
+
export interface OverviewFunnel {
|
|
12
|
+
/** How many attempts were started. */
|
|
13
|
+
started: number;
|
|
14
|
+
/** How many were paid. */
|
|
15
|
+
paid: number;
|
|
16
|
+
/** How many are still pending or underpaid. */
|
|
17
|
+
waiting: number;
|
|
18
|
+
/** How many expired or were canceled without a transfer. */
|
|
19
|
+
abandoned: number;
|
|
20
|
+
/** How many expired or were canceled after a transfer arrived. */
|
|
21
|
+
incomplete: number;
|
|
22
|
+
/** The attempts per coin, the most started first. */
|
|
23
|
+
assets: OverviewFunnelAsset[];
|
|
24
|
+
}
|
|
25
|
+
/** How the period's attempts to pay in one coin ended. */
|
|
26
|
+
export interface OverviewFunnelAsset {
|
|
27
|
+
asset: OrString<Asset>;
|
|
28
|
+
started: number;
|
|
29
|
+
paid: number;
|
|
30
|
+
abandoned: number;
|
|
31
|
+
}
|
|
32
|
+
/** What needs a person now. */
|
|
33
|
+
export interface OverviewAttention {
|
|
34
|
+
/** The latest underpaid charges that received something, at most five, to accept or chase. */
|
|
35
|
+
underpaidCharges: OverviewChargeAmount[];
|
|
36
|
+
/** The latest expired or canceled charges with a payment still waiting to be accepted, at most five. */
|
|
37
|
+
latePayments: OverviewChargeAmount[];
|
|
38
|
+
/** The payouts per coin that wait for a payout address. */
|
|
39
|
+
payoutsWaitingForAddress: OverviewWaitingPayouts[];
|
|
40
|
+
/** How many active webhook endpoints had a delivery fail in the last 7 days. */
|
|
41
|
+
failingWebhookEndpoints: number;
|
|
42
|
+
}
|
|
43
|
+
/** A charge that needs a person, with what it asked for and what arrived. */
|
|
44
|
+
export interface OverviewChargeAmount {
|
|
45
|
+
/** The charge's id. */
|
|
46
|
+
id: string;
|
|
47
|
+
asset: OrString<Asset>;
|
|
48
|
+
/** What the charge asked for, in the coin. */
|
|
49
|
+
amount: string;
|
|
50
|
+
/** What arrived, in the coin: for a late payment, what came after the charge closed. */
|
|
51
|
+
receivedAmount: string;
|
|
52
|
+
}
|
|
53
|
+
/** How many payouts in one coin wait for a payout address. */
|
|
54
|
+
export interface OverviewWaitingPayouts {
|
|
55
|
+
asset: OrString<Asset>;
|
|
56
|
+
count: number;
|
|
57
|
+
}
|
|
58
|
+
/** One coin's share of the period's paid charges. */
|
|
59
|
+
export interface OverviewAsset {
|
|
60
|
+
asset: OrString<Asset>;
|
|
61
|
+
/** How many charges in the coin were paid. */
|
|
62
|
+
paidCharges: number;
|
|
63
|
+
/** Their share of every paid charge, in percent. */
|
|
64
|
+
sharePercent: number;
|
|
65
|
+
}
|
|
66
|
+
/** A payment link among those paid through most in the period. */
|
|
67
|
+
export interface OverviewPaymentLink {
|
|
68
|
+
/** The link's id. */
|
|
69
|
+
id: string | null;
|
|
70
|
+
title: string | null;
|
|
71
|
+
/** How many charges were paid through it. */
|
|
72
|
+
paidCharges: number;
|
|
73
|
+
}
|
|
74
|
+
/** Which first steps the account has taken in the mode. */
|
|
75
|
+
export interface OverviewSetup {
|
|
76
|
+
/** Whether it has a payout address. */
|
|
77
|
+
payoutAddress: boolean;
|
|
78
|
+
/** Whether it has a payment link. */
|
|
79
|
+
paymentLink: boolean;
|
|
80
|
+
/** Whether a charge has been paid. */
|
|
81
|
+
paidCharge: boolean;
|
|
82
|
+
/** Whether it has a webhook endpoint. */
|
|
83
|
+
webhookEndpoint: boolean;
|
|
84
|
+
/** Whether its public profile has a logo, a display name or a website. */
|
|
85
|
+
publicProfile: boolean;
|
|
86
|
+
}
|
|
87
|
+
/** One day of the period. */
|
|
88
|
+
export interface OverviewDay {
|
|
89
|
+
/** The day, at midnight UTC. */
|
|
90
|
+
date: Date | null;
|
|
91
|
+
/** What was paid that day in the overview's currency. */
|
|
92
|
+
volume: string;
|
|
93
|
+
/** What the payouts confirmed that day came to. */
|
|
94
|
+
sentVolume: string;
|
|
95
|
+
/** How many charges in the overview's currency were paid that day. */
|
|
96
|
+
paidCharges: number;
|
|
97
|
+
}
|
|
98
|
+
/** The dashboard's figures for the last 30 days, and what needs attention now. */
|
|
3
99
|
export declare class Overview extends ApiResource {
|
|
4
|
-
/** The
|
|
5
|
-
readonly
|
|
100
|
+
/** The days the figures cover. */
|
|
101
|
+
readonly period: OverviewPeriod;
|
|
102
|
+
/** The currency the amounts are in: the one most charges were paid in lately, or the account's default. */
|
|
103
|
+
readonly currency: OrString<Currency>;
|
|
6
104
|
/** What was paid in the period. */
|
|
7
105
|
readonly volume: string;
|
|
8
106
|
/** How the volume changed against the 30 days before, in percent, or null when nothing was paid then. */
|
|
@@ -21,5 +119,19 @@ export declare class Overview extends ApiResource {
|
|
|
21
119
|
readonly openInvoices: number;
|
|
22
120
|
/** How many open invoices are past due. */
|
|
23
121
|
readonly overdueInvoices: number;
|
|
24
|
-
|
|
122
|
+
/** How the period's attempts to pay ended, in all and per coin. */
|
|
123
|
+
readonly funnel: OverviewFunnel;
|
|
124
|
+
/** What needs a person now: short and late payments, payouts without an address and failing webhook endpoints. */
|
|
125
|
+
readonly attention: OverviewAttention;
|
|
126
|
+
/** Each coin's share of the period's paid charges, the most paid first. */
|
|
127
|
+
readonly assets: OverviewAsset[];
|
|
128
|
+
/** The payment links paid through most in the period. */
|
|
129
|
+
readonly topPaymentLinks: OverviewPaymentLink[];
|
|
130
|
+
/** Which first steps the account has taken in the mode. */
|
|
131
|
+
readonly setup: OverviewSetup;
|
|
132
|
+
/** Every day of the period, oldest first. */
|
|
133
|
+
readonly daily: OverviewDay[];
|
|
134
|
+
/** The mode of the API key that fetched the overview: "live" or "test". */
|
|
135
|
+
readonly mode: OrString<Mode> | null;
|
|
136
|
+
constructor(attributes: Attributes, meta?: Attributes);
|
|
25
137
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { ApiResource, int, nullableNumber, string } from './api-resource.js';
|
|
2
|
-
/** The dashboard's figures for the last 30 days
|
|
1
|
+
import { ApiResource, bool, date, int, map, nullableNumber, nullableString, number, records, string } from './api-resource.js';
|
|
2
|
+
/** The dashboard's figures for the last 30 days, and what needs attention now. */
|
|
3
3
|
export class Overview extends ApiResource {
|
|
4
|
-
/** The
|
|
4
|
+
/** The days the figures cover. */
|
|
5
|
+
period;
|
|
6
|
+
/** The currency the amounts are in: the one most charges were paid in lately, or the account's default. */
|
|
5
7
|
currency;
|
|
6
8
|
/** What was paid in the period. */
|
|
7
9
|
volume;
|
|
@@ -21,8 +23,27 @@ export class Overview extends ApiResource {
|
|
|
21
23
|
openInvoices;
|
|
22
24
|
/** How many open invoices are past due. */
|
|
23
25
|
overdueInvoices;
|
|
24
|
-
|
|
26
|
+
/** How the period's attempts to pay ended, in all and per coin. */
|
|
27
|
+
funnel;
|
|
28
|
+
/** What needs a person now: short and late payments, payouts without an address and failing webhook endpoints. */
|
|
29
|
+
attention;
|
|
30
|
+
/** Each coin's share of the period's paid charges, the most paid first. */
|
|
31
|
+
assets;
|
|
32
|
+
/** The payment links paid through most in the period. */
|
|
33
|
+
topPaymentLinks;
|
|
34
|
+
/** Which first steps the account has taken in the mode. */
|
|
35
|
+
setup;
|
|
36
|
+
/** Every day of the period, oldest first. */
|
|
37
|
+
daily;
|
|
38
|
+
/** The mode of the API key that fetched the overview: "live" or "test". */
|
|
39
|
+
mode;
|
|
40
|
+
constructor(attributes, meta = {}) {
|
|
25
41
|
super(attributes);
|
|
42
|
+
const period = map(attributes, 'period');
|
|
43
|
+
const funnel = map(attributes, 'funnel');
|
|
44
|
+
const attention = map(attributes, 'attention');
|
|
45
|
+
const setup = map(attributes, 'setup');
|
|
46
|
+
this.period = { from: date(period, 'from'), to: date(period, 'to') };
|
|
26
47
|
this.currency = string(attributes, 'currency');
|
|
27
48
|
this.volume = string(attributes, 'volume', '0');
|
|
28
49
|
this.volumeChangePercent = nullableNumber(attributes, 'volume_change_percent');
|
|
@@ -33,5 +54,57 @@ export class Overview extends ApiResource {
|
|
|
33
54
|
this.activePaymentLinks = int(attributes, 'active_payment_links');
|
|
34
55
|
this.openInvoices = int(attributes, 'open_invoices');
|
|
35
56
|
this.overdueInvoices = int(attributes, 'overdue_invoices');
|
|
57
|
+
this.funnel = {
|
|
58
|
+
started: int(funnel, 'started'),
|
|
59
|
+
paid: int(funnel, 'paid'),
|
|
60
|
+
waiting: int(funnel, 'waiting'),
|
|
61
|
+
abandoned: int(funnel, 'abandoned'),
|
|
62
|
+
incomplete: int(funnel, 'incomplete'),
|
|
63
|
+
assets: records(funnel, 'assets').map((row) => ({
|
|
64
|
+
asset: string(row, 'asset'),
|
|
65
|
+
started: int(row, 'started'),
|
|
66
|
+
paid: int(row, 'paid'),
|
|
67
|
+
abandoned: int(row, 'abandoned'),
|
|
68
|
+
})),
|
|
69
|
+
};
|
|
70
|
+
this.attention = {
|
|
71
|
+
underpaidCharges: records(attention, 'underpaid_charges').map(chargeAmount),
|
|
72
|
+
latePayments: records(attention, 'late_payments').map(chargeAmount),
|
|
73
|
+
payoutsWaitingForAddress: records(attention, 'payouts_waiting_for_address').map((row) => ({ asset: string(row, 'asset'), count: int(row, 'count') })),
|
|
74
|
+
failingWebhookEndpoints: int(attention, 'failing_webhook_endpoints'),
|
|
75
|
+
};
|
|
76
|
+
this.assets = records(attributes, 'assets').map((row) => ({
|
|
77
|
+
asset: string(row, 'asset'),
|
|
78
|
+
paidCharges: int(row, 'paid_charges'),
|
|
79
|
+
sharePercent: number(row, 'share_percent'),
|
|
80
|
+
}));
|
|
81
|
+
this.topPaymentLinks = records(attributes, 'top_payment_links').map((link) => ({
|
|
82
|
+
id: nullableString(link, 'id'),
|
|
83
|
+
title: nullableString(link, 'title'),
|
|
84
|
+
paidCharges: int(link, 'paid_charges'),
|
|
85
|
+
}));
|
|
86
|
+
this.setup = {
|
|
87
|
+
payoutAddress: bool(setup, 'payout_address'),
|
|
88
|
+
paymentLink: bool(setup, 'payment_link'),
|
|
89
|
+
paidCharge: bool(setup, 'paid_charge'),
|
|
90
|
+
webhookEndpoint: bool(setup, 'webhook_endpoint'),
|
|
91
|
+
publicProfile: bool(setup, 'public_profile'),
|
|
92
|
+
};
|
|
93
|
+
this.daily = records(attributes, 'daily').map((day) => ({
|
|
94
|
+
date: date(day, 'date'),
|
|
95
|
+
volume: string(day, 'volume', '0'),
|
|
96
|
+
sentVolume: string(day, 'sent_volume', '0'),
|
|
97
|
+
paidCharges: int(day, 'paid_charges'),
|
|
98
|
+
}));
|
|
99
|
+
this.mode = nullableString(meta, 'mode');
|
|
36
100
|
}
|
|
37
101
|
}
|
|
102
|
+
/** Read a charge that needs a person. */
|
|
103
|
+
function chargeAmount(row) {
|
|
104
|
+
return {
|
|
105
|
+
id: string(row, 'id'),
|
|
106
|
+
asset: string(row, 'asset'),
|
|
107
|
+
amount: string(row, 'amount', '0'),
|
|
108
|
+
receivedAmount: string(row, 'received_amount', '0'),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PaymentLinkStatus, PricingType, type OrString } from '../enums.ts';
|
|
1
|
+
import { PaymentLinkStatus, PricingType, type Asset, type Currency, type OrString } from '../enums.ts';
|
|
2
2
|
import { ApiResource, type Attributes } from './api-resource.ts';
|
|
3
3
|
/** A question a payment link's checkout asks. */
|
|
4
4
|
export interface CheckoutQuestion {
|
|
@@ -24,9 +24,9 @@ export declare class PaymentLink extends ApiResource {
|
|
|
24
24
|
/** The most a customer may pay on an open-price link. */
|
|
25
25
|
readonly maxAmount: string | null;
|
|
26
26
|
/** The fiat currency the link is priced in. */
|
|
27
|
-
readonly currency:
|
|
27
|
+
readonly currency: OrString<Currency>;
|
|
28
28
|
/** The coins the link takes, or null for every coin the account can receive. */
|
|
29
|
-
readonly acceptedAssets:
|
|
29
|
+
readonly acceptedAssets: OrString<Asset>[] | null;
|
|
30
30
|
/** One of the PaymentLinkStatus values: active or archived. */
|
|
31
31
|
readonly status: OrString<PaymentLinkStatus>;
|
|
32
32
|
/** Where the customer is sent after paying. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PayoutStatus, type Asset, type OrString } from '../enums.ts';
|
|
1
|
+
import { PayoutStatus, type AddressNetwork, type Asset, type Currency, type OrString } from '../enums.ts';
|
|
2
2
|
import { ApiResource, type Attributes } from './api-resource.ts';
|
|
3
3
|
/** What became of one paid charge: what came in, what was kept, what was sent and the transaction that carried it. */
|
|
4
4
|
export declare class Payout extends ApiResource {
|
|
@@ -19,7 +19,7 @@ export declare class Payout extends ApiResource {
|
|
|
19
19
|
/** What the fee was worth in fiat, at the rate the charge was locked at. */
|
|
20
20
|
readonly feeFiatAmount: string | null;
|
|
21
21
|
/** The fiat currency of feeFiatAmount and exchangeRate. */
|
|
22
|
-
readonly fiatCurrency:
|
|
22
|
+
readonly fiatCurrency: OrString<Currency> | null;
|
|
23
23
|
/** The rate the charge was locked at. */
|
|
24
24
|
readonly exchangeRate: string | null;
|
|
25
25
|
/** What the merchant is owed, before the chain's own fee. */
|
|
@@ -76,14 +76,14 @@ export declare class PayoutSummary extends ApiResource {
|
|
|
76
76
|
}
|
|
77
77
|
/** Where the account's payouts on one network go. */
|
|
78
78
|
export declare class PayoutAddress extends ApiResource {
|
|
79
|
-
/**
|
|
80
|
-
readonly network:
|
|
79
|
+
/** One of the AddressNetwork values, such as "bitcoin" or "evm", which is also its id in the paths. */
|
|
80
|
+
readonly network: OrString<AddressNetwork>;
|
|
81
81
|
/** The network's name. */
|
|
82
82
|
readonly name: string;
|
|
83
83
|
/** Where payouts go, null while there is no address: payouts in its coins then wait for one. */
|
|
84
84
|
readonly address: string | null;
|
|
85
85
|
/** The coins on offer on this network. */
|
|
86
|
-
readonly assets:
|
|
86
|
+
readonly assets: OrString<Asset>[];
|
|
87
87
|
/** Until when payouts to a newly saved address wait. */
|
|
88
88
|
readonly payoutsHeldUntil: Date | null;
|
|
89
89
|
/** When the address was last saved. */
|
|
@@ -115,7 +115,7 @@ export class PayoutSummary extends ApiResource {
|
|
|
115
115
|
}
|
|
116
116
|
/** Where the account's payouts on one network go. */
|
|
117
117
|
export class PayoutAddress extends ApiResource {
|
|
118
|
-
/**
|
|
118
|
+
/** One of the AddressNetwork values, such as "bitcoin" or "evm", which is also its id in the paths. */
|
|
119
119
|
network;
|
|
120
120
|
/** The network's name. */
|
|
121
121
|
name;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Asset, Currency, OrString } from '../enums.ts';
|
|
1
2
|
import { ApiResource, type Attributes } from './api-resource.ts';
|
|
2
3
|
/** A crypto payment for a month of Pro: where to pay it and what to send. */
|
|
3
4
|
export declare class ProPayment extends ApiResource {
|
|
@@ -6,9 +7,9 @@ export declare class ProPayment extends ApiResource {
|
|
|
6
7
|
/** What it costs, in currency. */
|
|
7
8
|
readonly price: string;
|
|
8
9
|
/** The currency of the price. */
|
|
9
|
-
readonly currency:
|
|
10
|
+
readonly currency: OrString<Currency>;
|
|
10
11
|
/** The coin it is paid in. */
|
|
11
|
-
readonly asset:
|
|
12
|
+
readonly asset: OrString<Asset>;
|
|
12
13
|
/** What to send, in the coin. */
|
|
13
14
|
readonly assetAmount: string;
|
|
14
15
|
/** The page to pay it on. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Asset, type OrString } from '../enums.ts';
|
|
1
|
+
import { Asset, type Currency, type OrString } from '../enums.ts';
|
|
2
2
|
import { ApiResource, type Attributes } from './api-resource.ts';
|
|
3
3
|
/** A coin that can be paid in the API key's mode, with the lowest price a charge in it can have. */
|
|
4
4
|
export declare class SupportedAsset extends ApiResource {
|
|
@@ -21,7 +21,7 @@ export declare class SupportedAsset extends ApiResource {
|
|
|
21
21
|
/** Whether the account takes it right now, which needs a payout address for that network. */
|
|
22
22
|
readonly accepted: boolean | null;
|
|
23
23
|
/** The currency exchangeRate and minimumPrice are in. */
|
|
24
|
-
readonly currency:
|
|
24
|
+
readonly currency: OrString<Currency>;
|
|
25
25
|
/** What one unit of the coin is worth in that currency right now, or null while no rate is available. */
|
|
26
26
|
readonly exchangeRate: string | null;
|
|
27
27
|
/** The least a charge in it can come to, in the coin itself, or null when it has no minimum of its own. */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WebhookDeliveryStatus, type EventType, type OrString } from '../enums.ts';
|
|
1
2
|
import { ApiResource, type Attributes } from './api-resource.ts';
|
|
2
3
|
/** Where webhooks are delivered, and whether it can receive them. Its signing secret is only returned when it is added or rotated. */
|
|
3
4
|
export declare class WebhookEndpoint extends ApiResource {
|
|
@@ -8,7 +9,7 @@ export declare class WebhookEndpoint extends ApiResource {
|
|
|
8
9
|
/** What the merchant noted about it. */
|
|
9
10
|
readonly description: string | null;
|
|
10
11
|
/** The EventType values it subscribes to. */
|
|
11
|
-
readonly events:
|
|
12
|
+
readonly events: OrString<EventType>[];
|
|
12
13
|
/** Whether it is switched on. */
|
|
13
14
|
readonly active: boolean;
|
|
14
15
|
/** Whether it has answered the verification challenge; it receives nothing until it has. */
|
|
@@ -36,13 +37,13 @@ export declare class WebhookDelivery extends ApiResource {
|
|
|
36
37
|
/** The delivery's id, the X-VeliraPay-Delivery header it was sent with. */
|
|
37
38
|
readonly id: string;
|
|
38
39
|
/** The EventType value it carried. */
|
|
39
|
-
readonly event:
|
|
40
|
+
readonly event: OrString<EventType>;
|
|
40
41
|
/** The id of the event it carried, null for a test delivery. */
|
|
41
42
|
readonly eventId: string | null;
|
|
42
43
|
/** Whether it was a test event, which describes no real payment. */
|
|
43
44
|
readonly test: boolean;
|
|
44
|
-
/**
|
|
45
|
-
readonly status:
|
|
45
|
+
/** One of the WebhookDeliveryStatus values: pending, succeeded or failed. */
|
|
46
|
+
readonly status: OrString<WebhookDeliveryStatus>;
|
|
46
47
|
/** How many times it was sent. */
|
|
47
48
|
readonly attempts: number;
|
|
48
49
|
/** The HTTP status the endpoint last answered with. */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WebhookDeliveryStatus } from '../enums.js';
|
|
1
2
|
import { ApiResource, bool, date, int, isRecord, map, nullableInt, nullableString, objects, reference, string, strings } from './api-resource.js';
|
|
2
3
|
/** Where webhooks are delivered, and whether it can receive them. Its signing secret is only returned when it is added or rotated. */
|
|
3
4
|
export class WebhookEndpoint extends ApiResource {
|
|
@@ -58,7 +59,7 @@ export class WebhookDelivery extends ApiResource {
|
|
|
58
59
|
eventId;
|
|
59
60
|
/** Whether it was a test event, which describes no real payment. */
|
|
60
61
|
test;
|
|
61
|
-
/**
|
|
62
|
+
/** One of the WebhookDeliveryStatus values: pending, succeeded or failed. */
|
|
62
63
|
status;
|
|
63
64
|
/** How many times it was sent. */
|
|
64
65
|
attempts;
|
|
@@ -101,7 +102,7 @@ export class WebhookDelivery extends ApiResource {
|
|
|
101
102
|
}
|
|
102
103
|
/** Whether the endpoint accepted the delivery. */
|
|
103
104
|
succeeded() {
|
|
104
|
-
return this.status ===
|
|
105
|
+
return this.status === WebhookDeliveryStatus.Succeeded;
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
108
|
/** One attempt to send a webhook delivery: the request it made and what the endpoint answered. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Account } from '../resources/account.js';
|
|
2
|
-
import { data, meta, Service } from './service.js';
|
|
2
|
+
import { data, meta, Service, withDecimalAmounts } from './service.js';
|
|
3
3
|
/** The /v1/account and /v1/payment-settings endpoints. */
|
|
4
4
|
export class AccountService extends Service {
|
|
5
5
|
/** Retrieve the account the API key belongs to, with the coins it accepts in the key's mode. */
|
|
@@ -12,7 +12,7 @@ export class AccountService extends Service {
|
|
|
12
12
|
}
|
|
13
13
|
/** Change the default currency, the payment tolerances, the checkout language or invoice reminders. Needs payment_settings:write. */
|
|
14
14
|
async updatePaymentSettings(params, options) {
|
|
15
|
-
return account(await this.respond('PATCH', '/v1/payment-settings', params, options));
|
|
15
|
+
return account(await this.respond('PATCH', '/v1/payment-settings', withDecimalAmounts(params, 'underpayment_tolerance', 'overpayment_threshold'), options));
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
/** Read the account and its meta from an answer. */
|