@peable.to/shared-types 0.11.0 → 0.13.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/dist/cjs/catalog.js +53 -0
- package/dist/cjs/index.js +16 -1
- package/dist/cjs/requestLog.js +18 -0
- package/dist/cjs/testHelpers.js +21 -0
- package/dist/esm/catalog.js +50 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/requestLog.js +15 -0
- package/dist/esm/testHelpers.js +18 -0
- package/dist/types/catalog.d.ts +390 -0
- package/dist/types/event.d.ts +21 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/requestLog.d.ts +40 -0
- package/dist/types/testHelpers.d.ts +23 -0
- package/package.json +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CATALOG_LIMITS = exports.COUPON_DURATIONS = exports.TRANSFORM_QUANTITY_ROUNDS = exports.PRICE_TAX_BEHAVIORS = exports.RECURRING_USAGE_TYPES = exports.RECURRING_INTERVALS = exports.PRICE_TYPES = exports.PRICE_TIERS_MODES = exports.PRICE_BILLING_SCHEMES = void 0;
|
|
4
|
+
/** How a price's amount is computed from a quantity. */
|
|
5
|
+
exports.PRICE_BILLING_SCHEMES = ['per_unit', 'tiered'];
|
|
6
|
+
/**
|
|
7
|
+
* How a tiered price reads its tiers.
|
|
8
|
+
*
|
|
9
|
+
* - `volume` — the WHOLE quantity is priced at the tier it falls into.
|
|
10
|
+
* - `graduated` — each unit is priced at the tier it falls into, so a
|
|
11
|
+
* quantity crossing two tiers pays each tier's rate for its
|
|
12
|
+
* share, plus the flat amount of every tier it reaches.
|
|
13
|
+
*/
|
|
14
|
+
exports.PRICE_TIERS_MODES = ['graduated', 'volume'];
|
|
15
|
+
/** `recurring` when the price has a recurring component, `one_time` otherwise. */
|
|
16
|
+
exports.PRICE_TYPES = ['one_time', 'recurring'];
|
|
17
|
+
exports.RECURRING_INTERVALS = ['day', 'week', 'month', 'year'];
|
|
18
|
+
/**
|
|
19
|
+
* `licensed` bills the quantity on the subscription. `metered` bills reported
|
|
20
|
+
* usage and needs a meter; meters are not part of Orbit yet, so the gateway
|
|
21
|
+
* refuses a metered price rather than store one nothing can bill.
|
|
22
|
+
*/
|
|
23
|
+
exports.RECURRING_USAGE_TYPES = ['licensed', 'metered'];
|
|
24
|
+
/**
|
|
25
|
+
* Whether a price includes tax (Peable Tax, ADR 0011). `unspecified` defers to
|
|
26
|
+
* the merchant's default tax behavior; once a price says `inclusive` or
|
|
27
|
+
* `exclusive` it can never change.
|
|
28
|
+
*/
|
|
29
|
+
exports.PRICE_TAX_BEHAVIORS = ['inclusive', 'exclusive', 'unspecified'];
|
|
30
|
+
exports.TRANSFORM_QUANTITY_ROUNDS = ['up', 'down'];
|
|
31
|
+
/** How long a coupon's discount lasts once applied to a subscription. */
|
|
32
|
+
exports.COUPON_DURATIONS = ['once', 'repeating', 'forever'];
|
|
33
|
+
/** The bounds the gateway enforces, published so a form can say them first. */
|
|
34
|
+
exports.CATALOG_LIMITS = Object.freeze({
|
|
35
|
+
productNameMax: 250,
|
|
36
|
+
productDescriptionMax: 40000,
|
|
37
|
+
productImagesMax: 8,
|
|
38
|
+
urlMax: 2048,
|
|
39
|
+
unitLabelMax: 12,
|
|
40
|
+
statementDescriptorMax: 22,
|
|
41
|
+
marketingFeaturesMax: 15,
|
|
42
|
+
marketingFeatureNameMax: 80,
|
|
43
|
+
priceNicknameMax: 250,
|
|
44
|
+
lookupKeyMax: 200,
|
|
45
|
+
lookupKeysFilterMax: 10,
|
|
46
|
+
priceTiersMax: 250,
|
|
47
|
+
couponIdMax: 64,
|
|
48
|
+
couponNameMax: 40,
|
|
49
|
+
couponAppliesToProductsMax: 100,
|
|
50
|
+
couponDurationInMonthsMax: 1200,
|
|
51
|
+
promotionCodeMax: 64,
|
|
52
|
+
idsFilterMax: 100,
|
|
53
|
+
});
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TAX_LOCATION_EVIDENCE_TYPES = exports.TAX_REGISTRATION_SCHEMES = exports.PEABLE_BILLING_AUTHORITY_KEYS = exports.canonicalBillingTaxQuote = exports.canonicalBillingAuthority = exports.BILLING_SUBSCRIPTION_STATUSES = exports.SOCIAL_SOURCE_REF_MAX_LENGTH = exports.SOCIAL_SOURCE_APP_MAX_LENGTH = exports.MERCHANT_ENVIRONMENTS = exports.verifyWebhook = exports.signWebhook = exports.WEBHOOK_SECRET_ROLL_MAX_EXPIRES_IN_SECONDS = exports.WEBHOOK_ENDPOINTS_MAX_PER_MERCHANT = exports.WEBHOOK_ENDPOINT_DISABLED_REASONS = exports.WEBHOOK_ENDPOINT_STATUSES = exports.PEABLE_API_VERSION = exports.SETUP_INTENT_STATUSES = exports.isValidStatusTransition = exports.canStillBePaid = exports.canExpire = exports.TERMINAL_STATUSES = exports.PAYMENT_INTENT_STATUSES = exports.PAYMENT_INTENT_SETUP_FUTURE_USAGES = exports.PAYMENT_INTENT_RAILS = exports.PAYMENT_INTENT_CAPTURE_METHODS = exports.PAYMENT_INTENT_CANCELLATION_REASONS = exports.MERCHANT_CANCELLATION_REASONS = exports.EXPIRABLE_STATUSES = exports.CARD_ONLY_STATUSES = exports.isCurrencyCode = exports.decimalsFor = exports.CURRENCY_DECIMALS = exports.CURRENCY_CODES = exports.isBaseUnitString = exports.UNITS_PER_COIN = void 0;
|
|
3
|
+
exports.TAX_LOCATION_EVIDENCE_TYPES = exports.TAX_REGISTRATION_SCHEMES = exports.PEABLE_BILLING_AUTHORITY_KEYS = exports.canonicalBillingTaxQuote = exports.canonicalBillingAuthority = exports.BILLING_SUBSCRIPTION_STATUSES = exports.SOCIAL_SOURCE_REF_MAX_LENGTH = exports.SOCIAL_SOURCE_APP_MAX_LENGTH = exports.MERCHANT_ENVIRONMENTS = exports.verifyWebhook = exports.signWebhook = exports.SIMULATED_FAIRCOIN_OUTCOMES = exports.REQUEST_LOG_RETENTION_DAYS = exports.REQUEST_LOG_METHODS = exports.CATALOG_LIMITS = exports.COUPON_DURATIONS = exports.TRANSFORM_QUANTITY_ROUNDS = exports.PRICE_TAX_BEHAVIORS = exports.RECURRING_USAGE_TYPES = exports.RECURRING_INTERVALS = exports.PRICE_TYPES = exports.PRICE_TIERS_MODES = exports.PRICE_BILLING_SCHEMES = exports.WEBHOOK_SECRET_ROLL_MAX_EXPIRES_IN_SECONDS = exports.WEBHOOK_ENDPOINTS_MAX_PER_MERCHANT = exports.WEBHOOK_ENDPOINT_DISABLED_REASONS = exports.WEBHOOK_ENDPOINT_STATUSES = exports.PEABLE_API_VERSION = exports.SETUP_INTENT_STATUSES = exports.isValidStatusTransition = exports.canStillBePaid = exports.canExpire = exports.TERMINAL_STATUSES = exports.PAYMENT_INTENT_STATUSES = exports.PAYMENT_INTENT_SETUP_FUTURE_USAGES = exports.PAYMENT_INTENT_RAILS = exports.PAYMENT_INTENT_CAPTURE_METHODS = exports.PAYMENT_INTENT_CANCELLATION_REASONS = exports.MERCHANT_CANCELLATION_REASONS = exports.EXPIRABLE_STATUSES = exports.CARD_ONLY_STATUSES = exports.isCurrencyCode = exports.decimalsFor = exports.CURRENCY_DECIMALS = exports.CURRENCY_CODES = exports.isBaseUnitString = exports.UNITS_PER_COIN = void 0;
|
|
4
4
|
// @peable.to/shared-types — public API for the Peable Gateway contract.
|
|
5
5
|
var money_1 = require("./money");
|
|
6
6
|
Object.defineProperty(exports, "UNITS_PER_COIN", { enumerable: true, get: function () { return money_1.UNITS_PER_COIN; } });
|
|
@@ -31,6 +31,21 @@ Object.defineProperty(exports, "WEBHOOK_ENDPOINT_STATUSES", { enumerable: true,
|
|
|
31
31
|
Object.defineProperty(exports, "WEBHOOK_ENDPOINT_DISABLED_REASONS", { enumerable: true, get: function () { return webhookEndpoint_1.WEBHOOK_ENDPOINT_DISABLED_REASONS; } });
|
|
32
32
|
Object.defineProperty(exports, "WEBHOOK_ENDPOINTS_MAX_PER_MERCHANT", { enumerable: true, get: function () { return webhookEndpoint_1.WEBHOOK_ENDPOINTS_MAX_PER_MERCHANT; } });
|
|
33
33
|
Object.defineProperty(exports, "WEBHOOK_SECRET_ROLL_MAX_EXPIRES_IN_SECONDS", { enumerable: true, get: function () { return webhookEndpoint_1.WEBHOOK_SECRET_ROLL_MAX_EXPIRES_IN_SECONDS; } });
|
|
34
|
+
var catalog_1 = require("./catalog");
|
|
35
|
+
Object.defineProperty(exports, "PRICE_BILLING_SCHEMES", { enumerable: true, get: function () { return catalog_1.PRICE_BILLING_SCHEMES; } });
|
|
36
|
+
Object.defineProperty(exports, "PRICE_TIERS_MODES", { enumerable: true, get: function () { return catalog_1.PRICE_TIERS_MODES; } });
|
|
37
|
+
Object.defineProperty(exports, "PRICE_TYPES", { enumerable: true, get: function () { return catalog_1.PRICE_TYPES; } });
|
|
38
|
+
Object.defineProperty(exports, "RECURRING_INTERVALS", { enumerable: true, get: function () { return catalog_1.RECURRING_INTERVALS; } });
|
|
39
|
+
Object.defineProperty(exports, "RECURRING_USAGE_TYPES", { enumerable: true, get: function () { return catalog_1.RECURRING_USAGE_TYPES; } });
|
|
40
|
+
Object.defineProperty(exports, "PRICE_TAX_BEHAVIORS", { enumerable: true, get: function () { return catalog_1.PRICE_TAX_BEHAVIORS; } });
|
|
41
|
+
Object.defineProperty(exports, "TRANSFORM_QUANTITY_ROUNDS", { enumerable: true, get: function () { return catalog_1.TRANSFORM_QUANTITY_ROUNDS; } });
|
|
42
|
+
Object.defineProperty(exports, "COUPON_DURATIONS", { enumerable: true, get: function () { return catalog_1.COUPON_DURATIONS; } });
|
|
43
|
+
Object.defineProperty(exports, "CATALOG_LIMITS", { enumerable: true, get: function () { return catalog_1.CATALOG_LIMITS; } });
|
|
44
|
+
var requestLog_1 = require("./requestLog");
|
|
45
|
+
Object.defineProperty(exports, "REQUEST_LOG_METHODS", { enumerable: true, get: function () { return requestLog_1.REQUEST_LOG_METHODS; } });
|
|
46
|
+
Object.defineProperty(exports, "REQUEST_LOG_RETENTION_DAYS", { enumerable: true, get: function () { return requestLog_1.REQUEST_LOG_RETENTION_DAYS; } });
|
|
47
|
+
var testHelpers_1 = require("./testHelpers");
|
|
48
|
+
Object.defineProperty(exports, "SIMULATED_FAIRCOIN_OUTCOMES", { enumerable: true, get: function () { return testHelpers_1.SIMULATED_FAIRCOIN_OUTCOMES; } });
|
|
34
49
|
var webhookSigner_1 = require("./webhookSigner");
|
|
35
50
|
Object.defineProperty(exports, "signWebhook", { enumerable: true, get: function () { return webhookSigner_1.signWebhook; } });
|
|
36
51
|
Object.defineProperty(exports, "verifyWebhook", { enumerable: true, get: function () { return webhookSigner_1.verifyWebhook; } });
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REQUEST_LOG_RETENTION_DAYS = exports.REQUEST_LOG_METHODS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* One merchant API request, as Peable recorded it (`req_…`) — the request log
|
|
6
|
+
* Orbit and `peable logs tail` read.
|
|
7
|
+
*
|
|
8
|
+
* Its `id` IS the `Request-Id` that request was answered with, so the id a
|
|
9
|
+
* merchant quotes to support and the log row are the same thing.
|
|
10
|
+
*
|
|
11
|
+
* Deliberately thin: method, path (no query string), status, duration and the
|
|
12
|
+
* `Idempotency-Key` it carried. No body, no headers, no query string, no
|
|
13
|
+
* caller address — a log a merchant can read is a log that must not hold what
|
|
14
|
+
* a request carried. Kept 30 days.
|
|
15
|
+
*/
|
|
16
|
+
exports.REQUEST_LOG_METHODS = ['GET', 'POST', 'DELETE', 'PATCH', 'PUT'];
|
|
17
|
+
/** How long a request log is kept (and served). */
|
|
18
|
+
exports.REQUEST_LOG_RETENTION_DAYS = 30;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Test helpers (`/v1/test_helpers/*`) — test mode only.
|
|
4
|
+
*
|
|
5
|
+
* They drive a test-mode object through the SAME state machine a real payment
|
|
6
|
+
* moves through, so a merchant can exercise their integration end to end
|
|
7
|
+
* without a wallet or a card: every transition a helper makes is one the
|
|
8
|
+
* gateway would make, with the same events and webhooks.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.SIMULATED_FAIRCOIN_OUTCOMES = void 0;
|
|
12
|
+
/**
|
|
13
|
+
* What `simulate_faircoin_payment` pretends the payer did.
|
|
14
|
+
*
|
|
15
|
+
* - `settled` — paid the full amount, which is then seen in the mempool and
|
|
16
|
+
* confirmed: `broadcast → confirming → settled`
|
|
17
|
+
* (`payment_intent.confirming`, then `payment_intent.settled`).
|
|
18
|
+
* - `underpaid` — sent less than the amount: `broadcast → failed`
|
|
19
|
+
* (`payment_intent.failed`).
|
|
20
|
+
*/
|
|
21
|
+
exports.SIMULATED_FAIRCOIN_OUTCOMES = ['settled', 'underpaid'];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** How a price's amount is computed from a quantity. */
|
|
2
|
+
export const PRICE_BILLING_SCHEMES = ['per_unit', 'tiered'];
|
|
3
|
+
/**
|
|
4
|
+
* How a tiered price reads its tiers.
|
|
5
|
+
*
|
|
6
|
+
* - `volume` — the WHOLE quantity is priced at the tier it falls into.
|
|
7
|
+
* - `graduated` — each unit is priced at the tier it falls into, so a
|
|
8
|
+
* quantity crossing two tiers pays each tier's rate for its
|
|
9
|
+
* share, plus the flat amount of every tier it reaches.
|
|
10
|
+
*/
|
|
11
|
+
export const PRICE_TIERS_MODES = ['graduated', 'volume'];
|
|
12
|
+
/** `recurring` when the price has a recurring component, `one_time` otherwise. */
|
|
13
|
+
export const PRICE_TYPES = ['one_time', 'recurring'];
|
|
14
|
+
export const RECURRING_INTERVALS = ['day', 'week', 'month', 'year'];
|
|
15
|
+
/**
|
|
16
|
+
* `licensed` bills the quantity on the subscription. `metered` bills reported
|
|
17
|
+
* usage and needs a meter; meters are not part of Orbit yet, so the gateway
|
|
18
|
+
* refuses a metered price rather than store one nothing can bill.
|
|
19
|
+
*/
|
|
20
|
+
export const RECURRING_USAGE_TYPES = ['licensed', 'metered'];
|
|
21
|
+
/**
|
|
22
|
+
* Whether a price includes tax (Peable Tax, ADR 0011). `unspecified` defers to
|
|
23
|
+
* the merchant's default tax behavior; once a price says `inclusive` or
|
|
24
|
+
* `exclusive` it can never change.
|
|
25
|
+
*/
|
|
26
|
+
export const PRICE_TAX_BEHAVIORS = ['inclusive', 'exclusive', 'unspecified'];
|
|
27
|
+
export const TRANSFORM_QUANTITY_ROUNDS = ['up', 'down'];
|
|
28
|
+
/** How long a coupon's discount lasts once applied to a subscription. */
|
|
29
|
+
export const COUPON_DURATIONS = ['once', 'repeating', 'forever'];
|
|
30
|
+
/** The bounds the gateway enforces, published so a form can say them first. */
|
|
31
|
+
export const CATALOG_LIMITS = Object.freeze({
|
|
32
|
+
productNameMax: 250,
|
|
33
|
+
productDescriptionMax: 40000,
|
|
34
|
+
productImagesMax: 8,
|
|
35
|
+
urlMax: 2048,
|
|
36
|
+
unitLabelMax: 12,
|
|
37
|
+
statementDescriptorMax: 22,
|
|
38
|
+
marketingFeaturesMax: 15,
|
|
39
|
+
marketingFeatureNameMax: 80,
|
|
40
|
+
priceNicknameMax: 250,
|
|
41
|
+
lookupKeyMax: 200,
|
|
42
|
+
lookupKeysFilterMax: 10,
|
|
43
|
+
priceTiersMax: 250,
|
|
44
|
+
couponIdMax: 64,
|
|
45
|
+
couponNameMax: 40,
|
|
46
|
+
couponAppliesToProductsMax: 100,
|
|
47
|
+
couponDurationInMonthsMax: 1200,
|
|
48
|
+
promotionCodeMax: 64,
|
|
49
|
+
idsFilterMax: 100,
|
|
50
|
+
});
|
package/dist/esm/index.js
CHANGED
|
@@ -4,6 +4,9 @@ export { CARD_ONLY_STATUSES, EXPIRABLE_STATUSES, MERCHANT_CANCELLATION_REASONS,
|
|
|
4
4
|
export { SETUP_INTENT_STATUSES, } from './setupIntent.js';
|
|
5
5
|
export { PEABLE_API_VERSION, } from './event.js';
|
|
6
6
|
export { WEBHOOK_ENDPOINT_STATUSES, WEBHOOK_ENDPOINT_DISABLED_REASONS, WEBHOOK_ENDPOINTS_MAX_PER_MERCHANT, WEBHOOK_SECRET_ROLL_MAX_EXPIRES_IN_SECONDS, } from './webhookEndpoint.js';
|
|
7
|
+
export { PRICE_BILLING_SCHEMES, PRICE_TIERS_MODES, PRICE_TYPES, RECURRING_INTERVALS, RECURRING_USAGE_TYPES, PRICE_TAX_BEHAVIORS, TRANSFORM_QUANTITY_ROUNDS, COUPON_DURATIONS, CATALOG_LIMITS, } from './catalog.js';
|
|
8
|
+
export { REQUEST_LOG_METHODS, REQUEST_LOG_RETENTION_DAYS, } from './requestLog.js';
|
|
9
|
+
export { SIMULATED_FAIRCOIN_OUTCOMES, } from './testHelpers.js';
|
|
7
10
|
export { signWebhook, verifyWebhook } from './webhookSigner.js';
|
|
8
11
|
export { MERCHANT_ENVIRONMENTS, } from './merchant.js';
|
|
9
12
|
export { SOCIAL_SOURCE_APP_MAX_LENGTH, SOCIAL_SOURCE_REF_MAX_LENGTH, } from './social.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One merchant API request, as Peable recorded it (`req_…`) — the request log
|
|
3
|
+
* Orbit and `peable logs tail` read.
|
|
4
|
+
*
|
|
5
|
+
* Its `id` IS the `Request-Id` that request was answered with, so the id a
|
|
6
|
+
* merchant quotes to support and the log row are the same thing.
|
|
7
|
+
*
|
|
8
|
+
* Deliberately thin: method, path (no query string), status, duration and the
|
|
9
|
+
* `Idempotency-Key` it carried. No body, no headers, no query string, no
|
|
10
|
+
* caller address — a log a merchant can read is a log that must not hold what
|
|
11
|
+
* a request carried. Kept 30 days.
|
|
12
|
+
*/
|
|
13
|
+
export const REQUEST_LOG_METHODS = ['GET', 'POST', 'DELETE', 'PATCH', 'PUT'];
|
|
14
|
+
/** How long a request log is kept (and served). */
|
|
15
|
+
export const REQUEST_LOG_RETENTION_DAYS = 30;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test helpers (`/v1/test_helpers/*`) — test mode only.
|
|
3
|
+
*
|
|
4
|
+
* They drive a test-mode object through the SAME state machine a real payment
|
|
5
|
+
* moves through, so a merchant can exercise their integration end to end
|
|
6
|
+
* without a wallet or a card: every transition a helper makes is one the
|
|
7
|
+
* gateway would make, with the same events and webhooks.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* What `simulate_faircoin_payment` pretends the payer did.
|
|
11
|
+
*
|
|
12
|
+
* - `settled` — paid the full amount, which is then seen in the mempool and
|
|
13
|
+
* confirmed: `broadcast → confirming → settled`
|
|
14
|
+
* (`payment_intent.confirming`, then `payment_intent.settled`).
|
|
15
|
+
* - `underpaid` — sent less than the amount: `broadcast → failed`
|
|
16
|
+
* (`payment_intent.failed`).
|
|
17
|
+
*/
|
|
18
|
+
export const SIMULATED_FAIRCOIN_OUTCOMES = ['settled', 'underpaid'];
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import type { ListParams } from './list';
|
|
2
|
+
import type { Customer } from './customer';
|
|
3
|
+
import type { CurrencyCode } from './money';
|
|
4
|
+
/** How a price's amount is computed from a quantity. */
|
|
5
|
+
export declare const PRICE_BILLING_SCHEMES: readonly ["per_unit", "tiered"];
|
|
6
|
+
export type PriceBillingScheme = (typeof PRICE_BILLING_SCHEMES)[number];
|
|
7
|
+
/**
|
|
8
|
+
* How a tiered price reads its tiers.
|
|
9
|
+
*
|
|
10
|
+
* - `volume` — the WHOLE quantity is priced at the tier it falls into.
|
|
11
|
+
* - `graduated` — each unit is priced at the tier it falls into, so a
|
|
12
|
+
* quantity crossing two tiers pays each tier's rate for its
|
|
13
|
+
* share, plus the flat amount of every tier it reaches.
|
|
14
|
+
*/
|
|
15
|
+
export declare const PRICE_TIERS_MODES: readonly ["graduated", "volume"];
|
|
16
|
+
export type PriceTiersMode = (typeof PRICE_TIERS_MODES)[number];
|
|
17
|
+
/** `recurring` when the price has a recurring component, `one_time` otherwise. */
|
|
18
|
+
export declare const PRICE_TYPES: readonly ["one_time", "recurring"];
|
|
19
|
+
export type PriceType = (typeof PRICE_TYPES)[number];
|
|
20
|
+
export declare const RECURRING_INTERVALS: readonly ["day", "week", "month", "year"];
|
|
21
|
+
export type RecurringInterval = (typeof RECURRING_INTERVALS)[number];
|
|
22
|
+
/**
|
|
23
|
+
* `licensed` bills the quantity on the subscription. `metered` bills reported
|
|
24
|
+
* usage and needs a meter; meters are not part of Orbit yet, so the gateway
|
|
25
|
+
* refuses a metered price rather than store one nothing can bill.
|
|
26
|
+
*/
|
|
27
|
+
export declare const RECURRING_USAGE_TYPES: readonly ["licensed", "metered"];
|
|
28
|
+
export type RecurringUsageType = (typeof RECURRING_USAGE_TYPES)[number];
|
|
29
|
+
/**
|
|
30
|
+
* Whether a price includes tax (Peable Tax, ADR 0011). `unspecified` defers to
|
|
31
|
+
* the merchant's default tax behavior; once a price says `inclusive` or
|
|
32
|
+
* `exclusive` it can never change.
|
|
33
|
+
*/
|
|
34
|
+
export declare const PRICE_TAX_BEHAVIORS: readonly ["inclusive", "exclusive", "unspecified"];
|
|
35
|
+
export type PriceTaxBehavior = (typeof PRICE_TAX_BEHAVIORS)[number];
|
|
36
|
+
export declare const TRANSFORM_QUANTITY_ROUNDS: readonly ["up", "down"];
|
|
37
|
+
export type TransformQuantityRound = (typeof TRANSFORM_QUANTITY_ROUNDS)[number];
|
|
38
|
+
/** How long a coupon's discount lasts once applied to a subscription. */
|
|
39
|
+
export declare const COUPON_DURATIONS: readonly ["once", "repeating", "forever"];
|
|
40
|
+
export type CouponDuration = (typeof COUPON_DURATIONS)[number];
|
|
41
|
+
/** The bounds the gateway enforces, published so a form can say them first. */
|
|
42
|
+
export declare const CATALOG_LIMITS: Readonly<{
|
|
43
|
+
productNameMax: 250;
|
|
44
|
+
productDescriptionMax: 40000;
|
|
45
|
+
productImagesMax: 8;
|
|
46
|
+
urlMax: 2048;
|
|
47
|
+
unitLabelMax: 12;
|
|
48
|
+
statementDescriptorMax: 22;
|
|
49
|
+
marketingFeaturesMax: 15;
|
|
50
|
+
marketingFeatureNameMax: 80;
|
|
51
|
+
priceNicknameMax: 250;
|
|
52
|
+
lookupKeyMax: 200;
|
|
53
|
+
lookupKeysFilterMax: 10;
|
|
54
|
+
priceTiersMax: 250;
|
|
55
|
+
couponIdMax: 64;
|
|
56
|
+
couponNameMax: 40;
|
|
57
|
+
couponAppliesToProductsMax: 100;
|
|
58
|
+
couponDurationInMonthsMax: 1200;
|
|
59
|
+
promotionCodeMax: 64;
|
|
60
|
+
idsFilterMax: 100;
|
|
61
|
+
}>;
|
|
62
|
+
/** A product feature shown on pricing tables and checkout (Stripe's marketing features). */
|
|
63
|
+
export interface ProductMarketingFeature {
|
|
64
|
+
name: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A product (`prod_…`) — what a merchant sells. Its prices say how much.
|
|
68
|
+
*
|
|
69
|
+
* A product with prices cannot be deleted; set `active: false` to archive it.
|
|
70
|
+
*/
|
|
71
|
+
export interface Product {
|
|
72
|
+
id: string;
|
|
73
|
+
object: 'product';
|
|
74
|
+
/** The mode of the merchant that owns it (ADR 0017). */
|
|
75
|
+
livemode: boolean;
|
|
76
|
+
active: boolean;
|
|
77
|
+
name: string;
|
|
78
|
+
description: string | null;
|
|
79
|
+
/** Up to 8 image URLs. */
|
|
80
|
+
images: string[];
|
|
81
|
+
metadata: Record<string, string>;
|
|
82
|
+
/** A Peable Tax code (`txcd_…`), or `null` for the merchant's default. */
|
|
83
|
+
tax_code: string | null;
|
|
84
|
+
/** The product's default price — a `price_…`, or the Price when expanded. */
|
|
85
|
+
default_price: string | Price | null;
|
|
86
|
+
/** The unit a quantity counts (`seat`), shown on receipts and invoices. */
|
|
87
|
+
unit_label: string | null;
|
|
88
|
+
url: string | null;
|
|
89
|
+
/** What appears on a card statement; at most 22 characters. */
|
|
90
|
+
statement_descriptor: string | null;
|
|
91
|
+
marketing_features: ProductMarketingFeature[];
|
|
92
|
+
created: number;
|
|
93
|
+
updated: number;
|
|
94
|
+
}
|
|
95
|
+
/** What `DELETE /v1/products/:id` answers. */
|
|
96
|
+
export interface DeletedProduct {
|
|
97
|
+
id: string;
|
|
98
|
+
object: 'product';
|
|
99
|
+
deleted: true;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* One tier of a tiered price. `up_to` is the last quantity the tier covers
|
|
103
|
+
* (inclusive), and `null` on the last tier, which covers everything above —
|
|
104
|
+
* sent as `'inf'`. Each amount is a base-unit string; at least one is set.
|
|
105
|
+
*/
|
|
106
|
+
export interface PriceTier {
|
|
107
|
+
up_to: number | null;
|
|
108
|
+
unit_amount: string | null;
|
|
109
|
+
flat_amount: string | null;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Divide the quantity before pricing it: `divide_by: 10, round: 'up'` bills
|
|
113
|
+
* 11 units as 2 packs of ten. Per-unit prices only.
|
|
114
|
+
*/
|
|
115
|
+
export interface PriceTransformQuantity {
|
|
116
|
+
divide_by: number;
|
|
117
|
+
round: TransformQuantityRound;
|
|
118
|
+
}
|
|
119
|
+
export interface PriceRecurring {
|
|
120
|
+
interval: RecurringInterval;
|
|
121
|
+
/** Intervals between billings: `interval: 'month', interval_count: 3` is quarterly. At most three years. */
|
|
122
|
+
interval_count: number;
|
|
123
|
+
usage_type: RecurringUsageType;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* A price (`price_…`) — how much a product costs, in one currency, once or per
|
|
127
|
+
* interval.
|
|
128
|
+
*
|
|
129
|
+
* IMMUTABLE once created except for `active`, `nickname`, `metadata`,
|
|
130
|
+
* `lookup_key` and — while it is `unspecified` — `tax_behavior`. To change an
|
|
131
|
+
* amount, create a new price and archive the old one: a subscription priced
|
|
132
|
+
* from it must keep meaning what it meant.
|
|
133
|
+
*/
|
|
134
|
+
export interface Price {
|
|
135
|
+
id: string;
|
|
136
|
+
object: 'price';
|
|
137
|
+
livemode: boolean;
|
|
138
|
+
active: boolean;
|
|
139
|
+
/** The product it prices — a `prod_…`, or the Product when expanded. */
|
|
140
|
+
product: string | Product;
|
|
141
|
+
currency: CurrencyCode;
|
|
142
|
+
/** Base units per unit; `null` on a tiered price. */
|
|
143
|
+
unit_amount: string | null;
|
|
144
|
+
billing_scheme: PriceBillingScheme;
|
|
145
|
+
/** `null` unless `billing_scheme` is `tiered`. */
|
|
146
|
+
tiers: PriceTier[] | null;
|
|
147
|
+
tiers_mode: PriceTiersMode | null;
|
|
148
|
+
transform_quantity: PriceTransformQuantity | null;
|
|
149
|
+
type: PriceType;
|
|
150
|
+
/** `null` exactly when `type` is `one_time`. */
|
|
151
|
+
recurring: PriceRecurring | null;
|
|
152
|
+
tax_behavior: PriceTaxBehavior;
|
|
153
|
+
/**
|
|
154
|
+
* The merchant's own stable name for this price, unique among its prices
|
|
155
|
+
* (per mode): retrieve the current price of a plan with `lookup_keys[]`
|
|
156
|
+
* without storing an id that changes whenever the amount does.
|
|
157
|
+
*/
|
|
158
|
+
lookup_key: string | null;
|
|
159
|
+
nickname: string | null;
|
|
160
|
+
metadata: Record<string, string>;
|
|
161
|
+
created: number;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* A coupon — a discount, by percentage or by a fixed amount in one currency.
|
|
165
|
+
* Its `id` is the merchant's own (`SUMMER25`) or generated (`coupon_…`), and
|
|
166
|
+
* names that one coupon forever: a deleted coupon's id is never reused.
|
|
167
|
+
*
|
|
168
|
+
* Only `name` and `metadata` can change; the terms of a discount a customer
|
|
169
|
+
* already holds cannot.
|
|
170
|
+
*/
|
|
171
|
+
export interface Coupon {
|
|
172
|
+
id: string;
|
|
173
|
+
object: 'coupon';
|
|
174
|
+
livemode: boolean;
|
|
175
|
+
name: string | null;
|
|
176
|
+
/** 0 < x ≤ 100, at most two decimals. Set exactly when `amount_off` is not. */
|
|
177
|
+
percent_off: number | null;
|
|
178
|
+
/** Base units taken off, in `currency`. */
|
|
179
|
+
amount_off: string | null;
|
|
180
|
+
currency: CurrencyCode | null;
|
|
181
|
+
duration: CouponDuration;
|
|
182
|
+
/** Months a `repeating` coupon lasts; `null` otherwise. */
|
|
183
|
+
duration_in_months: number | null;
|
|
184
|
+
max_redemptions: number | null;
|
|
185
|
+
/** The last instant (Unix seconds) it can be redeemed. */
|
|
186
|
+
redeem_by: number | null;
|
|
187
|
+
times_redeemed: number;
|
|
188
|
+
/** Whether it can still be redeemed: not past `redeem_by` and not used up. */
|
|
189
|
+
valid: boolean;
|
|
190
|
+
/** The products it is restricted to, or `null` for every product. */
|
|
191
|
+
applies_to: {
|
|
192
|
+
products: string[];
|
|
193
|
+
} | null;
|
|
194
|
+
metadata: Record<string, string>;
|
|
195
|
+
created: number;
|
|
196
|
+
}
|
|
197
|
+
/** What `DELETE /v1/coupons/:id` answers. Existing discounts are not affected. */
|
|
198
|
+
export interface DeletedCoupon {
|
|
199
|
+
id: string;
|
|
200
|
+
object: 'coupon';
|
|
201
|
+
deleted: true;
|
|
202
|
+
}
|
|
203
|
+
export interface PromotionCodeRestrictions {
|
|
204
|
+
/** Only a customer's first transaction may redeem it. */
|
|
205
|
+
first_time_transaction: boolean;
|
|
206
|
+
/** The smallest order total (base units) it applies to, in `minimum_amount_currency`. */
|
|
207
|
+
minimum_amount: string | null;
|
|
208
|
+
minimum_amount_currency: CurrencyCode | null;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* A promotion code (`promo_…`) — a customer-facing `code` that redeems a
|
|
212
|
+
* coupon, with its own limits. Codes are case-insensitive and unique among a
|
|
213
|
+
* merchant's ACTIVE codes.
|
|
214
|
+
*/
|
|
215
|
+
export interface PromotionCode {
|
|
216
|
+
id: string;
|
|
217
|
+
object: 'promotion_code';
|
|
218
|
+
livemode: boolean;
|
|
219
|
+
code: string;
|
|
220
|
+
/** The coupon it redeems — its id, or the Coupon when expanded. */
|
|
221
|
+
coupon: string | Coupon;
|
|
222
|
+
/** The one customer who may redeem it (`cus_…`, or the Customer when expanded); `null` for anyone. */
|
|
223
|
+
customer: string | Customer | null;
|
|
224
|
+
active: boolean;
|
|
225
|
+
max_redemptions: number | null;
|
|
226
|
+
/** Unix seconds; never after the coupon's `redeem_by`. */
|
|
227
|
+
expires_at: number | null;
|
|
228
|
+
times_redeemed: number;
|
|
229
|
+
restrictions: PromotionCodeRestrictions;
|
|
230
|
+
metadata: Record<string, string>;
|
|
231
|
+
created: number;
|
|
232
|
+
}
|
|
233
|
+
export interface RecurringParams {
|
|
234
|
+
interval: RecurringInterval;
|
|
235
|
+
/** Default 1. */
|
|
236
|
+
interval_count?: number;
|
|
237
|
+
/** Default `licensed`. */
|
|
238
|
+
usage_type?: RecurringUsageType;
|
|
239
|
+
}
|
|
240
|
+
export interface PriceTierParams {
|
|
241
|
+
/** A positive integer, ascending; the last tier is `'inf'`. */
|
|
242
|
+
up_to: number | 'inf';
|
|
243
|
+
unit_amount?: string;
|
|
244
|
+
flat_amount?: string;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* An inline price (Stripe's `price_data`): what a checkout line item or an
|
|
248
|
+
* invoice item names when it has no stored `price_…`. Per-unit only.
|
|
249
|
+
*/
|
|
250
|
+
export interface PriceDataParams {
|
|
251
|
+
currency: CurrencyCode;
|
|
252
|
+
/** The `prod_…` it prices. */
|
|
253
|
+
product: string;
|
|
254
|
+
unit_amount: string;
|
|
255
|
+
recurring?: Omit<RecurringParams, 'usage_type'>;
|
|
256
|
+
tax_behavior?: PriceTaxBehavior;
|
|
257
|
+
}
|
|
258
|
+
/** `default_price_data` on a product create: `price_data` for the product being created. */
|
|
259
|
+
export type DefaultPriceDataParams = Omit<PriceDataParams, 'product'>;
|
|
260
|
+
export interface CreateProductParams {
|
|
261
|
+
name: string;
|
|
262
|
+
active?: boolean;
|
|
263
|
+
description?: string;
|
|
264
|
+
images?: string[];
|
|
265
|
+
metadata?: Record<string, string>;
|
|
266
|
+
tax_code?: string;
|
|
267
|
+
/** Create the product's default price with it. */
|
|
268
|
+
default_price_data?: DefaultPriceDataParams;
|
|
269
|
+
unit_label?: string;
|
|
270
|
+
url?: string;
|
|
271
|
+
statement_descriptor?: string;
|
|
272
|
+
marketing_features?: ProductMarketingFeature[];
|
|
273
|
+
}
|
|
274
|
+
/** `''` clears an optional text field; `metadata` is merged. */
|
|
275
|
+
export interface UpdateProductParams {
|
|
276
|
+
name?: string;
|
|
277
|
+
active?: boolean;
|
|
278
|
+
description?: string;
|
|
279
|
+
images?: string[];
|
|
280
|
+
metadata?: Record<string, string>;
|
|
281
|
+
tax_code?: string;
|
|
282
|
+
/** One of this product's active prices; `''` clears it. */
|
|
283
|
+
default_price?: string;
|
|
284
|
+
unit_label?: string;
|
|
285
|
+
url?: string;
|
|
286
|
+
statement_descriptor?: string;
|
|
287
|
+
marketing_features?: ProductMarketingFeature[];
|
|
288
|
+
}
|
|
289
|
+
export interface ProductListParams extends ListParams {
|
|
290
|
+
active?: boolean;
|
|
291
|
+
/** Only these products (at most 100). */
|
|
292
|
+
ids?: string[];
|
|
293
|
+
}
|
|
294
|
+
export interface CreatePriceParams {
|
|
295
|
+
product: string;
|
|
296
|
+
currency: CurrencyCode;
|
|
297
|
+
/** Required for `per_unit`; absent for `tiered`. */
|
|
298
|
+
unit_amount?: string;
|
|
299
|
+
/** Default `per_unit`. */
|
|
300
|
+
billing_scheme?: PriceBillingScheme;
|
|
301
|
+
tiers?: PriceTierParams[];
|
|
302
|
+
tiers_mode?: PriceTiersMode;
|
|
303
|
+
transform_quantity?: PriceTransformQuantity;
|
|
304
|
+
/** Present: a recurring price. Absent: one-time. */
|
|
305
|
+
recurring?: RecurringParams;
|
|
306
|
+
/** Default `unspecified`. */
|
|
307
|
+
tax_behavior?: PriceTaxBehavior;
|
|
308
|
+
lookup_key?: string;
|
|
309
|
+
/** Move `lookup_key` here from the price that holds it. */
|
|
310
|
+
transfer_lookup_key?: boolean;
|
|
311
|
+
nickname?: string;
|
|
312
|
+
active?: boolean;
|
|
313
|
+
metadata?: Record<string, string>;
|
|
314
|
+
}
|
|
315
|
+
export interface UpdatePriceParams {
|
|
316
|
+
active?: boolean;
|
|
317
|
+
/** `''` clears it. */
|
|
318
|
+
nickname?: string;
|
|
319
|
+
metadata?: Record<string, string>;
|
|
320
|
+
/** `''` clears it. */
|
|
321
|
+
lookup_key?: string;
|
|
322
|
+
transfer_lookup_key?: boolean;
|
|
323
|
+
/** Only while the price's is `unspecified`. */
|
|
324
|
+
tax_behavior?: PriceTaxBehavior;
|
|
325
|
+
}
|
|
326
|
+
export interface PriceListParams extends ListParams {
|
|
327
|
+
product?: string;
|
|
328
|
+
active?: boolean;
|
|
329
|
+
type?: PriceType;
|
|
330
|
+
currency?: CurrencyCode;
|
|
331
|
+
/** At most 10. */
|
|
332
|
+
lookup_keys?: string[];
|
|
333
|
+
recurring?: {
|
|
334
|
+
interval?: RecurringInterval;
|
|
335
|
+
usage_type?: RecurringUsageType;
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
export interface CreateCouponParams {
|
|
339
|
+
/** Your own id (`SUMMER25`); generated (`coupon_…`) when absent. */
|
|
340
|
+
id?: string;
|
|
341
|
+
name?: string;
|
|
342
|
+
percent_off?: number;
|
|
343
|
+
amount_off?: string;
|
|
344
|
+
/** Required with `amount_off`. */
|
|
345
|
+
currency?: CurrencyCode;
|
|
346
|
+
/** Default `once`. */
|
|
347
|
+
duration?: CouponDuration;
|
|
348
|
+
/** Required for `repeating`. */
|
|
349
|
+
duration_in_months?: number;
|
|
350
|
+
max_redemptions?: number;
|
|
351
|
+
/** Unix seconds, in the future. */
|
|
352
|
+
redeem_by?: number;
|
|
353
|
+
applies_to?: {
|
|
354
|
+
products: string[];
|
|
355
|
+
};
|
|
356
|
+
metadata?: Record<string, string>;
|
|
357
|
+
}
|
|
358
|
+
export interface UpdateCouponParams {
|
|
359
|
+
/** `''` clears it. */
|
|
360
|
+
name?: string;
|
|
361
|
+
metadata?: Record<string, string>;
|
|
362
|
+
}
|
|
363
|
+
export interface CreatePromotionCodeParams {
|
|
364
|
+
coupon: string;
|
|
365
|
+
/** Letters and digits; generated when absent. */
|
|
366
|
+
code?: string;
|
|
367
|
+
/** Only this customer (`cus_…`) may redeem it. */
|
|
368
|
+
customer?: string;
|
|
369
|
+
active?: boolean;
|
|
370
|
+
max_redemptions?: number;
|
|
371
|
+
expires_at?: number;
|
|
372
|
+
restrictions?: {
|
|
373
|
+
first_time_transaction?: boolean;
|
|
374
|
+
minimum_amount?: string;
|
|
375
|
+
minimum_amount_currency?: CurrencyCode;
|
|
376
|
+
};
|
|
377
|
+
metadata?: Record<string, string>;
|
|
378
|
+
}
|
|
379
|
+
export interface UpdatePromotionCodeParams {
|
|
380
|
+
active?: boolean;
|
|
381
|
+
metadata?: Record<string, string>;
|
|
382
|
+
}
|
|
383
|
+
export interface PromotionCodeListParams extends ListParams {
|
|
384
|
+
/** Case-insensitive. */
|
|
385
|
+
code?: string;
|
|
386
|
+
coupon?: string;
|
|
387
|
+
customer?: string;
|
|
388
|
+
active?: boolean;
|
|
389
|
+
}
|
|
390
|
+
export type CouponListParams = ListParams;
|
package/dist/types/event.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Charge } from './charge';
|
|
2
|
+
import type { Coupon, Price, Product, PromotionCode } from './catalog';
|
|
2
3
|
import type { Customer } from './customer';
|
|
3
4
|
import type { Dispute } from './dispute';
|
|
4
5
|
import type { PaymentIntent } from './paymentIntent';
|
|
@@ -72,6 +73,26 @@ export interface WebhookEventPayload {
|
|
|
72
73
|
'setup_intent.succeeded': SetupIntent;
|
|
73
74
|
'setup_intent.setup_failed': SetupIntent;
|
|
74
75
|
'setup_intent.canceled': SetupIntent;
|
|
76
|
+
/**
|
|
77
|
+
* The catalog (ADR 0018): each create, update and delete of a product,
|
|
78
|
+
* price, coupon or promotion code, carrying the object as it stands after
|
|
79
|
+
* the change (a deleted one as it stood before). An update names the moved
|
|
80
|
+
* fields in `data.previous_attributes`; an update that moved nothing records
|
|
81
|
+
* no event. Prices and promotion codes are never deleted — they are archived
|
|
82
|
+
* with `active: false` — so there is no `price.deleted` or
|
|
83
|
+
* `promotion_code.deleted`: a type that can never be sent is a promise the
|
|
84
|
+
* catalog cannot keep.
|
|
85
|
+
*/
|
|
86
|
+
'product.created': Product;
|
|
87
|
+
'product.updated': Product;
|
|
88
|
+
'product.deleted': Product;
|
|
89
|
+
'price.created': Price;
|
|
90
|
+
'price.updated': Price;
|
|
91
|
+
'coupon.created': Coupon;
|
|
92
|
+
'coupon.updated': Coupon;
|
|
93
|
+
'coupon.deleted': Coupon;
|
|
94
|
+
'promotion_code.created': PromotionCode;
|
|
95
|
+
'promotion_code.updated': PromotionCode;
|
|
75
96
|
/**
|
|
76
97
|
* A seller's account changed — their READINESS, in practice. Emitted when the
|
|
77
98
|
* fields a merchant ACTS on change, not on every refresh. It names no payment
|
package/dist/types/index.d.ts
CHANGED
|
@@ -8,9 +8,12 @@ export type { AttachPaymentMethodParams, BillingDetails, PaymentMethod, UpdatePa
|
|
|
8
8
|
export { type CancelSetupIntentParams, type CreateSetupIntentParams, type SetupIntent, type SetupIntentCancellationReason, type SetupIntentStatus, type SetupIntentUsage, SETUP_INTENT_STATUSES, } from './setupIntent';
|
|
9
9
|
export { PEABLE_API_VERSION, type WebhookEventType, type WebhookEvent, type WebhookEventPayload, type WebhookEventRequest, type BillingObservation, } from './event';
|
|
10
10
|
export { WEBHOOK_ENDPOINT_STATUSES, WEBHOOK_ENDPOINT_DISABLED_REASONS, WEBHOOK_ENDPOINTS_MAX_PER_MERCHANT, WEBHOOK_SECRET_ROLL_MAX_EXPIRES_IN_SECONDS, type WebhookEnabledEvent, type WebhookEndpoint, type WebhookEndpointStatus, type WebhookEndpointDisabledReason, type DeletedWebhookEndpoint, type CreateWebhookEndpointParams, type UpdateWebhookEndpointParams, type RollWebhookEndpointSecretParams, } from './webhookEndpoint';
|
|
11
|
+
export { PRICE_BILLING_SCHEMES, PRICE_TIERS_MODES, PRICE_TYPES, RECURRING_INTERVALS, RECURRING_USAGE_TYPES, PRICE_TAX_BEHAVIORS, TRANSFORM_QUANTITY_ROUNDS, COUPON_DURATIONS, CATALOG_LIMITS, type PriceBillingScheme, type PriceTiersMode, type PriceType, type RecurringInterval, type RecurringUsageType, type PriceTaxBehavior, type TransformQuantityRound, type CouponDuration, type ProductMarketingFeature, type Product, type DeletedProduct, type PriceTier, type PriceTransformQuantity, type PriceRecurring, type Price, type Coupon, type DeletedCoupon, type PromotionCodeRestrictions, type PromotionCode, type RecurringParams, type PriceTierParams, type PriceDataParams, type DefaultPriceDataParams, type CreateProductParams, type UpdateProductParams, type ProductListParams, type CreatePriceParams, type UpdatePriceParams, type PriceListParams, type CreateCouponParams, type UpdateCouponParams, type CouponListParams, type CreatePromotionCodeParams, type UpdatePromotionCodeParams, type PromotionCodeListParams, } from './catalog';
|
|
11
12
|
export type { Dispute, DisputeEvidence, DisputeStatus } from './dispute';
|
|
12
13
|
export type { CapabilityStatus, ConnectedAccount, ConnectedAccountFaircoin, ConnectedAccountFaircoinStatus, ConnectedAccountRail, Refund, RefundOrigin, RefundStatus, Settlement, Transfer, TransferReversal, TransferReversalStatus, TransferStatus, TransferWithReversal, } from './settlement';
|
|
13
14
|
export type { WebhookDelivery, WebhookDeliveryStatus, } from './webhookDelivery';
|
|
15
|
+
export { REQUEST_LOG_METHODS, REQUEST_LOG_RETENTION_DAYS, type RequestLog, type RequestLogListParams, type RequestLogMethod, type RequestLogStatusFilter, } from './requestLog';
|
|
16
|
+
export { SIMULATED_FAIRCOIN_OUTCOMES, type SimulatedFaircoinOutcome, type SimulateFaircoinPaymentParams, } from './testHelpers';
|
|
14
17
|
export { signWebhook, verifyWebhook } from './webhookSigner';
|
|
15
18
|
export { type MerchantEnvironment, type Merchant, MERCHANT_ENVIRONMENTS, } from './merchant';
|
|
16
19
|
export type { MerchantDisplay } from './merchantDisplay';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ListParams } from './list';
|
|
2
|
+
/**
|
|
3
|
+
* One merchant API request, as Peable recorded it (`req_…`) — the request log
|
|
4
|
+
* Orbit and `peable logs tail` read.
|
|
5
|
+
*
|
|
6
|
+
* Its `id` IS the `Request-Id` that request was answered with, so the id a
|
|
7
|
+
* merchant quotes to support and the log row are the same thing.
|
|
8
|
+
*
|
|
9
|
+
* Deliberately thin: method, path (no query string), status, duration and the
|
|
10
|
+
* `Idempotency-Key` it carried. No body, no headers, no query string, no
|
|
11
|
+
* caller address — a log a merchant can read is a log that must not hold what
|
|
12
|
+
* a request carried. Kept 30 days.
|
|
13
|
+
*/
|
|
14
|
+
export declare const REQUEST_LOG_METHODS: readonly ["GET", "POST", "DELETE", "PATCH", "PUT"];
|
|
15
|
+
export type RequestLogMethod = (typeof REQUEST_LOG_METHODS)[number];
|
|
16
|
+
export interface RequestLog {
|
|
17
|
+
/** The request's `Request-Id` (`req_…`). */
|
|
18
|
+
id: string;
|
|
19
|
+
object: 'request_log';
|
|
20
|
+
livemode: boolean;
|
|
21
|
+
method: RequestLogMethod;
|
|
22
|
+
/** The path that was requested, without its query string. */
|
|
23
|
+
path: string;
|
|
24
|
+
/** The HTTP status it was answered with. */
|
|
25
|
+
status: number;
|
|
26
|
+
/** How long the gateway took to answer, in milliseconds. */
|
|
27
|
+
duration_ms: number;
|
|
28
|
+
/** The `Idempotency-Key` the request carried, if it carried a valid one. */
|
|
29
|
+
idempotency_key: string | null;
|
|
30
|
+
/** When it was answered, Unix seconds. */
|
|
31
|
+
created: number;
|
|
32
|
+
}
|
|
33
|
+
/** `status`: one code (`404`) or a class (`2xx`, `4xx`, `5xx`). */
|
|
34
|
+
export type RequestLogStatusFilter = number | '2xx' | '3xx' | '4xx' | '5xx';
|
|
35
|
+
export interface RequestLogListParams extends ListParams {
|
|
36
|
+
status?: RequestLogStatusFilter;
|
|
37
|
+
method?: RequestLogMethod;
|
|
38
|
+
}
|
|
39
|
+
/** How long a request log is kept (and served). */
|
|
40
|
+
export declare const REQUEST_LOG_RETENTION_DAYS = 30;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test helpers (`/v1/test_helpers/*`) — test mode only.
|
|
3
|
+
*
|
|
4
|
+
* They drive a test-mode object through the SAME state machine a real payment
|
|
5
|
+
* moves through, so a merchant can exercise their integration end to end
|
|
6
|
+
* without a wallet or a card: every transition a helper makes is one the
|
|
7
|
+
* gateway would make, with the same events and webhooks.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* What `simulate_faircoin_payment` pretends the payer did.
|
|
11
|
+
*
|
|
12
|
+
* - `settled` — paid the full amount, which is then seen in the mempool and
|
|
13
|
+
* confirmed: `broadcast → confirming → settled`
|
|
14
|
+
* (`payment_intent.confirming`, then `payment_intent.settled`).
|
|
15
|
+
* - `underpaid` — sent less than the amount: `broadcast → failed`
|
|
16
|
+
* (`payment_intent.failed`).
|
|
17
|
+
*/
|
|
18
|
+
export declare const SIMULATED_FAIRCOIN_OUTCOMES: readonly ["settled", "underpaid"];
|
|
19
|
+
export type SimulatedFaircoinOutcome = (typeof SIMULATED_FAIRCOIN_OUTCOMES)[number];
|
|
20
|
+
export interface SimulateFaircoinPaymentParams {
|
|
21
|
+
/** Default `settled`. */
|
|
22
|
+
outcome?: SimulatedFaircoinOutcome;
|
|
23
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peable.to/shared-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Shared TypeScript types for the Peable Gateway — the wire contract shared by the backend, SDK, and frontend.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|