velirapay 0.1.0 → 0.1.1

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 CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  All notable changes to this library are documented here. It follows [Semantic Versioning](https://semver.org).
4
4
 
5
+ ## 0.1.1 - 2026-11-12
6
+
7
+ - The charges that `charges.create()`, `retrieve()`, `list()`, `iterator()`, `cancel()`, `recordRefund()`, `send()`, `accept()` and `simulate()` answer with are typed `ApiCharge`, whose `checkoutUrl` is a `string`, so `res.redirect(303, charge.checkoutUrl)` compiles under TypeScript's `strict`. Charges in webhooks and events keep `checkoutUrl: string | null`, since webhooks leave it out. Nothing changes at runtime.
8
+
5
9
  ## 0.1.0 - 2026-11-12
6
10
 
7
11
  The first version, covering what the PHP library covers as of its 0.6.5:
package/README.md CHANGED
@@ -55,7 +55,7 @@ res.redirect(303, charge.checkoutUrl);
55
55
 
56
56
  They pay there, and VeliraPay tells your server about it with a [webhook](#verifying-webhooks). The exchange rate is locked when the charge is created, and the customer has 30 minutes to pay.
57
57
 
58
- Parameters are sent as the API names them, in snake_case, and objects come back with camelCase properties: `charge.checkoutUrl`, `charge.assetAmount`, `charge.customer.ipAddress`. Amounts are always strings, such as `'49.90'`, never floating-point numbers, so no precision is lost. `checkoutUrl` is typed `string | null` because the charges in webhooks leave it out; a charge the API answers with always has one.
58
+ Parameters are sent as the API names them, in snake_case, and objects come back with camelCase properties: `charge.checkoutUrl`, `charge.assetAmount`, `charge.customer.ipAddress`. Amounts are always strings, such as `'49.90'`, never floating-point numbers, so no precision is lost. A charge the API answers with is an `ApiCharge`, whose `checkoutUrl` is always a string. Charges in webhooks leave it out, so theirs is `string | null`.
59
59
 
60
60
  With CommonJS:
61
61
 
@@ -36,7 +36,7 @@ export interface ClientOptions {
36
36
  export declare class VeliraPayClient {
37
37
  #private;
38
38
  /** The version of this library. */
39
- static readonly VERSION = "0.1.0";
39
+ static readonly VERSION = "0.1.1";
40
40
  /** The address of the VeliraPay API. */
41
41
  static readonly DEFAULT_BASE_URL = "https://api.velirapay.com";
42
42
  /** The account the API key belongs to. */
@@ -10,7 +10,7 @@ export { Account, AccountBusiness, Address, type AccountCheckout, type AccountIn
10
10
  export { Activity } from './resources/activity.ts';
11
11
  export { ApiKey } from './resources/api-key.ts';
12
12
  export { ApiResource, type Attributes } from './resources/api-resource.ts';
13
- export { Charge, Customer, Refund, Transaction, type ChargeTimelineEntry, type CustomFieldAnswer } from './resources/charge.ts';
13
+ export { Charge, Customer, Refund, Transaction, type ApiCharge, type ChargeTimelineEntry, type CustomFieldAnswer } from './resources/charge.ts';
14
14
  export { Coupon } from './resources/coupon.ts';
15
15
  export { Event } from './resources/event.ts';
16
16
  export { Invoice, InvoiceItem, type InvoiceCharge } from './resources/invoice.ts';
@@ -96,6 +96,10 @@ export declare class Charge extends ApiResource {
96
96
  /** Whether the charge can still be paid. */
97
97
  isOpen(): boolean;
98
98
  }
99
+ /** A charge as the API answers with it, which always has its checkout page. Charges in webhooks and events stay plain charges, without one. */
100
+ export type ApiCharge = Charge & {
101
+ readonly checkoutUrl: string;
102
+ };
99
103
  /** What is known about the customer paying a charge, including the signals that help spot fraud. */
100
104
  export declare class Customer extends ApiResource {
101
105
  /** The customer's email address. */
@@ -1,25 +1,25 @@
1
1
  import type { Page } from '../page.ts';
2
2
  import type { ChargeCreateParams, ChargeListParams, RefundParams, RequestOptions, SimulateParams } from '../params.ts';
3
- import { Charge } from '../resources/charge.ts';
3
+ import { type ApiCharge } from '../resources/charge.ts';
4
4
  import { Service } from './service.ts';
5
5
  /** The /v1/charges endpoints. */
6
6
  export declare class ChargeService extends Service {
7
7
  /** Charge a customer: create a charge with what you already know about them, and send them to its checkoutUrl. */
8
- create(params: ChargeCreateParams, options?: RequestOptions): Promise<Charge>;
8
+ create(params: ChargeCreateParams, options?: RequestOptions): Promise<ApiCharge>;
9
9
  /** Retrieve a charge by its id. */
10
- retrieve(id: string): Promise<Charge>;
10
+ retrieve(id: string): Promise<ApiCharge>;
11
11
  /** List charges, newest first. */
12
- list(params?: ChargeListParams): Promise<Page<Charge>>;
12
+ list(params?: ChargeListParams): Promise<Page<ApiCharge>>;
13
13
  /** Iterate over every charge, newest first, fetching pages as they are reached. */
14
- iterator(params?: Omit<ChargeListParams, 'page'>): AsyncGenerator<Charge, void, undefined>;
14
+ iterator(params?: Omit<ChargeListParams, 'page'>): AsyncGenerator<ApiCharge, void, undefined>;
15
15
  /** Cancel a pending charge that no transfer has been seen for, so it can no longer be paid. */
16
- cancel(id: string, options?: RequestOptions): Promise<Charge>;
16
+ cancel(id: string, options?: RequestOptions): Promise<ApiCharge>;
17
17
  /** Record a refund you sent the customer from your own wallet. An underpaid charge or a late payment is accepted first, and the network surcharge is never refundable. */
18
- recordRefund(id: string, params: RefundParams, options?: RequestOptions): Promise<Charge>;
18
+ recordRefund(id: string, params: RefundParams, options?: RequestOptions): Promise<ApiCharge>;
19
19
  /** Email the customer the payment page of a pending charge. */
20
- send(id: string, options?: RequestOptions): Promise<Charge>;
20
+ send(id: string, options?: RequestOptions): Promise<ApiCharge>;
21
21
  /** Accept an underpaid charge, or a late payment on an expired or canceled one, as paid for what arrived and confirmed. */
22
- accept(id: string, options?: RequestOptions): Promise<Charge>;
22
+ accept(id: string, options?: RequestOptions): Promise<ApiCharge>;
23
23
  /** Pay a test-mode charge without coins, in full or by a chosen amount in the charge's coin. */
24
- simulate(id: string, params?: SimulateParams, options?: RequestOptions): Promise<Charge>;
24
+ simulate(id: string, params?: SimulateParams, options?: RequestOptions): Promise<ApiCharge>;
25
25
  }
@@ -7,15 +7,15 @@ const service_ts_1 = require("./service.js");
7
7
  class ChargeService extends service_ts_1.Service {
8
8
  /** Charge a customer: create a charge with what you already know about them, and send them to its checkoutUrl. */
9
9
  async create(params, options) {
10
- return new charge_ts_1.Charge(await this.request('POST', '/v1/charges', params, options));
10
+ return apiCharge(await this.request('POST', '/v1/charges', params, options));
11
11
  }
12
12
  /** Retrieve a charge by its id. */
13
13
  async retrieve(id) {
14
- return new charge_ts_1.Charge(await this.request('GET', (0, service_ts_1.path)('/v1/charges/%s', id)));
14
+ return apiCharge(await this.request('GET', (0, service_ts_1.path)('/v1/charges/%s', id)));
15
15
  }
16
16
  /** List charges, newest first. */
17
17
  async list(params = {}) {
18
- return this.page('/v1/charges', params, (charge) => new charge_ts_1.Charge(charge));
18
+ return this.page('/v1/charges', params, apiCharge);
19
19
  }
20
20
  /** Iterate over every charge, newest first, fetching pages as they are reached. */
21
21
  async *iterator(params = {}) {
@@ -23,23 +23,27 @@ class ChargeService extends service_ts_1.Service {
23
23
  }
24
24
  /** Cancel a pending charge that no transfer has been seen for, so it can no longer be paid. */
25
25
  async cancel(id, options) {
26
- return new charge_ts_1.Charge(await this.request('POST', (0, service_ts_1.path)('/v1/charges/%s/cancel', id), undefined, options));
26
+ return apiCharge(await this.request('POST', (0, service_ts_1.path)('/v1/charges/%s/cancel', id), undefined, options));
27
27
  }
28
28
  /** Record a refund you sent the customer from your own wallet. An underpaid charge or a late payment is accepted first, and the network surcharge is never refundable. */
29
29
  async recordRefund(id, params, options) {
30
- return new charge_ts_1.Charge(await this.request('POST', (0, service_ts_1.path)('/v1/charges/%s/refunds', id), params, options));
30
+ return apiCharge(await this.request('POST', (0, service_ts_1.path)('/v1/charges/%s/refunds', id), params, options));
31
31
  }
32
32
  /** Email the customer the payment page of a pending charge. */
33
33
  async send(id, options) {
34
- return new charge_ts_1.Charge(await this.request('POST', (0, service_ts_1.path)('/v1/charges/%s/send', id), undefined, options));
34
+ return apiCharge(await this.request('POST', (0, service_ts_1.path)('/v1/charges/%s/send', id), undefined, options));
35
35
  }
36
36
  /** Accept an underpaid charge, or a late payment on an expired or canceled one, as paid for what arrived and confirmed. */
37
37
  async accept(id, options) {
38
- return new charge_ts_1.Charge(await this.request('POST', (0, service_ts_1.path)('/v1/charges/%s/accept', id), undefined, options));
38
+ return apiCharge(await this.request('POST', (0, service_ts_1.path)('/v1/charges/%s/accept', id), undefined, options));
39
39
  }
40
40
  /** Pay a test-mode charge without coins, in full or by a chosen amount in the charge's coin. */
41
41
  async simulate(id, params = {}, options) {
42
- return new charge_ts_1.Charge(await this.request('POST', (0, service_ts_1.path)('/v1/charges/%s/simulate', id), Object.keys(params).length === 0 ? undefined : params, options));
42
+ return apiCharge(await this.request('POST', (0, service_ts_1.path)('/v1/charges/%s/simulate', id), Object.keys(params).length === 0 ? undefined : params, options));
43
43
  }
44
44
  }
45
45
  exports.ChargeService = ChargeService;
46
+ /** Read a charge the API answered with, which always carries its checkout page. */
47
+ function apiCharge(attributes) {
48
+ return new charge_ts_1.Charge(attributes);
49
+ }
@@ -1,2 +1,2 @@
1
1
  /** The version of this library. */
2
- export declare const VERSION = "0.1.0";
2
+ export declare const VERSION = "0.1.1";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  /** The version of this library. */
5
- exports.VERSION = '0.1.0';
5
+ exports.VERSION = '0.1.1';
@@ -36,7 +36,7 @@ export interface ClientOptions {
36
36
  export declare class VeliraPayClient {
37
37
  #private;
38
38
  /** The version of this library. */
39
- static readonly VERSION = "0.1.0";
39
+ static readonly VERSION = "0.1.1";
40
40
  /** The address of the VeliraPay API. */
41
41
  static readonly DEFAULT_BASE_URL = "https://api.velirapay.com";
42
42
  /** The account the API key belongs to. */
@@ -10,7 +10,7 @@ export { Account, AccountBusiness, Address, type AccountCheckout, type AccountIn
10
10
  export { Activity } from './resources/activity.ts';
11
11
  export { ApiKey } from './resources/api-key.ts';
12
12
  export { ApiResource, type Attributes } from './resources/api-resource.ts';
13
- export { Charge, Customer, Refund, Transaction, type ChargeTimelineEntry, type CustomFieldAnswer } from './resources/charge.ts';
13
+ export { Charge, Customer, Refund, Transaction, type ApiCharge, type ChargeTimelineEntry, type CustomFieldAnswer } from './resources/charge.ts';
14
14
  export { Coupon } from './resources/coupon.ts';
15
15
  export { Event } from './resources/event.ts';
16
16
  export { Invoice, InvoiceItem, type InvoiceCharge } from './resources/invoice.ts';
@@ -96,6 +96,10 @@ export declare class Charge extends ApiResource {
96
96
  /** Whether the charge can still be paid. */
97
97
  isOpen(): boolean;
98
98
  }
99
+ /** A charge as the API answers with it, which always has its checkout page. Charges in webhooks and events stay plain charges, without one. */
100
+ export type ApiCharge = Charge & {
101
+ readonly checkoutUrl: string;
102
+ };
99
103
  /** What is known about the customer paying a charge, including the signals that help spot fraud. */
100
104
  export declare class Customer extends ApiResource {
101
105
  /** The customer's email address. */
@@ -1,25 +1,25 @@
1
1
  import type { Page } from '../page.ts';
2
2
  import type { ChargeCreateParams, ChargeListParams, RefundParams, RequestOptions, SimulateParams } from '../params.ts';
3
- import { Charge } from '../resources/charge.ts';
3
+ import { type ApiCharge } from '../resources/charge.ts';
4
4
  import { Service } from './service.ts';
5
5
  /** The /v1/charges endpoints. */
6
6
  export declare class ChargeService extends Service {
7
7
  /** Charge a customer: create a charge with what you already know about them, and send them to its checkoutUrl. */
8
- create(params: ChargeCreateParams, options?: RequestOptions): Promise<Charge>;
8
+ create(params: ChargeCreateParams, options?: RequestOptions): Promise<ApiCharge>;
9
9
  /** Retrieve a charge by its id. */
10
- retrieve(id: string): Promise<Charge>;
10
+ retrieve(id: string): Promise<ApiCharge>;
11
11
  /** List charges, newest first. */
12
- list(params?: ChargeListParams): Promise<Page<Charge>>;
12
+ list(params?: ChargeListParams): Promise<Page<ApiCharge>>;
13
13
  /** Iterate over every charge, newest first, fetching pages as they are reached. */
14
- iterator(params?: Omit<ChargeListParams, 'page'>): AsyncGenerator<Charge, void, undefined>;
14
+ iterator(params?: Omit<ChargeListParams, 'page'>): AsyncGenerator<ApiCharge, void, undefined>;
15
15
  /** Cancel a pending charge that no transfer has been seen for, so it can no longer be paid. */
16
- cancel(id: string, options?: RequestOptions): Promise<Charge>;
16
+ cancel(id: string, options?: RequestOptions): Promise<ApiCharge>;
17
17
  /** Record a refund you sent the customer from your own wallet. An underpaid charge or a late payment is accepted first, and the network surcharge is never refundable. */
18
- recordRefund(id: string, params: RefundParams, options?: RequestOptions): Promise<Charge>;
18
+ recordRefund(id: string, params: RefundParams, options?: RequestOptions): Promise<ApiCharge>;
19
19
  /** Email the customer the payment page of a pending charge. */
20
- send(id: string, options?: RequestOptions): Promise<Charge>;
20
+ send(id: string, options?: RequestOptions): Promise<ApiCharge>;
21
21
  /** Accept an underpaid charge, or a late payment on an expired or canceled one, as paid for what arrived and confirmed. */
22
- accept(id: string, options?: RequestOptions): Promise<Charge>;
22
+ accept(id: string, options?: RequestOptions): Promise<ApiCharge>;
23
23
  /** Pay a test-mode charge without coins, in full or by a chosen amount in the charge's coin. */
24
- simulate(id: string, params?: SimulateParams, options?: RequestOptions): Promise<Charge>;
24
+ simulate(id: string, params?: SimulateParams, options?: RequestOptions): Promise<ApiCharge>;
25
25
  }
@@ -4,15 +4,15 @@ import { path, Service } from './service.js';
4
4
  export class ChargeService extends Service {
5
5
  /** Charge a customer: create a charge with what you already know about them, and send them to its checkoutUrl. */
6
6
  async create(params, options) {
7
- return new Charge(await this.request('POST', '/v1/charges', params, options));
7
+ return apiCharge(await this.request('POST', '/v1/charges', params, options));
8
8
  }
9
9
  /** Retrieve a charge by its id. */
10
10
  async retrieve(id) {
11
- return new Charge(await this.request('GET', path('/v1/charges/%s', id)));
11
+ return apiCharge(await this.request('GET', path('/v1/charges/%s', id)));
12
12
  }
13
13
  /** List charges, newest first. */
14
14
  async list(params = {}) {
15
- return this.page('/v1/charges', params, (charge) => new Charge(charge));
15
+ return this.page('/v1/charges', params, apiCharge);
16
16
  }
17
17
  /** Iterate over every charge, newest first, fetching pages as they are reached. */
18
18
  async *iterator(params = {}) {
@@ -20,22 +20,26 @@ export class ChargeService extends Service {
20
20
  }
21
21
  /** Cancel a pending charge that no transfer has been seen for, so it can no longer be paid. */
22
22
  async cancel(id, options) {
23
- return new Charge(await this.request('POST', path('/v1/charges/%s/cancel', id), undefined, options));
23
+ return apiCharge(await this.request('POST', path('/v1/charges/%s/cancel', id), undefined, options));
24
24
  }
25
25
  /** Record a refund you sent the customer from your own wallet. An underpaid charge or a late payment is accepted first, and the network surcharge is never refundable. */
26
26
  async recordRefund(id, params, options) {
27
- return new Charge(await this.request('POST', path('/v1/charges/%s/refunds', id), params, options));
27
+ return apiCharge(await this.request('POST', path('/v1/charges/%s/refunds', id), params, options));
28
28
  }
29
29
  /** Email the customer the payment page of a pending charge. */
30
30
  async send(id, options) {
31
- return new Charge(await this.request('POST', path('/v1/charges/%s/send', id), undefined, options));
31
+ return apiCharge(await this.request('POST', path('/v1/charges/%s/send', id), undefined, options));
32
32
  }
33
33
  /** Accept an underpaid charge, or a late payment on an expired or canceled one, as paid for what arrived and confirmed. */
34
34
  async accept(id, options) {
35
- return new Charge(await this.request('POST', path('/v1/charges/%s/accept', id), undefined, options));
35
+ return apiCharge(await this.request('POST', path('/v1/charges/%s/accept', id), undefined, options));
36
36
  }
37
37
  /** Pay a test-mode charge without coins, in full or by a chosen amount in the charge's coin. */
38
38
  async simulate(id, params = {}, options) {
39
- return new Charge(await this.request('POST', path('/v1/charges/%s/simulate', id), Object.keys(params).length === 0 ? undefined : params, options));
39
+ return apiCharge(await this.request('POST', path('/v1/charges/%s/simulate', id), Object.keys(params).length === 0 ? undefined : params, options));
40
40
  }
41
41
  }
42
+ /** Read a charge the API answered with, which always carries its checkout page. */
43
+ function apiCharge(attributes) {
44
+ return new Charge(attributes);
45
+ }
@@ -1,2 +1,2 @@
1
1
  /** The version of this library. */
2
- export declare const VERSION = "0.1.0";
2
+ export declare const VERSION = "0.1.1";
@@ -1,2 +1,2 @@
1
1
  /** The version of this library. */
2
- export const VERSION = '0.1.0';
2
+ export const VERSION = '0.1.1';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://www.schemastore.org/package.json",
3
3
  "name": "velirapay",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "description": "The official Node.js library for VeliraPay crypto payments: charges, payment links, invoices, payouts, events and webhook verification.",
6
6
  "keywords": [
7
7
  "velirapay",