@peable.to/shared-types 0.12.0 → 0.14.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/dispute.js +76 -0
- package/dist/cjs/file.js +44 -0
- package/dist/cjs/index.js +22 -1
- package/dist/cjs/money.js +36 -4
- package/dist/cjs/paymentMethodConfiguration.js +54 -0
- package/dist/cjs/requestLog.js +18 -0
- package/dist/cjs/testHelpers.js +21 -0
- package/dist/esm/dispute.js +74 -1
- package/dist/esm/file.js +41 -0
- package/dist/esm/index.js +6 -1
- package/dist/esm/money.js +35 -3
- package/dist/esm/paymentMethodConfiguration.js +51 -0
- package/dist/esm/requestLog.js +15 -0
- package/dist/esm/testHelpers.js +18 -0
- package/dist/types/dispute.d.ts +106 -99
- package/dist/types/event.d.ts +8 -2
- package/dist/types/file.d.ts +78 -0
- package/dist/types/index.d.ts +6 -2
- package/dist/types/merchant.d.ts +7 -0
- package/dist/types/merchantDisplay.d.ts +2 -0
- package/dist/types/money.d.ts +11 -3
- package/dist/types/paymentIntent.d.ts +22 -3
- package/dist/types/paymentMethodConfiguration.d.ts +116 -0
- package/dist/types/requestLog.d.ts +40 -0
- package/dist/types/testHelpers.d.ts +23 -0
- package/package.json +1 -1
package/dist/types/dispute.d.ts
CHANGED
|
@@ -1,28 +1,88 @@
|
|
|
1
|
+
import type { Charge } from './charge';
|
|
2
|
+
import type { CurrencyCode } from './money';
|
|
1
3
|
import type { PaymentIntent } from './paymentIntent';
|
|
2
4
|
/**
|
|
3
|
-
* A dispute — the card network holding a
|
|
4
|
-
*
|
|
5
|
+
* A dispute — the card network holding a payment's money while a cardholder
|
|
6
|
+
* contests it. Stripe's Dispute object (`dp_…`), Orbit's row.
|
|
5
7
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* those two events exist: `disputed` is a DEADLINE, and a merchant who has to
|
|
11
|
-
* make a second call to learn when evidence is due is a merchant who can miss it
|
|
12
|
-
* while their integration is working exactly as documented.
|
|
13
|
-
*
|
|
14
|
-
* It is also what the provider does. Stripe's `charge.dispute.created` carries
|
|
15
|
-
* the dispute, not the charge — the parity was half-applied.
|
|
8
|
+
* `charge.dispute.created|updated|closed|funds_withdrawn|funds_reinstated`
|
|
9
|
+
* carry it as `data.object`. A dispute is a DEADLINE: `created` carries
|
|
10
|
+
* `evidence_details.due_by`, so a merchant never needs a second call to learn
|
|
11
|
+
* when their response is due.
|
|
16
12
|
*/
|
|
17
13
|
/**
|
|
18
14
|
* Where the dispute stands.
|
|
19
15
|
*
|
|
20
16
|
* `needs_response` and `under_review` are open; `won` and `lost` are terminal
|
|
21
|
-
* and are the only two that say where the money ended up.
|
|
22
|
-
*
|
|
23
|
-
*
|
|
17
|
+
* and are the only two that say where the money ended up. The provider's
|
|
18
|
+
* `warning_*` inquiry states collapse onto the state they warn about. There is
|
|
19
|
+
* deliberately no `closed`: a merchant told a dispute "closed" without being
|
|
20
|
+
* told which way has been given a notification and no information.
|
|
24
21
|
*/
|
|
25
22
|
export type DisputeStatus = 'needs_response' | 'under_review' | 'won' | 'lost';
|
|
23
|
+
/**
|
|
24
|
+
* Why the cardholder disputed — Stripe's enum. A network reason code the
|
|
25
|
+
* provider does not map to one of these reads `general`; the row keeps the
|
|
26
|
+
* provider's own word, so nothing is lost by the normalisation.
|
|
27
|
+
*/
|
|
28
|
+
export declare const DISPUTE_REASONS: readonly ["bank_cannot_process", "check_returned", "credit_not_processed", "customer_initiated", "debit_not_authorized", "duplicate", "fraudulent", "general", "incorrect_account_details", "insufficient_funds", "noncompliant", "product_not_received", "product_unacceptable", "subscription_canceled", "unrecognized"];
|
|
29
|
+
export type DisputeReason = (typeof DISPUTE_REASONS)[number];
|
|
30
|
+
/** Map any provider reason onto {@link DisputeReason}: unknown or absent is `general`. */
|
|
31
|
+
export declare function normalizeDisputeReason(reason: string | null | undefined): DisputeReason;
|
|
32
|
+
/**
|
|
33
|
+
* The TEXT evidence fields — the network's names, spelled the way the rest of
|
|
34
|
+
* these contracts spell things, never a Peable paraphrase: a merchant assembling
|
|
35
|
+
* a defence is reading their acquirer's guidance, and renamed fields would make
|
|
36
|
+
* that guidance not apply.
|
|
37
|
+
*
|
|
38
|
+
* Declared ONCE. The route's schema is `satisfies Record<DisputeTextEvidenceField, …>`
|
|
39
|
+
* and the Stripe adapter's name map is a total `Record`, so a field added here
|
|
40
|
+
* does not compile until both carry it — the drift that would let a merchant
|
|
41
|
+
* send a field the network never sees.
|
|
42
|
+
*/
|
|
43
|
+
export declare const DISPUTE_TEXT_EVIDENCE_FIELDS: readonly ["access_activity_log", "billing_address", "cancellation_policy_disclosure", "cancellation_rebuttal", "customer_email_address", "customer_name", "customer_purchase_ip", "duplicate_charge_explanation", "product_description", "refund_policy_disclosure", "refund_refusal_explanation", "service_date", "shipping_address", "shipping_carrier", "shipping_date", "shipping_tracking_number", "uncategorized_text"];
|
|
44
|
+
export type DisputeTextEvidenceField = (typeof DISPUTE_TEXT_EVIDENCE_FIELDS)[number];
|
|
45
|
+
/**
|
|
46
|
+
* The FILE evidence fields. Each names a `file_…` of purpose `dispute_evidence`
|
|
47
|
+
* uploaded by the same merchant; its bytes go to the provider when the response
|
|
48
|
+
* is submitted, and only then.
|
|
49
|
+
*/
|
|
50
|
+
export declare const DISPUTE_FILE_EVIDENCE_FIELDS: readonly ["cancellation_policy", "customer_communication", "customer_signature", "duplicate_charge_documentation", "receipt", "refund_policy", "service_documentation", "shipping_documentation", "uncategorized_file"];
|
|
51
|
+
export type DisputeFileEvidenceField = (typeof DISPUTE_FILE_EVIDENCE_FIELDS)[number];
|
|
52
|
+
export type DisputeEvidenceField = DisputeTextEvidenceField | DisputeFileEvidenceField;
|
|
53
|
+
/**
|
|
54
|
+
* A merchant's evidence as the dispute holds it: every field, `null` when unset.
|
|
55
|
+
*
|
|
56
|
+
* Present ONLY on a live read — `GET /v1/disputes/:id` and the answers of
|
|
57
|
+
* `POST /v1/disputes/:id` and `…/close`. The text half is read from the
|
|
58
|
+
* provider, which is where a draft lives (Peable never stores it); the file half
|
|
59
|
+
* is the `file_…` ids the merchant attached. Lists and event payloads never
|
|
60
|
+
* carry it: an event is stored, and evidence carries a customer's name, email,
|
|
61
|
+
* address and correspondence.
|
|
62
|
+
*/
|
|
63
|
+
export type DisputeEvidence = Record<DisputeEvidenceField, string | null>;
|
|
64
|
+
/**
|
|
65
|
+
* `evidence` on `POST /v1/disputes/:id`: any subset of the fields. A text field
|
|
66
|
+
* is the merchant's words; a file field is a `file_…`. An empty string UNSETS
|
|
67
|
+
* the field, as on Stripe.
|
|
68
|
+
*/
|
|
69
|
+
export type DisputeEvidenceParams = Partial<Record<DisputeEvidenceField, string>>;
|
|
70
|
+
/** The response's bookkeeping — Stripe's `evidence_details`, plus when it was submitted. */
|
|
71
|
+
export interface DisputeEvidenceDetails {
|
|
72
|
+
/**
|
|
73
|
+
* When the network stops accepting evidence, Unix seconds. `null` once the
|
|
74
|
+
* dispute is closed — there is no deadline for a decision already made.
|
|
75
|
+
*/
|
|
76
|
+
due_by: number | null;
|
|
77
|
+
/** Whether any evidence has been staged or submitted. */
|
|
78
|
+
has_evidence: boolean;
|
|
79
|
+
/** Whether the deadline passed without a submission. */
|
|
80
|
+
past_due: boolean;
|
|
81
|
+
/** `0` or `1`: a response is one-shot at the network. */
|
|
82
|
+
submission_count: number;
|
|
83
|
+
/** When the response reached the network, Unix seconds; `null` while it has not. */
|
|
84
|
+
submitted_at: number | null;
|
|
85
|
+
}
|
|
26
86
|
export interface Dispute {
|
|
27
87
|
id: string;
|
|
28
88
|
object: 'dispute';
|
|
@@ -31,100 +91,47 @@ export interface Dispute {
|
|
|
31
91
|
* `true` for a `production` merchant, `false` for every other environment.
|
|
32
92
|
*/
|
|
33
93
|
livemode: boolean;
|
|
34
|
-
/** The disputed payment's `pi_…`, or the {@link PaymentIntent} with `expand[]=payment_intent`. */
|
|
35
|
-
payment_intent: string | PaymentIntent;
|
|
36
94
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* It is the DISPUTED amount, which may be less than the payment's: a
|
|
41
|
-
* cardholder can contest part of a charge.
|
|
95
|
+
* The DISPUTED amount in the currency's smallest unit, as a canonical integer
|
|
96
|
+
* string. It may be less than the payment's: a cardholder can contest part of
|
|
97
|
+
* a charge.
|
|
42
98
|
*/
|
|
43
99
|
amount: string;
|
|
44
|
-
currency:
|
|
100
|
+
currency: CurrencyCode;
|
|
101
|
+
/** `ch_…`, or the {@link Charge} with `expand[]=charge`. */
|
|
102
|
+
charge: string | Charge | null;
|
|
103
|
+
/** The disputed payment's `pi_…`, or the {@link PaymentIntent} with `expand[]=payment_intent`. */
|
|
104
|
+
payment_intent: string | PaymentIntent;
|
|
45
105
|
status: DisputeStatus;
|
|
106
|
+
reason: DisputeReason;
|
|
46
107
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* Deliberately an open string rather than a closed set. It is the one field a
|
|
50
|
-
* merchant argues against, and a gateway paraphrase would be the words they
|
|
51
|
-
* quote while the acquirer holds different ones. `null` when the network sent
|
|
52
|
-
* none.
|
|
53
|
-
*/
|
|
54
|
-
reason: string | null;
|
|
55
|
-
/**
|
|
56
|
-
* When the network stops accepting evidence, Unix seconds.
|
|
57
|
-
*
|
|
58
|
-
* `null` once the dispute is closed — there is no deadline for a decision
|
|
59
|
-
* already made, and a closed dispute still showing one would put a response
|
|
60
|
-
* in front of a merchant that can no longer be given.
|
|
61
|
-
*/
|
|
62
|
-
evidence_due_at: number | null;
|
|
63
|
-
/**
|
|
64
|
-
* When the merchant's response reached the network, Unix seconds. `null` while
|
|
65
|
-
* none has been submitted.
|
|
66
|
-
*
|
|
67
|
-
* The timestamp and nothing else: the evidence itself is forwarded to the
|
|
68
|
-
* acquirer and never stored here. What it SAID is readable there, by someone
|
|
69
|
-
* with their own authorization — this gateway does not keep a copy of a
|
|
70
|
-
* customer's name, address and correspondence.
|
|
71
|
-
*
|
|
72
|
-
* Together with `evidenceDueAt` it answers the only two questions a merchant
|
|
73
|
-
* has about a live dispute: whether they still owe a response, and by when.
|
|
108
|
+
* Whether the disputed payment can still be refunded. Once it has been in
|
|
109
|
+
* full, no further funds are withdrawn because of this dispute.
|
|
74
110
|
*/
|
|
75
|
-
|
|
111
|
+
is_charge_refundable: boolean;
|
|
112
|
+
evidence_details: DisputeEvidenceDetails;
|
|
113
|
+
/** Live reads only — see {@link DisputeEvidence}. */
|
|
114
|
+
evidence?: DisputeEvidence;
|
|
115
|
+
metadata: Record<string, string>;
|
|
76
116
|
created: number;
|
|
77
117
|
updated_at: number;
|
|
78
118
|
}
|
|
79
119
|
/**
|
|
80
|
-
*
|
|
120
|
+
* `POST /v1/disputes/:id`.
|
|
81
121
|
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* list, and the cost of them drifting is specific and silent — a field added to
|
|
87
|
-
* three of the four is one a merchant sends, the gateway accepts, and the
|
|
88
|
-
* network never sees. They find out when the dispute is decided against them.
|
|
89
|
-
*
|
|
90
|
-
* So the set lives here, with the wire contracts, and the other three are
|
|
91
|
-
* pinned to it: `provider.ts` aliases it, `routes/disputes.ts` declares its
|
|
92
|
-
* schema `satisfies Record<keyof DisputeEvidence, …>`, and the Stripe adapter's
|
|
93
|
-
* map is a total `Record<keyof DisputeEvidence, …>`. Adding a field here makes
|
|
94
|
-
* all three fail to compile until they carry it.
|
|
95
|
-
*
|
|
96
|
-
* ## What is not here
|
|
97
|
-
*
|
|
98
|
-
* The field NAMES are the network's, spelled the way the rest of these
|
|
99
|
-
* contracts spell things. They are not a Peable vocabulary and are not mapped
|
|
100
|
-
* to one: a merchant assembling a defence is reading their acquirer's guidance,
|
|
101
|
-
* and a gateway that renamed the fields would make that guidance not apply.
|
|
102
|
-
*
|
|
103
|
-
* FILE attachments are deliberately absent. They need the provider's upload
|
|
104
|
-
* API, a size and type policy, and somewhere for the bytes to live on the way
|
|
105
|
-
* through — and offering half of that would let a merchant submit a defence
|
|
106
|
-
* missing the receipt it rests on.
|
|
107
|
-
*
|
|
108
|
-
* None of it is ever stored. It carries a customer's name, their email, a
|
|
109
|
-
* billing address and correspondence; it is forwarded to the acquirer and
|
|
110
|
-
* forgotten. What is recorded is `evidenceSubmittedAt` and nothing more.
|
|
122
|
+
* `submit: false` (the default) STAGES the evidence: text goes to the provider
|
|
123
|
+
* as a draft, files are attached by id. `submit: true` uploads the attached
|
|
124
|
+
* files to the provider and submits everything — ONCE; a second submission is
|
|
125
|
+
* refused, because the network takes one response.
|
|
111
126
|
*/
|
|
112
|
-
export interface
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
service_date?: string;
|
|
123
|
-
access_activity_log?: string;
|
|
124
|
-
cancellation_policy_disclosure?: string;
|
|
125
|
-
cancellation_rebuttal?: string;
|
|
126
|
-
duplicate_charge_explanation?: string;
|
|
127
|
-
refund_policy_disclosure?: string;
|
|
128
|
-
refund_refusal_explanation?: string;
|
|
129
|
-
uncategorized_text?: string;
|
|
127
|
+
export interface UpdateDisputeParams {
|
|
128
|
+
evidence?: DisputeEvidenceParams;
|
|
129
|
+
/** A PATCH (`""` unsets a key). */
|
|
130
|
+
metadata?: Record<string, string>;
|
|
131
|
+
submit?: boolean;
|
|
132
|
+
}
|
|
133
|
+
/** `GET /v1/disputes`. */
|
|
134
|
+
export interface ListDisputesParams {
|
|
135
|
+
payment_intent?: string;
|
|
136
|
+
charge?: string;
|
|
130
137
|
}
|
package/dist/types/event.d.ts
CHANGED
|
@@ -44,8 +44,10 @@ export interface BillingObservation {
|
|
|
44
44
|
* Refunds are not PaymentIntent statuses: `refund.created|updated|failed` carry
|
|
45
45
|
* the Refund, and `charge.refunded` the Charge whose `amount_refunded` moved.
|
|
46
46
|
* A dispute is the network's process beside a payment that stays `succeeded`:
|
|
47
|
-
* `charge.dispute.created` is a DEADLINE (evidence is due), `
|
|
48
|
-
* the outcome
|
|
47
|
+
* `charge.dispute.created` is a DEADLINE (evidence is due), `updated` follows
|
|
48
|
+
* a staged or submitted response, `closed` carries the outcome, and
|
|
49
|
+
* `funds_withdrawn` / `funds_reinstated` the money's movement — never the
|
|
50
|
+
* evidence, which is not stored and so is never in an event.
|
|
49
51
|
*/
|
|
50
52
|
export interface WebhookEventPayload {
|
|
51
53
|
'payment_intent.created': PaymentIntent;
|
|
@@ -59,6 +61,10 @@ export interface WebhookEventPayload {
|
|
|
59
61
|
'charge.dispute.created': Dispute;
|
|
60
62
|
'charge.dispute.updated': Dispute;
|
|
61
63
|
'charge.dispute.closed': Dispute;
|
|
64
|
+
/** The network took the disputed amount from the balance. */
|
|
65
|
+
'charge.dispute.funds_withdrawn': Dispute;
|
|
66
|
+
/** The network returned it (the dispute was won, or withdrawn by the cardholder). */
|
|
67
|
+
'charge.dispute.funds_reinstated': Dispute;
|
|
62
68
|
'refund.created': Refund;
|
|
63
69
|
'refund.updated': Refund;
|
|
64
70
|
'refund.failed': Refund;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a file is FOR. Decided at upload and never changed: the purpose is what
|
|
3
|
+
* sets the type and size policy, who may see the bytes, and which objects may
|
|
4
|
+
* reference the file — a `business_logo` is public, a `dispute_evidence` file
|
|
5
|
+
* is private and can only be attached to the merchant's own disputes.
|
|
6
|
+
*/
|
|
7
|
+
export declare const FILE_PURPOSES: readonly ["dispute_evidence", "business_logo", "identity_document", "additional_verification"];
|
|
8
|
+
export type FilePurpose = (typeof FILE_PURPOSES)[number];
|
|
9
|
+
/** The stored format, by its conventional extension (Stripe's `type`). */
|
|
10
|
+
export declare const FILE_TYPES: readonly ["pdf", "png", "jpg"];
|
|
11
|
+
export type FileType = (typeof FILE_TYPES)[number];
|
|
12
|
+
/**
|
|
13
|
+
* Whether the bytes can be used right now.
|
|
14
|
+
*
|
|
15
|
+
* - `available` — Oxy serves the file; it can be shown or forwarded.
|
|
16
|
+
* - `withheld` — the file still exists and is not being served (its owner
|
|
17
|
+
* trashed it or made it private); it can come back.
|
|
18
|
+
* - `removed` — Oxy said the file is gone for good (deleted, taken down, lost).
|
|
19
|
+
* The object stays so whatever referenced it can say why it stopped working.
|
|
20
|
+
*/
|
|
21
|
+
export declare const FILE_STATUSES: readonly ["available", "withheld", "removed"];
|
|
22
|
+
export type FileStatus = (typeof FILE_STATUSES)[number];
|
|
23
|
+
/**
|
|
24
|
+
* The upload policy of each purpose: the formats it takes, recognised from the
|
|
25
|
+
* bytes and never from a client's `Content-Type`, and the largest file.
|
|
26
|
+
*
|
|
27
|
+
* The provider's own ceilings, restated where the upload is parsed, so a file
|
|
28
|
+
* the card network would refuse is refused at upload — not at the one-shot
|
|
29
|
+
* dispute submission it was meant for.
|
|
30
|
+
*/
|
|
31
|
+
export declare const FILE_PURPOSE_POLICIES: Readonly<Record<FilePurpose, {
|
|
32
|
+
readonly types: readonly FileType[];
|
|
33
|
+
readonly max_bytes: number;
|
|
34
|
+
}>>;
|
|
35
|
+
/**
|
|
36
|
+
* The API's `file` object. Named `FileObject` rather than `File` so it never
|
|
37
|
+
* shadows the DOM's `File` in a browser that imports both.
|
|
38
|
+
*/
|
|
39
|
+
export interface FileObject {
|
|
40
|
+
/** `file_…`. */
|
|
41
|
+
id: string;
|
|
42
|
+
object: 'file';
|
|
43
|
+
/** The mode of the merchant that uploaded it (ADR 0017). */
|
|
44
|
+
livemode: boolean;
|
|
45
|
+
purpose: FilePurpose;
|
|
46
|
+
/** The name it was uploaded with, if it had a printable one. */
|
|
47
|
+
filename: string | null;
|
|
48
|
+
/** Bytes. */
|
|
49
|
+
size: number;
|
|
50
|
+
type: FileType;
|
|
51
|
+
status: FileStatus;
|
|
52
|
+
/**
|
|
53
|
+
* A public URL for a `business_logo` that is `available` — what a payer
|
|
54
|
+
* surface renders. `null` for every other purpose: evidence and identity
|
|
55
|
+
* documents are never addressable by URL, and their bytes leave Peable only
|
|
56
|
+
* to the provider they are submitted to.
|
|
57
|
+
*/
|
|
58
|
+
url: string | null;
|
|
59
|
+
created: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* `POST /v1/files` — exactly one source:
|
|
63
|
+
*
|
|
64
|
+
* - the bytes, as `multipart/form-data` with a `purpose` field and a `file`
|
|
65
|
+
* part (the SDK's `files.create({ purpose, file })` builds it);
|
|
66
|
+
* - `oxy_file`: as JSON, an Oxy file the caller already owns (their
|
|
67
|
+
* application's, or an account they are or act for). Its ownership is
|
|
68
|
+
* checked once, here, and never again.
|
|
69
|
+
*/
|
|
70
|
+
export interface CreateFileFromOxyParams {
|
|
71
|
+
purpose: FilePurpose;
|
|
72
|
+
/** Oxy file id. */
|
|
73
|
+
oxy_file: string;
|
|
74
|
+
}
|
|
75
|
+
/** `GET /v1/files`. */
|
|
76
|
+
export interface ListFilesParams {
|
|
77
|
+
purpose?: FilePurpose;
|
|
78
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { UNITS_PER_COIN, isBaseUnitString, type CurrencyCode, CURRENCY_CODES, CURRENCY_DECIMALS, decimalsFor, isCurrencyCode, } from './money';
|
|
1
|
+
export { UNITS_PER_COIN, isBaseUnitString, type CurrencyCode, type FiatCurrencyCode, CURRENCY_CODES, CURRENCY_DECIMALS, FIAT_CURRENCY_CODES, decimalsFor, isCurrencyCode, } from './money';
|
|
2
2
|
export type { NetworkType } from './network';
|
|
3
3
|
export type { ExpandParams, List, ListParams, RangeQuery } from './list';
|
|
4
4
|
export { type Address, type AddressParams, type CancelPaymentIntentParams, type CapturePaymentIntentParams, type ConfirmPaymentIntentParams, type CreatePaymentIntentParams, type PaymentIntent, type PaymentIntentCancellationReason, type PaymentIntentCaptureMethod, type PaymentIntentFaircoin, type PaymentIntentLastPaymentError, type PaymentIntentNextAction, type PaymentIntentRail, type PaymentIntentSetupFutureUsage, type PaymentIntentStatus, type PaymentMethodType, type Shipping, type ShippingParams, type UpdatePaymentIntentParams, CARD_ONLY_STATUSES, EXPIRABLE_STATUSES, MERCHANT_CANCELLATION_REASONS, PAYMENT_INTENT_CANCELLATION_REASONS, PAYMENT_INTENT_CAPTURE_METHODS, PAYMENT_INTENT_RAILS, PAYMENT_INTENT_SETUP_FUTURE_USAGES, PAYMENT_INTENT_STATUSES, TERMINAL_STATUSES, canExpire, canStillBePaid, isValidStatusTransition, } from './paymentIntent';
|
|
@@ -9,9 +9,13 @@ export { type CancelSetupIntentParams, type CreateSetupIntentParams, type SetupI
|
|
|
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
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';
|
|
12
|
-
export type
|
|
12
|
+
export { DISPUTE_FILE_EVIDENCE_FIELDS, DISPUTE_REASONS, DISPUTE_TEXT_EVIDENCE_FIELDS, normalizeDisputeReason, type Dispute, type DisputeEvidence, type DisputeEvidenceDetails, type DisputeEvidenceField, type DisputeEvidenceParams, type DisputeFileEvidenceField, type DisputeReason, type DisputeStatus, type DisputeTextEvidenceField, type ListDisputesParams, type UpdateDisputeParams, } from './dispute';
|
|
13
|
+
export { FILE_PURPOSES, FILE_PURPOSE_POLICIES, FILE_STATUSES, FILE_TYPES, type CreateFileFromOxyParams, type FileObject, type FilePurpose, type FileStatus, type FileType, type ListFilesParams, } from './file';
|
|
14
|
+
export { CARD_RAIL_PAYMENT_METHOD_TYPES, PAYMENT_METHOD_CONFIGURATION_TYPES, PAYMENT_METHOD_CURRENCIES, type CardRailPaymentMethodType, type CreatePaymentMethodConfigurationParams, type CreatePaymentMethodDomainParams, type ListPaymentMethodDomainsParams, type PaymentMethodConfiguration, type PaymentMethodConfigurationEntry, type PaymentMethodConfigurationEntryParams, type PaymentMethodConfigurationType, type PaymentMethodDisplayPreference, type PaymentMethodDomain, type PaymentMethodDomainWalletStatus, type PaymentMethodUnavailableReason, type UpdatePaymentMethodConfigurationParams, type UpdatePaymentMethodDomainParams, } from './paymentMethodConfiguration';
|
|
13
15
|
export type { CapabilityStatus, ConnectedAccount, ConnectedAccountFaircoin, ConnectedAccountFaircoinStatus, ConnectedAccountRail, Refund, RefundOrigin, RefundStatus, Settlement, Transfer, TransferReversal, TransferReversalStatus, TransferStatus, TransferWithReversal, } from './settlement';
|
|
14
16
|
export type { WebhookDelivery, WebhookDeliveryStatus, } from './webhookDelivery';
|
|
17
|
+
export { REQUEST_LOG_METHODS, REQUEST_LOG_RETENTION_DAYS, type RequestLog, type RequestLogListParams, type RequestLogMethod, type RequestLogStatusFilter, } from './requestLog';
|
|
18
|
+
export { SIMULATED_FAIRCOIN_OUTCOMES, type SimulatedFaircoinOutcome, type SimulateFaircoinPaymentParams, } from './testHelpers';
|
|
15
19
|
export { signWebhook, verifyWebhook } from './webhookSigner';
|
|
16
20
|
export { type MerchantEnvironment, type Merchant, MERCHANT_ENVIRONMENTS, } from './merchant';
|
|
17
21
|
export type { MerchantDisplay } from './merchantDisplay';
|
package/dist/types/merchant.d.ts
CHANGED
|
@@ -35,6 +35,13 @@ export interface Merchant {
|
|
|
35
35
|
* Absent again once Oxy reports the file deleted or taken down.
|
|
36
36
|
*/
|
|
37
37
|
avatar_file_id?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The wide wordmark payer surfaces show in their header: a `file_…` of
|
|
40
|
+
* purpose `business_logo`. Beside the avatar, never instead of it — the avatar
|
|
41
|
+
* is the square identity image (Stripe's branding `icon`), the logo is the
|
|
42
|
+
* wordmark (Stripe's branding `logo`). Absent when unset.
|
|
43
|
+
*/
|
|
44
|
+
business_logo?: string;
|
|
38
45
|
description?: string;
|
|
39
46
|
created: number;
|
|
40
47
|
updated_at: number;
|
|
@@ -3,5 +3,7 @@ export interface MerchantDisplay {
|
|
|
3
3
|
name: string;
|
|
4
4
|
/** Resolved server-side via the canonical media chokepoint; `null` when the merchant has no avatar. */
|
|
5
5
|
avatar_url: string | null;
|
|
6
|
+
/** The merchant's `business_logo`, resolved; `null` when unset or not being served. */
|
|
7
|
+
logo_url: string | null;
|
|
6
8
|
description: string | null;
|
|
7
9
|
}
|
package/dist/types/money.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The currencies this gateway can denominate a payment in
|
|
2
|
+
* The currencies this gateway can denominate a payment in: FairCoin on the
|
|
3
|
+
* chain rail, and on the card rail the fiat set the provider settles for the
|
|
4
|
+
* payment methods Orbit offers (cards, wallets, SEPA Debit, iDEAL, Bancontact,
|
|
5
|
+
* EPS). A local method narrows it further per payment
|
|
6
|
+
* (`PAYMENT_METHOD_CURRENCIES` in `paymentMethodConfiguration.ts`).
|
|
3
7
|
*
|
|
4
8
|
* A closed set, and the database mirrors it as a CHECK
|
|
5
9
|
* (`db/schema/valueSets.ts`). ADR 0001 D4: the scale of an amount is a property
|
|
@@ -7,7 +11,7 @@
|
|
|
7
11
|
* {@link CURRENCY_DECIMALS} exists and why {@link UNITS_PER_COIN} must never be
|
|
8
12
|
* used to interpret a fiat amount.
|
|
9
13
|
*/
|
|
10
|
-
export declare const CURRENCY_CODES: readonly ["FAIR", "EUR", "USD"];
|
|
14
|
+
export declare const CURRENCY_CODES: readonly ["FAIR", "EUR", "USD", "GBP", "CHF", "SEK", "NOK", "DKK", "PLN", "CZK", "CAD", "AUD", "JPY"];
|
|
11
15
|
export type CurrencyCode = (typeof CURRENCY_CODES)[number];
|
|
12
16
|
/** Whether an arbitrary string is a currency this gateway knows. */
|
|
13
17
|
export declare function isCurrencyCode(value: string): value is CurrencyCode;
|
|
@@ -15,11 +19,15 @@ export declare function isCurrencyCode(value: string): value is CurrencyCode;
|
|
|
15
19
|
* How many decimal places each currency's smallest unit represents — i.e. an
|
|
16
20
|
* amount of `1` means `10^-decimals` of one whole unit.
|
|
17
21
|
*
|
|
18
|
-
* FairCoin's 8 is a consensus constant and is pinned against
|
|
22
|
+
* ISO 4217's minor units for every fiat member (JPY has none). FairCoin's 8 is a consensus constant and is pinned against
|
|
19
23
|
* {@link UNITS_PER_COIN} by this package's own tests, so the two spellings of
|
|
20
24
|
* one fact cannot drift.
|
|
21
25
|
*/
|
|
22
26
|
export declare const CURRENCY_DECIMALS: Readonly<Record<CurrencyCode, number>>;
|
|
27
|
+
/** A currency the card rail can denominate a payment in. */
|
|
28
|
+
export type FiatCurrencyCode = Exclude<CurrencyCode, 'FAIR'>;
|
|
29
|
+
/** The fiat members — every currency the card rail can denominate a payment in. */
|
|
30
|
+
export declare const FIAT_CURRENCY_CODES: readonly FiatCurrencyCode[];
|
|
23
31
|
/** The decimal places of `currency`'s smallest unit. */
|
|
24
32
|
export declare function decimalsFor(currency: CurrencyCode): number;
|
|
25
33
|
export declare const UNITS_PER_COIN = 100000000n;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CardRailPaymentMethodType } from './paymentMethodConfiguration';
|
|
1
2
|
import type { Charge } from './charge';
|
|
2
3
|
import type { Customer } from './customer';
|
|
3
4
|
import type { CurrencyCode } from './money';
|
|
@@ -85,8 +86,12 @@ export declare const PAYMENT_INTENT_CAPTURE_METHODS: readonly PaymentIntentCaptu
|
|
|
85
86
|
/** Card only: keep the payment method on the customer for later (ADR 0016). */
|
|
86
87
|
export type PaymentIntentSetupFutureUsage = 'on_session' | 'off_session';
|
|
87
88
|
export declare const PAYMENT_INTENT_SETUP_FUTURE_USAGES: readonly PaymentIntentSetupFutureUsage[];
|
|
88
|
-
/**
|
|
89
|
-
|
|
89
|
+
/**
|
|
90
|
+
* The payment method types a PaymentIntent can carry: `faircoin` on the chain
|
|
91
|
+
* rail, and on the card rail the card and the local methods the provider
|
|
92
|
+
* collects in its hosted fields. Wallets (Apple Pay, Google Pay) are `card`.
|
|
93
|
+
*/
|
|
94
|
+
export type PaymentMethodType = 'faircoin' | CardRailPaymentMethodType;
|
|
90
95
|
/** Why the last attempt failed. Peable's words, never the provider's raw prose. */
|
|
91
96
|
export interface PaymentIntentLastPaymentError {
|
|
92
97
|
/** `card_error` for a declined card; `payment_error` for a FairCoin underpayment. */
|
|
@@ -176,7 +181,16 @@ export interface PaymentIntent {
|
|
|
176
181
|
status: PaymentIntentStatus;
|
|
177
182
|
/** Which rail moves this payment. Decides which fields below are populated. */
|
|
178
183
|
rail: PaymentIntentRail;
|
|
184
|
+
/**
|
|
185
|
+
* What the payer may pay with: `['faircoin']` on the chain; on the card rail
|
|
186
|
+
* the types named at creation, or those the configuration offers in this
|
|
187
|
+
* currency.
|
|
188
|
+
*/
|
|
179
189
|
payment_method_types: PaymentMethodType[];
|
|
190
|
+
/** The `pmc_…` whose methods this card payment offers; `null` on the chain and when types were named. */
|
|
191
|
+
payment_method_configuration_details: {
|
|
192
|
+
id: string;
|
|
193
|
+
} | null;
|
|
180
194
|
/**
|
|
181
195
|
* Amount in the currency's SMALLEST unit as a canonical integer string.
|
|
182
196
|
* Never a float, and never interpretable without `currency`: m⊜ (10^-8 FAIR)
|
|
@@ -236,8 +250,13 @@ export interface CreatePaymentIntentParams {
|
|
|
236
250
|
network?: NetworkType;
|
|
237
251
|
/** Defaults to `'FAIR'` on the faircoin rail; required on the card rail. */
|
|
238
252
|
currency?: CurrencyCode;
|
|
239
|
-
/**
|
|
253
|
+
/**
|
|
254
|
+
* `['faircoin']` on the chain rail. On the card rail, any of the card-rail
|
|
255
|
+
* types the provider offers in `currency` — instead of a configuration.
|
|
256
|
+
*/
|
|
240
257
|
payment_method_types?: PaymentMethodType[];
|
|
258
|
+
/** Card only: the `pmc_…` whose methods to offer. Defaults to the merchant's default configuration. */
|
|
259
|
+
payment_method_configuration?: string;
|
|
241
260
|
/** `cus_…`. */
|
|
242
261
|
customer?: string;
|
|
243
262
|
/** `pm_…`, card only. A saved payment method of `customer`. */
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { type FiatCurrencyCode } from './money';
|
|
2
|
+
/**
|
|
3
|
+
* The methods a configuration can turn on.
|
|
4
|
+
*
|
|
5
|
+
* `apple_pay` and `google_pay` are WALLETS over a card: a payment made with one
|
|
6
|
+
* is a `card` payment, so they appear here and never in a PaymentIntent's
|
|
7
|
+
* `payment_method_types`. `bizum` is listed because merchants ask for it and the
|
|
8
|
+
* honest answer is a reason, not an absence: the provider does not offer it.
|
|
9
|
+
*
|
|
10
|
+
* Deliberately absent: the provider's own consumer wallet (its brand on Orbit's
|
|
11
|
+
* checkout, `payment-provider-boundary.md`) and giropay (discontinued by the
|
|
12
|
+
* scheme).
|
|
13
|
+
*/
|
|
14
|
+
export declare const PAYMENT_METHOD_CONFIGURATION_TYPES: readonly ["card", "apple_pay", "google_pay", "sepa_debit", "ideal", "bancontact", "eps", "bizum"];
|
|
15
|
+
export type PaymentMethodConfigurationType = (typeof PAYMENT_METHOD_CONFIGURATION_TYPES)[number];
|
|
16
|
+
/** The card-rail types a PaymentIntent can carry in `payment_method_types`. */
|
|
17
|
+
export declare const CARD_RAIL_PAYMENT_METHOD_TYPES: readonly ["card", "sepa_debit", "ideal", "bancontact", "eps"];
|
|
18
|
+
export type CardRailPaymentMethodType = (typeof CARD_RAIL_PAYMENT_METHOD_TYPES)[number];
|
|
19
|
+
/**
|
|
20
|
+
* Why a method cannot be offered whatever the merchant chooses.
|
|
21
|
+
*
|
|
22
|
+
* - `provider_unsupported` — the processing provider does not offer it;
|
|
23
|
+
* - `requires_card` — a wallet rides on card payments, and card is off.
|
|
24
|
+
*/
|
|
25
|
+
export type PaymentMethodUnavailableReason = 'provider_unsupported' | 'requires_card';
|
|
26
|
+
/**
|
|
27
|
+
* The currencies each method can take a payment in. A method is offered on a
|
|
28
|
+
* payment only when its currency is listed — so iDEAL never appears on a USD
|
|
29
|
+
* payment, and a payer is never shown a method that would fail.
|
|
30
|
+
*/
|
|
31
|
+
export declare const PAYMENT_METHOD_CURRENCIES: Readonly<Record<PaymentMethodConfigurationType, readonly FiatCurrencyCode[]>>;
|
|
32
|
+
/** The merchant's choice (`none`: Orbit's default) and what is in effect. */
|
|
33
|
+
export interface PaymentMethodDisplayPreference {
|
|
34
|
+
preference: 'on' | 'off' | 'none';
|
|
35
|
+
value: 'on' | 'off';
|
|
36
|
+
}
|
|
37
|
+
export interface PaymentMethodConfigurationEntry {
|
|
38
|
+
/** Whether payers can be offered this method: it is on and nothing prevents it. */
|
|
39
|
+
available: boolean;
|
|
40
|
+
display_preference: PaymentMethodDisplayPreference;
|
|
41
|
+
/** Why it cannot be offered whatever the merchant chooses; `null` when it can. */
|
|
42
|
+
unavailable_reason: PaymentMethodUnavailableReason | null;
|
|
43
|
+
/** The payment currencies it is offered on. */
|
|
44
|
+
currencies: readonly FiatCurrencyCode[];
|
|
45
|
+
}
|
|
46
|
+
export type PaymentMethodConfiguration = {
|
|
47
|
+
/** `pmc_…`. */
|
|
48
|
+
id: string;
|
|
49
|
+
object: 'payment_method_configuration';
|
|
50
|
+
livemode: boolean;
|
|
51
|
+
name: string;
|
|
52
|
+
/** An inactive configuration cannot be named on a new PaymentIntent. The default is always active. */
|
|
53
|
+
active: boolean;
|
|
54
|
+
/** The configuration a PaymentIntent uses when it names none. Exactly one per merchant. */
|
|
55
|
+
is_default: boolean;
|
|
56
|
+
created: number;
|
|
57
|
+
updated_at: number;
|
|
58
|
+
} & {
|
|
59
|
+
[K in PaymentMethodConfigurationType]: PaymentMethodConfigurationEntry;
|
|
60
|
+
};
|
|
61
|
+
/** One method's setting in a create or update. */
|
|
62
|
+
export interface PaymentMethodConfigurationEntryParams {
|
|
63
|
+
display_preference: {
|
|
64
|
+
preference: 'on' | 'off' | 'none';
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** `POST /v1/payment_method_configurations`. */
|
|
68
|
+
export type CreatePaymentMethodConfigurationParams = {
|
|
69
|
+
name?: string;
|
|
70
|
+
} & {
|
|
71
|
+
[K in PaymentMethodConfigurationType]?: PaymentMethodConfigurationEntryParams;
|
|
72
|
+
};
|
|
73
|
+
/** `POST /v1/payment_method_configurations/:id`. */
|
|
74
|
+
export type UpdatePaymentMethodConfigurationParams = CreatePaymentMethodConfigurationParams & {
|
|
75
|
+
active?: boolean;
|
|
76
|
+
};
|
|
77
|
+
/** A wallet's standing on one domain. */
|
|
78
|
+
export interface PaymentMethodDomainWalletStatus {
|
|
79
|
+
/** `active`: the wallet can run on pages served from this domain. */
|
|
80
|
+
status: 'active' | 'inactive';
|
|
81
|
+
/** Present while `inactive`: what the wallet's verification said, in Peable's words. */
|
|
82
|
+
status_details: {
|
|
83
|
+
error_message: string;
|
|
84
|
+
} | null;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* A web domain the merchant serves payment pages from (`pmd_…`), registered so
|
|
88
|
+
* Apple Pay and Google Pay run there. Peable's own hosted checkout needs none:
|
|
89
|
+
* its domain is Peable's.
|
|
90
|
+
*/
|
|
91
|
+
export interface PaymentMethodDomain {
|
|
92
|
+
id: string;
|
|
93
|
+
object: 'payment_method_domain';
|
|
94
|
+
livemode: boolean;
|
|
95
|
+
/** Lowercase hostname, no scheme, port or path. */
|
|
96
|
+
domain_name: string;
|
|
97
|
+
/** Whether wallets may run on it at all. */
|
|
98
|
+
enabled: boolean;
|
|
99
|
+
apple_pay: PaymentMethodDomainWalletStatus;
|
|
100
|
+
google_pay: PaymentMethodDomainWalletStatus;
|
|
101
|
+
created: number;
|
|
102
|
+
}
|
|
103
|
+
/** `POST /v1/payment_method_domains`. */
|
|
104
|
+
export interface CreatePaymentMethodDomainParams {
|
|
105
|
+
domain_name: string;
|
|
106
|
+
enabled?: boolean;
|
|
107
|
+
}
|
|
108
|
+
/** `POST /v1/payment_method_domains/:id`. */
|
|
109
|
+
export interface UpdatePaymentMethodDomainParams {
|
|
110
|
+
enabled?: boolean;
|
|
111
|
+
}
|
|
112
|
+
/** `GET /v1/payment_method_domains`. */
|
|
113
|
+
export interface ListPaymentMethodDomainsParams {
|
|
114
|
+
domain_name?: string;
|
|
115
|
+
enabled?: boolean;
|
|
116
|
+
}
|
|
@@ -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;
|