@peable.to/shared-types 0.4.0 → 0.5.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/dist/cjs/connect.js +2 -0
- package/dist/cjs/index.js +6 -1
- package/dist/cjs/paymentIntent.js +25 -1
- package/dist/cjs/tax.js +38 -0
- package/dist/esm/connect.js +1 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/paymentIntent.js +23 -0
- package/dist/esm/tax.js +35 -0
- package/dist/types/billing.d.ts +7 -0
- package/dist/types/checkoutSession.d.ts +7 -0
- package/dist/types/connect.d.ts +39 -0
- package/dist/types/event.d.ts +8 -0
- package/dist/types/index.d.ts +4 -2
- package/dist/types/merchant.d.ts +4 -1
- package/dist/types/paymentIntent.d.ts +47 -0
- package/dist/types/settlement.d.ts +49 -3
- package/dist/types/tax.d.ts +288 -0
- package/package.json +15 -4
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
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.CARD_ONLY_STATUSES = exports.CHAIN_ONLY_STATUSES = exports.PAYMENT_INTENT_RAILS = exports.PAYMENT_INTENT_STATUSES = exports.POST_SETTLEMENT_STATUSES = exports.reachesSettlementFromPayer = exports.canStillBePaid = exports.isValidStatusTransition = 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.canExpire = exports.EXPIRABLE_STATUSES = exports.CARD_ONLY_STATUSES = exports.CHAIN_ONLY_STATUSES = exports.PAYMENT_INTENT_RAILS = exports.PAYMENT_INTENT_STATUSES = exports.POST_SETTLEMENT_STATUSES = exports.reachesSettlementFromPayer = exports.canStillBePaid = exports.isValidStatusTransition = 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; } });
|
|
@@ -18,6 +18,8 @@ Object.defineProperty(exports, "PAYMENT_INTENT_STATUSES", { enumerable: true, ge
|
|
|
18
18
|
Object.defineProperty(exports, "PAYMENT_INTENT_RAILS", { enumerable: true, get: function () { return paymentIntent_1.PAYMENT_INTENT_RAILS; } });
|
|
19
19
|
Object.defineProperty(exports, "CHAIN_ONLY_STATUSES", { enumerable: true, get: function () { return paymentIntent_1.CHAIN_ONLY_STATUSES; } });
|
|
20
20
|
Object.defineProperty(exports, "CARD_ONLY_STATUSES", { enumerable: true, get: function () { return paymentIntent_1.CARD_ONLY_STATUSES; } });
|
|
21
|
+
Object.defineProperty(exports, "EXPIRABLE_STATUSES", { enumerable: true, get: function () { return paymentIntent_1.EXPIRABLE_STATUSES; } });
|
|
22
|
+
Object.defineProperty(exports, "canExpire", { enumerable: true, get: function () { return paymentIntent_1.canExpire; } });
|
|
21
23
|
var webhookSigner_1 = require("./webhookSigner");
|
|
22
24
|
Object.defineProperty(exports, "signWebhook", { enumerable: true, get: function () { return webhookSigner_1.signWebhook; } });
|
|
23
25
|
Object.defineProperty(exports, "verifyWebhook", { enumerable: true, get: function () { return webhookSigner_1.verifyWebhook; } });
|
|
@@ -32,3 +34,6 @@ var billing_authority_1 = require("./billing-authority");
|
|
|
32
34
|
Object.defineProperty(exports, "canonicalBillingAuthority", { enumerable: true, get: function () { return billing_authority_1.canonicalBillingAuthority; } });
|
|
33
35
|
Object.defineProperty(exports, "canonicalBillingTaxQuote", { enumerable: true, get: function () { return billing_authority_1.canonicalBillingTaxQuote; } });
|
|
34
36
|
Object.defineProperty(exports, "PEABLE_BILLING_AUTHORITY_KEYS", { enumerable: true, get: function () { return billing_authority_1.PEABLE_BILLING_AUTHORITY_KEYS; } });
|
|
37
|
+
var tax_1 = require("./tax");
|
|
38
|
+
Object.defineProperty(exports, "TAX_REGISTRATION_SCHEMES", { enumerable: true, get: function () { return tax_1.TAX_REGISTRATION_SCHEMES; } });
|
|
39
|
+
Object.defineProperty(exports, "TAX_LOCATION_EVIDENCE_TYPES", { enumerable: true, get: function () { return tax_1.TAX_LOCATION_EVIDENCE_TYPES; } });
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.POST_SETTLEMENT_STATUSES = exports.PAYMENT_INTENT_STATUSES = exports.CARD_ONLY_STATUSES = exports.CHAIN_ONLY_STATUSES = exports.PAYMENT_INTENT_RAILS = void 0;
|
|
3
|
+
exports.EXPIRABLE_STATUSES = exports.POST_SETTLEMENT_STATUSES = exports.PAYMENT_INTENT_STATUSES = exports.CARD_ONLY_STATUSES = exports.CHAIN_ONLY_STATUSES = exports.PAYMENT_INTENT_RAILS = void 0;
|
|
4
4
|
exports.isValidStatusTransition = isValidStatusTransition;
|
|
5
5
|
exports.canStillBePaid = canStillBePaid;
|
|
6
6
|
exports.reachesSettlementFromPayer = reachesSettlementFromPayer;
|
|
7
|
+
exports.canExpire = canExpire;
|
|
7
8
|
/** {@link PaymentIntentRail} as the tuple the database CHECK reads. */
|
|
8
9
|
exports.PAYMENT_INTENT_RAILS = ['faircoin', 'card'];
|
|
9
10
|
/**
|
|
@@ -205,3 +206,26 @@ function reachesSettlementFromPayer(status) {
|
|
|
205
206
|
}
|
|
206
207
|
return false;
|
|
207
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* The statuses an intent may still EXPIRE from (ADR 0012 D9).
|
|
211
|
+
*
|
|
212
|
+
* Exactly those whose transition list contains `expired`: the gateway is
|
|
213
|
+
* waiting on a PERSON who has not paid. Once a FairCoin payer has reported a
|
|
214
|
+
* broadcast (`broadcast`), or the chain is confirming it (`confirming`), the
|
|
215
|
+
* intent NEVER expires, whatever `expiresAt` says — coins are moving and the
|
|
216
|
+
* settlement watcher owns the row. A platform must therefore never cancel an
|
|
217
|
+
* order because `expiresAt` passed: it releases a reservation on
|
|
218
|
+
* `payment_intent.expired` (or `rejected`), and on nothing else.
|
|
219
|
+
*
|
|
220
|
+
* Stated rather than derived, for `PAYABLE_STATUSES`' reason; the gateway's
|
|
221
|
+
* test suite pins it against the transition table.
|
|
222
|
+
*/
|
|
223
|
+
exports.EXPIRABLE_STATUSES = [
|
|
224
|
+
'created',
|
|
225
|
+
'awaiting_approval',
|
|
226
|
+
'requires_action',
|
|
227
|
+
];
|
|
228
|
+
/** Whether an intent in this status can still expire. See {@link EXPIRABLE_STATUSES}. */
|
|
229
|
+
function canExpire(status) {
|
|
230
|
+
return exports.EXPIRABLE_STATUSES.includes(status);
|
|
231
|
+
}
|
package/dist/cjs/tax.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Peable Tax — the wire contract.
|
|
4
|
+
*
|
|
5
|
+
* Modelled on Stripe Tax and applied to every settlement rail (card, FairCoin,
|
|
6
|
+
* any further fiat provider). A merchant declares WHERE it is registered;
|
|
7
|
+
* Peable decides per sale whether a registration covers the customer's
|
|
8
|
+
* evidenced location, asks a tax provider for the amount only when one does,
|
|
9
|
+
* and freezes the answer. Registering with a government is the seller's job,
|
|
10
|
+
* never this code's.
|
|
11
|
+
*
|
|
12
|
+
* Amounts are integers in the currency's minor unit, like the billing quote.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.TAX_LOCATION_EVIDENCE_TYPES = exports.TAX_REGISTRATION_SCHEMES = void 0;
|
|
16
|
+
/** How a registration lets the seller collect. `standard`/`simplified` cover
|
|
17
|
+
* one country; the EU One-Stop-Shop schemes cover every EU member state from
|
|
18
|
+
* one identification state; the US is per state; Canadian PST/QST is per
|
|
19
|
+
* province. */
|
|
20
|
+
exports.TAX_REGISTRATION_SCHEMES = [
|
|
21
|
+
'standard',
|
|
22
|
+
'simplified',
|
|
23
|
+
'eu_oss_union',
|
|
24
|
+
'eu_oss_non_union',
|
|
25
|
+
'us_state_sales_tax',
|
|
26
|
+
'ca_provincial',
|
|
27
|
+
];
|
|
28
|
+
/** Location evidence a jurisdiction accepts. There is deliberately no
|
|
29
|
+
* language, currency, locale or timezone: none of them is evidence of where a
|
|
30
|
+
* customer lives, and Peable cannot be told otherwise. */
|
|
31
|
+
exports.TAX_LOCATION_EVIDENCE_TYPES = [
|
|
32
|
+
'billing_address',
|
|
33
|
+
'ip_address',
|
|
34
|
+
'payment_method_country',
|
|
35
|
+
'bank_country',
|
|
36
|
+
'sim_country',
|
|
37
|
+
'landline_country',
|
|
38
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// @peable.to/shared-types — public API for the Peable Gateway contract.
|
|
2
2
|
export { UNITS_PER_COIN, isBaseUnitString, CURRENCY_CODES, CURRENCY_DECIMALS, decimalsFor, isCurrencyCode, } from './money.js';
|
|
3
|
-
export { isValidStatusTransition, canStillBePaid, reachesSettlementFromPayer, POST_SETTLEMENT_STATUSES, PAYMENT_INTENT_STATUSES, PAYMENT_INTENT_RAILS, CHAIN_ONLY_STATUSES, CARD_ONLY_STATUSES, } from './paymentIntent.js';
|
|
3
|
+
export { isValidStatusTransition, canStillBePaid, reachesSettlementFromPayer, POST_SETTLEMENT_STATUSES, PAYMENT_INTENT_STATUSES, PAYMENT_INTENT_RAILS, CHAIN_ONLY_STATUSES, CARD_ONLY_STATUSES, EXPIRABLE_STATUSES, canExpire, } from './paymentIntent.js';
|
|
4
4
|
export { signWebhook, verifyWebhook } from './webhookSigner.js';
|
|
5
5
|
export { MERCHANT_ENVIRONMENTS, } from './merchant.js';
|
|
6
6
|
export { SOCIAL_SOURCE_APP_MAX_LENGTH, SOCIAL_SOURCE_REF_MAX_LENGTH, } from './social.js';
|
|
7
7
|
export { BILLING_SUBSCRIPTION_STATUSES, } from './billing.js';
|
|
8
8
|
export { canonicalBillingAuthority, canonicalBillingTaxQuote, PEABLE_BILLING_AUTHORITY_KEYS, } from './billing-authority.js';
|
|
9
|
+
export { TAX_REGISTRATION_SCHEMES, TAX_LOCATION_EVIDENCE_TYPES, } from './tax.js';
|
|
@@ -199,3 +199,26 @@ export function reachesSettlementFromPayer(status) {
|
|
|
199
199
|
}
|
|
200
200
|
return false;
|
|
201
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* The statuses an intent may still EXPIRE from (ADR 0012 D9).
|
|
204
|
+
*
|
|
205
|
+
* Exactly those whose transition list contains `expired`: the gateway is
|
|
206
|
+
* waiting on a PERSON who has not paid. Once a FairCoin payer has reported a
|
|
207
|
+
* broadcast (`broadcast`), or the chain is confirming it (`confirming`), the
|
|
208
|
+
* intent NEVER expires, whatever `expiresAt` says — coins are moving and the
|
|
209
|
+
* settlement watcher owns the row. A platform must therefore never cancel an
|
|
210
|
+
* order because `expiresAt` passed: it releases a reservation on
|
|
211
|
+
* `payment_intent.expired` (or `rejected`), and on nothing else.
|
|
212
|
+
*
|
|
213
|
+
* Stated rather than derived, for `PAYABLE_STATUSES`' reason; the gateway's
|
|
214
|
+
* test suite pins it against the transition table.
|
|
215
|
+
*/
|
|
216
|
+
export const EXPIRABLE_STATUSES = [
|
|
217
|
+
'created',
|
|
218
|
+
'awaiting_approval',
|
|
219
|
+
'requires_action',
|
|
220
|
+
];
|
|
221
|
+
/** Whether an intent in this status can still expire. See {@link EXPIRABLE_STATUSES}. */
|
|
222
|
+
export function canExpire(status) {
|
|
223
|
+
return EXPIRABLE_STATUSES.includes(status);
|
|
224
|
+
}
|
package/dist/esm/tax.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Peable Tax — the wire contract.
|
|
3
|
+
*
|
|
4
|
+
* Modelled on Stripe Tax and applied to every settlement rail (card, FairCoin,
|
|
5
|
+
* any further fiat provider). A merchant declares WHERE it is registered;
|
|
6
|
+
* Peable decides per sale whether a registration covers the customer's
|
|
7
|
+
* evidenced location, asks a tax provider for the amount only when one does,
|
|
8
|
+
* and freezes the answer. Registering with a government is the seller's job,
|
|
9
|
+
* never this code's.
|
|
10
|
+
*
|
|
11
|
+
* Amounts are integers in the currency's minor unit, like the billing quote.
|
|
12
|
+
*/
|
|
13
|
+
/** How a registration lets the seller collect. `standard`/`simplified` cover
|
|
14
|
+
* one country; the EU One-Stop-Shop schemes cover every EU member state from
|
|
15
|
+
* one identification state; the US is per state; Canadian PST/QST is per
|
|
16
|
+
* province. */
|
|
17
|
+
export const TAX_REGISTRATION_SCHEMES = [
|
|
18
|
+
'standard',
|
|
19
|
+
'simplified',
|
|
20
|
+
'eu_oss_union',
|
|
21
|
+
'eu_oss_non_union',
|
|
22
|
+
'us_state_sales_tax',
|
|
23
|
+
'ca_provincial',
|
|
24
|
+
];
|
|
25
|
+
/** Location evidence a jurisdiction accepts. There is deliberately no
|
|
26
|
+
* language, currency, locale or timezone: none of them is evidence of where a
|
|
27
|
+
* customer lives, and Peable cannot be told otherwise. */
|
|
28
|
+
export const TAX_LOCATION_EVIDENCE_TYPES = [
|
|
29
|
+
'billing_address',
|
|
30
|
+
'ip_address',
|
|
31
|
+
'payment_method_country',
|
|
32
|
+
'bank_country',
|
|
33
|
+
'sim_country',
|
|
34
|
+
'landline_country',
|
|
35
|
+
];
|
package/dist/types/billing.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { BillingInvoiceTaxLine } from './tax';
|
|
1
2
|
/** Recurring billing transport. Store/plan references belong to the authenticated app;
|
|
2
3
|
* they do not identify an Oxy payer or convey entitlements. */
|
|
3
4
|
export declare const BILLING_SUBSCRIPTION_STATUSES: readonly ["incomplete", "incomplete_expired", "trialing", "active", "past_due", "canceled", "unpaid", "paused"];
|
|
@@ -174,6 +175,9 @@ export interface BillingFinalInvoice {
|
|
|
174
175
|
expiresAt: string;
|
|
175
176
|
roundingEvidenceId: string;
|
|
176
177
|
};
|
|
178
|
+
/** Present only when requested (`include: ['tax_lines']`): the frozen
|
|
179
|
+
* Peable Tax lines behind `taxMinorUnits`, covered by the same signature. */
|
|
180
|
+
taxLines?: BillingInvoiceTaxLine[];
|
|
177
181
|
}
|
|
178
182
|
export interface BillingFinalInvoiceAuthority {
|
|
179
183
|
schemaVersion: 1;
|
|
@@ -227,6 +231,9 @@ export interface CreateBillingTaxQuoteParams {
|
|
|
227
231
|
rail?: BillingRail;
|
|
228
232
|
storeId: string;
|
|
229
233
|
planId: string;
|
|
234
|
+
/** Selects one offer when a plan is sold at several prices. */
|
|
235
|
+
providerPriceId?: string;
|
|
236
|
+
/** A `tax.location_evidence` id (`taxloc_…`) recorded for this `storeId`. */
|
|
230
237
|
customerLocationEvidenceId: string;
|
|
231
238
|
}
|
|
232
239
|
export interface BillingTaxQuote {
|
|
@@ -15,6 +15,11 @@ export interface CheckoutSession {
|
|
|
15
15
|
rail: PaymentIntentRail;
|
|
16
16
|
/** FairCoin rail only; `null` on a card session. */
|
|
17
17
|
network: NetworkType | null;
|
|
18
|
+
/**
|
|
19
|
+
* The seller the wrapped payment is made on behalf of (`ca_…`), or `null`
|
|
20
|
+
* (ADR 0012 D5). Optional in the type for older fixtures; always sent.
|
|
21
|
+
*/
|
|
22
|
+
connectedAccountId?: string | null;
|
|
18
23
|
metadata: Record<string, string>;
|
|
19
24
|
successUrl?: string;
|
|
20
25
|
cancelUrl?: string;
|
|
@@ -50,4 +55,6 @@ export interface CreateCheckoutSessionParams {
|
|
|
50
55
|
metadata?: Record<string, string>;
|
|
51
56
|
successUrl?: string;
|
|
52
57
|
cancelUrl?: string;
|
|
58
|
+
/** Pay this seller (`ca_…`) rather than the merchant — see `CreatePaymentIntentParams.connectedAccount`. */
|
|
59
|
+
connectedAccount?: string;
|
|
53
60
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { MerchantDisplay } from './merchantDisplay';
|
|
2
|
+
import type { NetworkType } from './network';
|
|
3
|
+
/** `GET /v1/connect/onboarding/:token` — what the seller is being asked to do. */
|
|
4
|
+
export interface ConnectOnboarding {
|
|
5
|
+
object: 'connect_onboarding';
|
|
6
|
+
/** The `ca_…` being onboarded. */
|
|
7
|
+
accountId: string;
|
|
8
|
+
/** Who is asking — the PLATFORM's public display, as a payer would see it. */
|
|
9
|
+
platform: MerchantDisplay;
|
|
10
|
+
/** The chain the seller will be paid on. Their key must be for this network. */
|
|
11
|
+
network: NetworkType;
|
|
12
|
+
/** When this link stops working. */
|
|
13
|
+
expiresAt: string;
|
|
14
|
+
/** Where to send the seller once the key is registered. */
|
|
15
|
+
returnUrl: string;
|
|
16
|
+
}
|
|
17
|
+
/** `POST /v1/connect/onboarding/:token/faircoin` — the seller's watch-only ACCOUNT xpub. */
|
|
18
|
+
export interface RegisterFaircoinKeyParams {
|
|
19
|
+
/** A watch-only extended PUBLIC key. A private key is refused and never stored. */
|
|
20
|
+
xpub: string;
|
|
21
|
+
}
|
|
22
|
+
/** The answer to a successful registration. */
|
|
23
|
+
export interface ConnectOnboardingComplete {
|
|
24
|
+
object: 'connect_onboarding';
|
|
25
|
+
accountId: string;
|
|
26
|
+
status: 'active';
|
|
27
|
+
returnUrl: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A FairCoin onboarding link, as the platform receives it from
|
|
31
|
+
* `POST /v1/connected_accounts/:id/account_links` with `rail: 'faircoin'`.
|
|
32
|
+
* Same shape as the card rail's link. Do not store it: it is single-use and
|
|
33
|
+
* expires — mint one when the seller is about to open it.
|
|
34
|
+
*/
|
|
35
|
+
export interface AccountLink {
|
|
36
|
+
object: 'account_link';
|
|
37
|
+
url: string;
|
|
38
|
+
expiresAt: string;
|
|
39
|
+
}
|
package/dist/types/event.d.ts
CHANGED
|
@@ -117,6 +117,14 @@ export type WebhookEvent<K extends WebhookEventType = WebhookEventType> = {
|
|
|
117
117
|
object: 'event';
|
|
118
118
|
type: T;
|
|
119
119
|
created: string;
|
|
120
|
+
/**
|
|
121
|
+
* The connected account (`ca_…`) this event is about — Stripe's
|
|
122
|
+
* `event.account` (ADR 0012 D7). Present on every event for an on-behalf
|
|
123
|
+
* payment and on `connected_account.updated`; absent on events about the
|
|
124
|
+
* merchant's own payments. Lets a platform route an event to a seller
|
|
125
|
+
* without opening `data.object`.
|
|
126
|
+
*/
|
|
127
|
+
account?: string;
|
|
120
128
|
data: {
|
|
121
129
|
object: WebhookEventPayload[T];
|
|
122
130
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
export { UNITS_PER_COIN, isBaseUnitString, type CurrencyCode, CURRENCY_CODES, CURRENCY_DECIMALS, decimalsFor, isCurrencyCode, } from './money';
|
|
2
2
|
export type { NetworkType } from './network';
|
|
3
|
-
export { type PaymentIntentStatus, type PaymentIntentRail, type PaymentIntent, type CreatePaymentIntentParams, isValidStatusTransition, canStillBePaid, reachesSettlementFromPayer, POST_SETTLEMENT_STATUSES, PAYMENT_INTENT_STATUSES, PAYMENT_INTENT_RAILS, CHAIN_ONLY_STATUSES, CARD_ONLY_STATUSES, } from './paymentIntent';
|
|
3
|
+
export { type PaymentIntentStatus, type PaymentIntentRail, type PaymentIntent, type CreatePaymentIntentParams, isValidStatusTransition, canStillBePaid, reachesSettlementFromPayer, POST_SETTLEMENT_STATUSES, PAYMENT_INTENT_STATUSES, PAYMENT_INTENT_RAILS, CHAIN_ONLY_STATUSES, CARD_ONLY_STATUSES, EXPIRABLE_STATUSES, canExpire, } from './paymentIntent';
|
|
4
4
|
export type { WebhookEventType, WebhookEvent, WebhookEventPayload, BillingObservation, } from './event';
|
|
5
5
|
export type { Dispute, DisputeEvidence, DisputeStatus } from './dispute';
|
|
6
|
-
export type { CapabilityStatus, ConnectedAccount, Refund, RefundOrigin, RefundStatus, Settlement, Transfer, TransferReversal, TransferReversalStatus, TransferStatus, TransferWithReversal, } from './settlement';
|
|
6
|
+
export type { CapabilityStatus, ConnectedAccount, ConnectedAccountFaircoin, ConnectedAccountFaircoinStatus, ConnectedAccountRail, Refund, RefundOrigin, RefundStatus, Settlement, Transfer, TransferReversal, TransferReversalStatus, TransferStatus, TransferWithReversal, } from './settlement';
|
|
7
7
|
export type { WebhookDelivery, WebhookDeliveryStatus, } from './webhookDelivery';
|
|
8
8
|
export { signWebhook, verifyWebhook } from './webhookSigner';
|
|
9
9
|
export { type MerchantEnvironment, type Merchant, MERCHANT_ENVIRONMENTS, } from './merchant';
|
|
10
10
|
export type { MerchantDisplay } from './merchantDisplay';
|
|
11
|
+
export type { AccountLink, ConnectOnboarding, ConnectOnboardingComplete, RegisterFaircoinKeyParams, } from './connect';
|
|
11
12
|
export type { PaymentLink, PublicPaymentLink, CreatePaymentLinkParams, } from './paymentLink';
|
|
12
13
|
export type { CheckoutSession, CheckoutSessionPublic, CreateCheckoutSessionParams, } from './checkoutSession';
|
|
13
14
|
export { SOCIAL_SOURCE_APP_MAX_LENGTH, SOCIAL_SOURCE_REF_MAX_LENGTH, type SocialPaymentSource, type SocialNextAddressRequest, type SocialNextAddressResponse, type SocialReceiveCursorResponse, type SocialPaymentDirection, type SocialPayment, type SocialPaymentsResponse, type EnrichmentKind, type EnrichmentResult, type EnrichRequest, type EnrichResponse, } from './social';
|
|
14
15
|
export { BILLING_SUBSCRIPTION_STATUSES, type BillingSubscriptionStatus, type CreateBillingTaxQuoteParams, type BillingTaxQuote, type BillingInvoiceAuthoritySource, type BillingFinalInvoice, type BillingFinalInvoiceAuthority, type BillingFaircoinRenewalChoice, type BillingFaircoinRenewalConsent, type BillingFaircoinRenewalRevocation, type BillingCheckoutSession, type BillingCheckoutObservation, type RetrieveBillingCheckoutOperationParams, type BillingCheckoutOperationSource, type BillingCheckoutOperationRecovery, type BillingPaidInvoice, type BillingInvoiceState, type BillingCustomer, type BillingRail, type BillingRailSettlement, type BillingRailOffer, type BillingRailOption, type BillingRailList, type EnsureBillingCustomerParams, type CreateBillingCheckoutParams, type CreateBillingPortalParams, type BillingHostedSession, type BillingSubscription, } from './billing';
|
|
15
16
|
export { canonicalBillingAuthority, canonicalBillingTaxQuote, PEABLE_BILLING_AUTHORITY_KEYS, } from './billing-authority';
|
|
16
17
|
export type { BillingFaircoinFxQuote } from './billing';
|
|
18
|
+
export { TAX_REGISTRATION_SCHEMES, TAX_LOCATION_EVIDENCE_TYPES, type TaxRegistrationScheme, type TaxLocationEvidenceType, type TaxBehavior, type TaxAddress, type TaxCode, type TaxCalculationAccount, type TaxSettings, type UpdateTaxSettingsParams, type TaxRegistration, type CreateTaxRegistrationParams, type TaxProductCode, type TaxLocationEvidenceItem, type CreateTaxLocationEvidenceParams, type TaxLocationEvidence, type TaxLineItemParams, type CreateTaxCalculationParams, type TaxBreakdownEntry, type TaxCalculationLineItem, type TaxCalculation, type TaxTransaction, type TaxTransactionList, type TaxTransactionReversal, type CreateTaxReversalParams, type ListTaxTransactionsParams, type TaxReportRow, type TaxReport, type BillingInvoiceTaxLine, } from './tax';
|
package/dist/types/merchant.d.ts
CHANGED
|
@@ -26,7 +26,10 @@ export interface Merchant {
|
|
|
26
26
|
* the raw values the merchant owns.
|
|
27
27
|
*/
|
|
28
28
|
displayName?: string;
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Bare Oxy file id, not a URL. `MerchantDisplay.avatarUrl` resolves it.
|
|
31
|
+
* Absent again once Oxy reports the file deleted or taken down.
|
|
32
|
+
*/
|
|
30
33
|
avatarFileId?: string;
|
|
31
34
|
description?: string;
|
|
32
35
|
createdAt: string;
|
|
@@ -52,6 +52,23 @@ export declare const POST_SETTLEMENT_STATUSES: readonly PaymentIntentStatus[];
|
|
|
52
52
|
* the thing that checks it rather than as the thing that answers it.
|
|
53
53
|
*/
|
|
54
54
|
export declare function reachesSettlementFromPayer(status: PaymentIntentStatus): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* The statuses an intent may still EXPIRE from (ADR 0012 D9).
|
|
57
|
+
*
|
|
58
|
+
* Exactly those whose transition list contains `expired`: the gateway is
|
|
59
|
+
* waiting on a PERSON who has not paid. Once a FairCoin payer has reported a
|
|
60
|
+
* broadcast (`broadcast`), or the chain is confirming it (`confirming`), the
|
|
61
|
+
* intent NEVER expires, whatever `expiresAt` says — coins are moving and the
|
|
62
|
+
* settlement watcher owns the row. A platform must therefore never cancel an
|
|
63
|
+
* order because `expiresAt` passed: it releases a reservation on
|
|
64
|
+
* `payment_intent.expired` (or `rejected`), and on nothing else.
|
|
65
|
+
*
|
|
66
|
+
* Stated rather than derived, for `PAYABLE_STATUSES`' reason; the gateway's
|
|
67
|
+
* test suite pins it against the transition table.
|
|
68
|
+
*/
|
|
69
|
+
export declare const EXPIRABLE_STATUSES: readonly PaymentIntentStatus[];
|
|
70
|
+
/** Whether an intent in this status can still expire. See {@link EXPIRABLE_STATUSES}. */
|
|
71
|
+
export declare function canExpire(status: PaymentIntentStatus): boolean;
|
|
55
72
|
export interface PaymentIntent {
|
|
56
73
|
id: string;
|
|
57
74
|
object: 'payment_intent';
|
|
@@ -73,12 +90,34 @@ export interface PaymentIntent {
|
|
|
73
90
|
*/
|
|
74
91
|
address: string | null;
|
|
75
92
|
merchantId: string;
|
|
93
|
+
/**
|
|
94
|
+
* The seller this payment is made ON BEHALF OF (`ca_…`), or `null` for a
|
|
95
|
+
* payment to the merchant itself (ADR 0012 D5). On-behalf payments are
|
|
96
|
+
* FairCoin only, and `address` derives from that seller's own key.
|
|
97
|
+
*
|
|
98
|
+
* Optional in the type only so fixtures written against earlier versions
|
|
99
|
+
* still compile; a gateway at this version always sends it.
|
|
100
|
+
*/
|
|
101
|
+
connectedAccountId?: string | null;
|
|
76
102
|
txid: string | null;
|
|
77
103
|
/** On-chain confirmations. Structurally `0` for the whole life of a card payment. */
|
|
78
104
|
confirmations: number;
|
|
79
105
|
clientSecret: string;
|
|
80
106
|
metadata: Record<string, string>;
|
|
107
|
+
/**
|
|
108
|
+
* When an UNPAID intent expires. Meaningful only while {@link canExpire}
|
|
109
|
+
* is true for `status` — see `canExpire` below.
|
|
110
|
+
*/
|
|
81
111
|
expiresAt: string;
|
|
112
|
+
/**
|
|
113
|
+
* Whether this intent can still expire (ADR 0012 D9). `false` once the payer
|
|
114
|
+
* has reported a broadcast: a FairCoin payment that is `broadcast` or
|
|
115
|
+
* `confirming` NEVER expires, so a platform must not cancel the order for it.
|
|
116
|
+
*
|
|
117
|
+
* Optional in the type only for fixtures written against earlier versions;
|
|
118
|
+
* a gateway at this version always sends it.
|
|
119
|
+
*/
|
|
120
|
+
canExpire?: boolean;
|
|
82
121
|
createdAt: string;
|
|
83
122
|
updatedAt: string;
|
|
84
123
|
}
|
|
@@ -96,4 +135,12 @@ export interface CreatePaymentIntentParams {
|
|
|
96
135
|
currency?: CurrencyCode;
|
|
97
136
|
metadata?: Record<string, string>;
|
|
98
137
|
expiresInSeconds?: number;
|
|
138
|
+
/**
|
|
139
|
+
* Create the payment ON BEHALF OF this connected account (`ca_…`) — the
|
|
140
|
+
* address derives from the seller's own key and the coins go straight to
|
|
141
|
+
* their wallet (ADR 0012 D5). FairCoin only: combined with `rail: 'card'` it
|
|
142
|
+
* is refused. The account's FairCoin half must be `active` and `network`
|
|
143
|
+
* must be the account's network.
|
|
144
|
+
*/
|
|
145
|
+
connectedAccount?: string;
|
|
99
146
|
}
|
|
@@ -1,20 +1,66 @@
|
|
|
1
1
|
import type { CurrencyCode } from './money';
|
|
2
|
+
import type { NetworkType } from './network';
|
|
2
3
|
/** How a provider reports one capability on a seller's account. */
|
|
3
4
|
export type CapabilityStatus = 'active' | 'pending' | 'inactive';
|
|
4
5
|
/** Where one settlement stands. */
|
|
5
6
|
export type TransferStatus = 'pending' | 'paid' | 'partially_reversed' | 'reversed' | 'failed';
|
|
6
7
|
/** Where one reversal of a settlement stands. */
|
|
7
8
|
export type TransferReversalStatus = 'pending' | 'succeeded' | 'failed';
|
|
9
|
+
/**
|
|
10
|
+
* Which rails a seller's account was opened for (ADR 0012 D1).
|
|
11
|
+
*
|
|
12
|
+
* One seller is ONE `ca_…`: `card` is the provider account a marketplace
|
|
13
|
+
* settles to by transfer, `faircoin` is the seller's own watch-only key that
|
|
14
|
+
* on-behalf FairCoin payments derive their addresses from.
|
|
15
|
+
*/
|
|
16
|
+
export type ConnectedAccountRail = 'card' | 'faircoin';
|
|
17
|
+
/**
|
|
18
|
+
* Where a seller's FairCoin half stands.
|
|
19
|
+
*
|
|
20
|
+
* `pending` — the platform opened it and the seller has not registered a key
|
|
21
|
+
* yet; an on-behalf payment is refused (`account_not_ready`). `active` — the
|
|
22
|
+
* seller registered their key; payments derive addresses from it.
|
|
23
|
+
*/
|
|
24
|
+
export type ConnectedAccountFaircoinStatus = 'pending' | 'active';
|
|
25
|
+
/**
|
|
26
|
+
* The FairCoin half of a seller's account.
|
|
27
|
+
*
|
|
28
|
+
* The seller's xpub is deliberately ABSENT (ADR 0012 D6): an account xpub
|
|
29
|
+
* reveals every address of that account, so a platform holding it would learn
|
|
30
|
+
* the seller's whole history and balance. Nothing a platform does needs it —
|
|
31
|
+
* each payment carries its own address.
|
|
32
|
+
*/
|
|
33
|
+
export interface ConnectedAccountFaircoin {
|
|
34
|
+
/** The chain the seller is paid on. Fixed when the platform opened the half. */
|
|
35
|
+
network: NetworkType;
|
|
36
|
+
status: ConnectedAccountFaircoinStatus;
|
|
37
|
+
/** The Oxy user who may register the key — and, once `active`, who did. */
|
|
38
|
+
oxyUserId: string;
|
|
39
|
+
/** When the seller registered their key. `null` while `pending`. */
|
|
40
|
+
registeredAt: string | null;
|
|
41
|
+
}
|
|
8
42
|
export interface ConnectedAccount {
|
|
9
43
|
id: string;
|
|
10
44
|
object: 'connected_account';
|
|
11
45
|
/** The merchant's OWN id for this seller — how they address it. */
|
|
12
46
|
externalRef: string;
|
|
13
|
-
/**
|
|
14
|
-
|
|
47
|
+
/** Which halves this account has. Never empty. */
|
|
48
|
+
rails: readonly ConnectedAccountRail[];
|
|
49
|
+
/**
|
|
50
|
+
* The FairCoin half, or `null` when the platform never opened one.
|
|
51
|
+
* Readiness for FairCoin is `faircoin?.status === 'active'`; `payable` below
|
|
52
|
+
* is about the CARD half's settlements and says nothing about FairCoin.
|
|
53
|
+
*/
|
|
54
|
+
faircoin: ConnectedAccountFaircoin | null;
|
|
55
|
+
/**
|
|
56
|
+
* ISO 3166-1 alpha-2, upper-case. `null` on a FairCoin-only seller, which has
|
|
57
|
+
* no card half and was never asked for one (ADR 0012 D1).
|
|
58
|
+
*/
|
|
59
|
+
country: string | null;
|
|
15
60
|
defaultCurrency: string | null;
|
|
16
61
|
/**
|
|
17
|
-
* Whether this seller can receive a settlement right now.
|
|
62
|
+
* Whether this seller can receive a CARD settlement (a transfer) right now.
|
|
63
|
+
* Always `false` on a FairCoin-only seller.
|
|
18
64
|
*
|
|
19
65
|
* A CONVENIENCE, not the authority: every field it is derived from is here
|
|
20
66
|
* too, and a marketplace with its own readiness policy reads those instead.
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Peable Tax — the wire contract.
|
|
3
|
+
*
|
|
4
|
+
* Modelled on Stripe Tax and applied to every settlement rail (card, FairCoin,
|
|
5
|
+
* any further fiat provider). A merchant declares WHERE it is registered;
|
|
6
|
+
* Peable decides per sale whether a registration covers the customer's
|
|
7
|
+
* evidenced location, asks a tax provider for the amount only when one does,
|
|
8
|
+
* and freezes the answer. Registering with a government is the seller's job,
|
|
9
|
+
* never this code's.
|
|
10
|
+
*
|
|
11
|
+
* Amounts are integers in the currency's minor unit, like the billing quote.
|
|
12
|
+
*/
|
|
13
|
+
/** How a registration lets the seller collect. `standard`/`simplified` cover
|
|
14
|
+
* one country; the EU One-Stop-Shop schemes cover every EU member state from
|
|
15
|
+
* one identification state; the US is per state; Canadian PST/QST is per
|
|
16
|
+
* province. */
|
|
17
|
+
export declare const TAX_REGISTRATION_SCHEMES: readonly ["standard", "simplified", "eu_oss_union", "eu_oss_non_union", "us_state_sales_tax", "ca_provincial"];
|
|
18
|
+
export type TaxRegistrationScheme = (typeof TAX_REGISTRATION_SCHEMES)[number];
|
|
19
|
+
/** Location evidence a jurisdiction accepts. There is deliberately no
|
|
20
|
+
* language, currency, locale or timezone: none of them is evidence of where a
|
|
21
|
+
* customer lives, and Peable cannot be told otherwise. */
|
|
22
|
+
export declare const TAX_LOCATION_EVIDENCE_TYPES: readonly ["billing_address", "ip_address", "payment_method_country", "bank_country", "sim_country", "landline_country"];
|
|
23
|
+
export type TaxLocationEvidenceType = (typeof TAX_LOCATION_EVIDENCE_TYPES)[number];
|
|
24
|
+
export type TaxBehavior = 'inclusive' | 'exclusive';
|
|
25
|
+
export interface TaxAddress {
|
|
26
|
+
/** ISO 3166-1 alpha-2. */
|
|
27
|
+
country: string;
|
|
28
|
+
/** ISO 3166-2 subdivision without the country prefix (`CA`, `QC`). */
|
|
29
|
+
state?: string | null;
|
|
30
|
+
postalCode?: string | null;
|
|
31
|
+
city?: string | null;
|
|
32
|
+
line1?: string | null;
|
|
33
|
+
line2?: string | null;
|
|
34
|
+
}
|
|
35
|
+
export interface TaxCode {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
description: string;
|
|
39
|
+
}
|
|
40
|
+
/** Which provider account calculates for this merchant. `platform`: Peable's
|
|
41
|
+
* own provider account, available only to official Oxy applications, whose
|
|
42
|
+
* seller is the platform's legal entity. `none`: no provider; sales in a
|
|
43
|
+
* registered jurisdiction cannot be calculated and fail closed. */
|
|
44
|
+
export type TaxCalculationAccount = 'platform' | 'none';
|
|
45
|
+
export interface TaxSettings {
|
|
46
|
+
object: 'tax.settings';
|
|
47
|
+
merchantId: string;
|
|
48
|
+
/** `active` once the owner approved; any edit returns it to `draft`. */
|
|
49
|
+
status: 'draft' | 'active';
|
|
50
|
+
legalName: string | null;
|
|
51
|
+
headOffice: TaxAddress | null;
|
|
52
|
+
defaultTaxCode: string;
|
|
53
|
+
defaultTaxBehavior: TaxBehavior;
|
|
54
|
+
calculationAccount: TaxCalculationAccount;
|
|
55
|
+
/** The provider that calculates registered sales, when one is reachable. */
|
|
56
|
+
provider: string | null;
|
|
57
|
+
approvedAt: string | null;
|
|
58
|
+
approvedBy: string | null;
|
|
59
|
+
updatedAt: string | null;
|
|
60
|
+
}
|
|
61
|
+
export interface UpdateTaxSettingsParams {
|
|
62
|
+
legalName?: string | null;
|
|
63
|
+
headOffice?: TaxAddress | null;
|
|
64
|
+
defaultTaxCode?: string;
|
|
65
|
+
defaultTaxBehavior?: TaxBehavior;
|
|
66
|
+
}
|
|
67
|
+
export interface TaxRegistration {
|
|
68
|
+
object: 'tax.registration';
|
|
69
|
+
id: string;
|
|
70
|
+
country: string;
|
|
71
|
+
state: string | null;
|
|
72
|
+
scheme: TaxRegistrationScheme;
|
|
73
|
+
/** The government-issued number (VAT id, state permit), when there is one. */
|
|
74
|
+
registrationNumber: string | null;
|
|
75
|
+
activeFrom: string;
|
|
76
|
+
expiresAt: string | null;
|
|
77
|
+
/** `pending_approval` until the owner approves; `scheduled` before activeFrom. */
|
|
78
|
+
status: 'pending_approval' | 'scheduled' | 'active' | 'expired';
|
|
79
|
+
approvedAt: string | null;
|
|
80
|
+
/** The mirrored registration at the calculating provider, once synced. */
|
|
81
|
+
providerRegistrationRef: string | null;
|
|
82
|
+
createdAt: string;
|
|
83
|
+
}
|
|
84
|
+
export interface CreateTaxRegistrationParams {
|
|
85
|
+
country: string;
|
|
86
|
+
state?: string | null;
|
|
87
|
+
scheme: TaxRegistrationScheme;
|
|
88
|
+
registrationNumber?: string | null;
|
|
89
|
+
/** ISO timestamp; omitted means immediately on approval. */
|
|
90
|
+
activeFrom?: string;
|
|
91
|
+
expiresAt?: string | null;
|
|
92
|
+
}
|
|
93
|
+
export interface TaxProductCode {
|
|
94
|
+
object: 'tax.product';
|
|
95
|
+
/** The merchant's product or plan reference (a billing `planId`). */
|
|
96
|
+
productRef: string;
|
|
97
|
+
taxCode: string;
|
|
98
|
+
updatedAt: string;
|
|
99
|
+
}
|
|
100
|
+
export type TaxLocationEvidenceItem = {
|
|
101
|
+
type: 'billing_address';
|
|
102
|
+
address: TaxAddress;
|
|
103
|
+
} | {
|
|
104
|
+
type: 'ip_address';
|
|
105
|
+
ipAddress: string;
|
|
106
|
+
country: string;
|
|
107
|
+
state?: string | null;
|
|
108
|
+
} | {
|
|
109
|
+
type: 'payment_method_country' | 'bank_country' | 'sim_country' | 'landline_country';
|
|
110
|
+
country: string;
|
|
111
|
+
};
|
|
112
|
+
export interface CreateTaxLocationEvidenceParams {
|
|
113
|
+
/** The customer this evidence is about; for billing, the `storeId`. */
|
|
114
|
+
customerRef: string;
|
|
115
|
+
evidence: TaxLocationEvidenceItem[];
|
|
116
|
+
}
|
|
117
|
+
export interface TaxLocationEvidence {
|
|
118
|
+
object: 'tax.location_evidence';
|
|
119
|
+
id: string;
|
|
120
|
+
customerRef: string;
|
|
121
|
+
/** Only `sufficient` evidence can be calculated against. */
|
|
122
|
+
status: 'sufficient' | 'insufficient' | 'conflicting';
|
|
123
|
+
/** The jurisdiction rule applied, e.g. `eu_digital_two_items`. */
|
|
124
|
+
rule: string;
|
|
125
|
+
country: string | null;
|
|
126
|
+
state: string | null;
|
|
127
|
+
items: {
|
|
128
|
+
type: TaxLocationEvidenceType;
|
|
129
|
+
country: string;
|
|
130
|
+
state: string | null;
|
|
131
|
+
}[];
|
|
132
|
+
observedAt: string;
|
|
133
|
+
expiresAt: string;
|
|
134
|
+
livemode: boolean;
|
|
135
|
+
}
|
|
136
|
+
export interface TaxLineItemParams {
|
|
137
|
+
reference: string;
|
|
138
|
+
/** Unit amount × quantity, minor units. Includes tax when inclusive. */
|
|
139
|
+
amount: number;
|
|
140
|
+
quantity?: number;
|
|
141
|
+
/** Defaults to the product's tax code, then the merchant's default. */
|
|
142
|
+
taxCode?: string;
|
|
143
|
+
/** Defaults to the merchant's default tax behavior. */
|
|
144
|
+
taxBehavior?: TaxBehavior;
|
|
145
|
+
}
|
|
146
|
+
export interface CreateTaxCalculationParams {
|
|
147
|
+
currency: string;
|
|
148
|
+
customerLocationEvidenceId: string;
|
|
149
|
+
lineItems: TaxLineItemParams[];
|
|
150
|
+
}
|
|
151
|
+
export interface TaxBreakdownEntry {
|
|
152
|
+
country: string;
|
|
153
|
+
state: string | null;
|
|
154
|
+
level: string | null;
|
|
155
|
+
displayName: string | null;
|
|
156
|
+
taxType: string | null;
|
|
157
|
+
/** Decimal string, e.g. `"20.0"`; null when no tax is imposed. */
|
|
158
|
+
ratePercentage: string | null;
|
|
159
|
+
taxableAmount: number;
|
|
160
|
+
amount: number;
|
|
161
|
+
inclusive: boolean;
|
|
162
|
+
/** Provider reason, or Peable's own `not_registered` / `product_nontaxable`. */
|
|
163
|
+
taxabilityReason: string;
|
|
164
|
+
}
|
|
165
|
+
export interface TaxCalculationLineItem {
|
|
166
|
+
reference: string;
|
|
167
|
+
quantity: number;
|
|
168
|
+
taxCode: string;
|
|
169
|
+
taxBehavior: TaxBehavior;
|
|
170
|
+
/** As given: includes tax when inclusive. */
|
|
171
|
+
amount: number;
|
|
172
|
+
amountTax: number;
|
|
173
|
+
/** Excluding tax. */
|
|
174
|
+
amountNet: number;
|
|
175
|
+
breakdown: TaxBreakdownEntry[];
|
|
176
|
+
}
|
|
177
|
+
/** A frozen answer. `collection` says why the tax is what it is:
|
|
178
|
+
* `collect` (a registration covers the customer and the provider calculated),
|
|
179
|
+
* `not_registered` (no registration covers them: zero tax, recorded as such),
|
|
180
|
+
* `nontaxable` (every line used the nontaxable code). */
|
|
181
|
+
export interface TaxCalculation {
|
|
182
|
+
object: 'tax.calculation';
|
|
183
|
+
id: string;
|
|
184
|
+
currency: string;
|
|
185
|
+
collection: 'collect' | 'not_registered' | 'nontaxable';
|
|
186
|
+
registrationId: string | null;
|
|
187
|
+
provider: string | null;
|
|
188
|
+
providerCalculationRef: string | null;
|
|
189
|
+
customerLocationEvidenceId: string;
|
|
190
|
+
country: string;
|
|
191
|
+
state: string | null;
|
|
192
|
+
/** What the customer pays. */
|
|
193
|
+
amountTotal: number;
|
|
194
|
+
amountNet: number;
|
|
195
|
+
taxAmountExclusive: number;
|
|
196
|
+
taxAmountInclusive: number;
|
|
197
|
+
lineItems: TaxCalculationLineItem[];
|
|
198
|
+
taxDate: string;
|
|
199
|
+
createdAt: string;
|
|
200
|
+
expiresAt: string;
|
|
201
|
+
livemode: boolean;
|
|
202
|
+
}
|
|
203
|
+
/** What a reversal gave back: the original calculation's amounts, scaled to
|
|
204
|
+
* the refunded share and NEGATIVE (positive only when it reinstates an earlier
|
|
205
|
+
* reversal, e.g. a refund the bank later failed). */
|
|
206
|
+
export interface TaxTransactionReversal {
|
|
207
|
+
amountTotal: number;
|
|
208
|
+
amountNet: number;
|
|
209
|
+
taxAmount: number;
|
|
210
|
+
lineItems: TaxCalculationLineItem[];
|
|
211
|
+
}
|
|
212
|
+
/** A calculation that was paid. Created by Peable when the payment it priced
|
|
213
|
+
* is accepted on its rail; the report and filings are built from these.
|
|
214
|
+
*
|
|
215
|
+
* `type: "reversal"` is a refund (or credit note) of an earlier transaction,
|
|
216
|
+
* `reversalOf` names it, and `reversal` holds its signed amounts. The report
|
|
217
|
+
* nets reversals into the rows of the original. */
|
|
218
|
+
export interface TaxTransaction {
|
|
219
|
+
object: 'tax.transaction';
|
|
220
|
+
id: string;
|
|
221
|
+
type: 'transaction' | 'reversal';
|
|
222
|
+
calculationId: string;
|
|
223
|
+
/** The rail's own object, e.g. the invoice id. */
|
|
224
|
+
reference: string;
|
|
225
|
+
rail: string;
|
|
226
|
+
committedAt: string;
|
|
227
|
+
/** The original transaction's id, for a reversal. */
|
|
228
|
+
reversalOf: string | null;
|
|
229
|
+
reversal: TaxTransactionReversal | null;
|
|
230
|
+
calculation: TaxCalculation;
|
|
231
|
+
}
|
|
232
|
+
/** Record a refund made outside Peable (a FairCoin rail payment is refunded
|
|
233
|
+
* from the seller's own wallet, never by the gateway). Card refunds and credit
|
|
234
|
+
* notes are observed from the provider instead. */
|
|
235
|
+
export interface CreateTaxReversalParams {
|
|
236
|
+
/** The refund's own reference; a repeated reference returns the same reversal. */
|
|
237
|
+
reference: string;
|
|
238
|
+
/** Gross minor units refunded (what the payer got back). Omitted: everything
|
|
239
|
+
* that is not yet reversed. */
|
|
240
|
+
amount?: number;
|
|
241
|
+
}
|
|
242
|
+
export interface TaxTransactionList {
|
|
243
|
+
object: 'list';
|
|
244
|
+
data: TaxTransaction[];
|
|
245
|
+
hasMore: boolean;
|
|
246
|
+
}
|
|
247
|
+
export interface ListTaxTransactionsParams {
|
|
248
|
+
/** Inclusive ISO timestamp. */
|
|
249
|
+
from: string;
|
|
250
|
+
/** Exclusive ISO timestamp. */
|
|
251
|
+
to: string;
|
|
252
|
+
limit?: number;
|
|
253
|
+
startingAfter?: string;
|
|
254
|
+
}
|
|
255
|
+
/** One filing line: totals per jurisdiction, registration, tax type and rate. */
|
|
256
|
+
export interface TaxReportRow {
|
|
257
|
+
country: string;
|
|
258
|
+
state: string | null;
|
|
259
|
+
registrationId: string | null;
|
|
260
|
+
scheme: TaxRegistrationScheme | null;
|
|
261
|
+
collection: TaxCalculation['collection'];
|
|
262
|
+
taxType: string | null;
|
|
263
|
+
ratePercentage: string | null;
|
|
264
|
+
currency: string;
|
|
265
|
+
transactions: number;
|
|
266
|
+
/** Reversals netted into this row; `taxableAmount` and `taxAmount` are net. */
|
|
267
|
+
reversals: number;
|
|
268
|
+
taxableAmount: number;
|
|
269
|
+
taxAmount: number;
|
|
270
|
+
}
|
|
271
|
+
export interface TaxReport {
|
|
272
|
+
object: 'tax.report';
|
|
273
|
+
from: string;
|
|
274
|
+
to: string;
|
|
275
|
+
rows: TaxReportRow[];
|
|
276
|
+
}
|
|
277
|
+
/** One tax line on a signed final invoice (`include: ['tax_lines']`). */
|
|
278
|
+
export interface BillingInvoiceTaxLine {
|
|
279
|
+
calculationId: string;
|
|
280
|
+
country: string;
|
|
281
|
+
state: string | null;
|
|
282
|
+
taxType: string | null;
|
|
283
|
+
ratePercentage: string | null;
|
|
284
|
+
taxableMinorUnits: number;
|
|
285
|
+
taxMinorUnits: number;
|
|
286
|
+
inclusive: boolean;
|
|
287
|
+
taxabilityReason: string;
|
|
288
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peable.to/shared-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
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",
|
|
@@ -24,6 +24,18 @@
|
|
|
24
24
|
},
|
|
25
25
|
"default": "./dist/esm/index.js"
|
|
26
26
|
},
|
|
27
|
+
"./tax": {
|
|
28
|
+
"react-native": "./dist/esm/tax.js",
|
|
29
|
+
"import": {
|
|
30
|
+
"types": "./dist/types/tax.d.ts",
|
|
31
|
+
"default": "./dist/esm/tax.js"
|
|
32
|
+
},
|
|
33
|
+
"require": {
|
|
34
|
+
"types": "./dist/types/tax.d.ts",
|
|
35
|
+
"default": "./dist/cjs/tax.js"
|
|
36
|
+
},
|
|
37
|
+
"default": "./dist/esm/tax.js"
|
|
38
|
+
},
|
|
27
39
|
"./package.json": "./package.json"
|
|
28
40
|
},
|
|
29
41
|
"files": [
|
|
@@ -54,8 +66,7 @@
|
|
|
54
66
|
"clean": "rm -rf dist",
|
|
55
67
|
"dev": "tsc --watch",
|
|
56
68
|
"typecheck": "tsc --noEmit",
|
|
57
|
-
"test": "bun test"
|
|
58
|
-
"prepublishOnly": "bun run clean && bun run build"
|
|
69
|
+
"test": "bun test"
|
|
59
70
|
},
|
|
60
71
|
"devDependencies": {
|
|
61
72
|
"typescript": "~5.9.2",
|
|
@@ -63,6 +74,6 @@
|
|
|
63
74
|
"@types/bun": "latest"
|
|
64
75
|
},
|
|
65
76
|
"dependencies": {
|
|
66
|
-
"@peable.to/contracts": "0.1
|
|
77
|
+
"@peable.to/contracts": "0.2.1"
|
|
67
78
|
}
|
|
68
79
|
}
|