@agent-cards/checkout 0.19.0 → 0.22.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/README.md +6 -753
- package/cdp.d.ts +1 -0
- package/cdp.js +2 -0
- package/index.d.ts +1 -0
- package/index.js +2 -0
- package/package.json +33 -33
- package/playwright.d.ts +1 -0
- package/playwright.js +2 -0
- package/preflight.d.ts +1 -0
- package/preflight.js +2 -0
- package/CHANGELOG.md +0 -132
- package/PREFLIGHT.md +0 -312
- package/dist/adyen-merchant-hosted.generated.d.ts +0 -277
- package/dist/adyen-merchant-hosted.generated.js +0 -1902
- package/dist/adyen.generated.d.ts +0 -24
- package/dist/adyen.generated.js +0 -64
- package/dist/attachment.d.ts +0 -11
- package/dist/attachment.js +0 -50
- package/dist/braintree.d.ts +0 -2
- package/dist/braintree.generated.d.ts +0 -10
- package/dist/braintree.generated.js +0 -302
- package/dist/braintree.js +0 -2
- package/dist/builtin-registry.generated.d.ts +0 -2
- package/dist/builtin-registry.generated.js +0 -1
- package/dist/card-fields.generated.d.ts +0 -3
- package/dist/card-fields.generated.js +0 -46
- package/dist/cdp.d.ts +0 -192
- package/dist/cdp.js +0 -2393
- package/dist/checkout-com.generated.d.ts +0 -4
- package/dist/checkout-com.generated.js +0 -183
- package/dist/client.d.ts +0 -849
- package/dist/client.js +0 -1754
- package/dist/cse-body.d.ts +0 -25
- package/dist/cse-body.js +0 -41
- package/dist/fiserv.d.ts +0 -65
- package/dist/fiserv.generated.d.ts +0 -73
- package/dist/fiserv.generated.js +0 -830
- package/dist/fiserv.js +0 -104
- package/dist/hosted-form.d.ts +0 -44
- package/dist/hosted-form.js +0 -78
- package/dist/index.d.ts +0 -18
- package/dist/index.js +0 -10
- package/dist/lifecycle.d.ts +0 -179
- package/dist/lifecycle.js +0 -395
- package/dist/mercado-checkout.d.ts +0 -20
- package/dist/mercado-checkout.generated.d.ts +0 -52
- package/dist/mercado-checkout.generated.js +0 -198
- package/dist/mercado-checkout.js +0 -108
- package/dist/merchant-handoff.d.ts +0 -54
- package/dist/merchant-handoff.js +0 -100
- package/dist/merchant-hosted.d.ts +0 -140
- package/dist/merchant-hosted.js +0 -170
- package/dist/merchant-total-watch.d.ts +0 -115
- package/dist/merchant-total-watch.js +0 -268
- package/dist/merchant-total.d.ts +0 -257
- package/dist/merchant-total.js +0 -383
- package/dist/owned-shop.generated.d.ts +0 -24
- package/dist/owned-shop.generated.js +0 -108
- package/dist/paysafe.generated.d.ts +0 -12
- package/dist/paysafe.generated.js +0 -87
- package/dist/playwright.d.ts +0 -3
- package/dist/playwright.js +0 -3
- package/dist/pre-claim.d.ts +0 -123
- package/dist/pre-claim.js +0 -386
- package/dist/preflight-capabilities.generated.d.ts +0 -1253
- package/dist/preflight-capabilities.generated.js +0 -1929
- package/dist/preflight-catalog.json +0 -4727
- package/dist/preflight-playwright.d.ts +0 -34
- package/dist/preflight-playwright.js +0 -355
- package/dist/preflight-schemas.json +0 -1122
- package/dist/preflight.d.ts +0 -1
- package/dist/preflight.generated.d.ts +0 -1965
- package/dist/preflight.generated.js +0 -570
- package/dist/preflight.js +0 -2
- package/dist/preparation.d.ts +0 -38
- package/dist/preparation.js +0 -191
- package/dist/prepared-processor.d.ts +0 -43
- package/dist/prepared-processor.js +0 -172
- package/dist/recurly.generated.d.ts +0 -1
- package/dist/recurly.generated.js +0 -87
- package/dist/registry.d.ts +0 -121
- package/dist/registry.js +0 -310
- package/dist/spreedly.generated.d.ts +0 -10
- package/dist/spreedly.generated.js +0 -332
- package/dist/stripe-checkout.d.ts +0 -81
- package/dist/stripe-checkout.generated.d.ts +0 -82
- package/dist/stripe-checkout.generated.js +0 -1093
- package/dist/stripe-checkout.js +0 -140
- package/dist/substitute.d.ts +0 -38
- package/dist/substitute.js +0 -23
- package/dist/substitutions.generated.d.ts +0 -11
- package/dist/substitutions.generated.js +0 -818
- package/examples/existing-browser.mjs +0 -63
- package/examples/preflight/classify-direct.mjs +0 -21
- package/examples/preflight/classify-kernel.mjs +0 -30
- package/examples/preflight/inspect-browser.mjs +0 -44
- package/examples/preflight/kernel-native/README.md +0 -112
- package/examples/preflight/kernel-native/documented-adapters.json +0 -113
- package/examples/preflight/kernel-native/inventory.json +0 -233
- package/examples/preflight/kernel-native/qualification.mjs +0 -182
- package/examples/preflight/kernel-profile.empty.json +0 -11
- package/examples/preflight/mollie-hosted.observations.json +0 -23
- package/examples/preflight/mollie-hosted.result.json +0 -103
- package/examples/preflight/stripe-script.direct.result.json +0 -92
- package/examples/preflight/stripe-script.observations.json +0 -16
- package/examples/preflight/stripe-script.result.json +0 -87
package/dist/fiserv.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fiserv Commerce Hub card capture, as this SDK reads it.
|
|
3
|
-
*
|
|
4
|
-
* Every rule lives in the internal payment core (payment-core src/fiserv.js), vendored
|
|
5
|
-
* here as fiserv.generated.ts so the published package installs nothing else; the
|
|
6
|
-
* backend and the Vault load the same rules. That artifact is untyped JavaScript, so
|
|
7
|
-
* this module gives the adapters, the client and callers typed names for the parts the
|
|
8
|
-
* SDK uses, the way substitute.ts types the shared substitution. It adds no rule.
|
|
9
|
-
*
|
|
10
|
-
* The request is the Secure Data Capture frame's POST to Commerce Hub's card-capture
|
|
11
|
-
* endpoint. The frame encrypts the card the agent typed and posts the envelope as
|
|
12
|
-
* source.encryptionData; the cardholder's device builds the same envelope around the
|
|
13
|
-
* approved card under a key Agentcard pinned for the merchant, and the paused capture
|
|
14
|
-
* continues from the agent's browser with the envelope's four members swapped.
|
|
15
|
-
*/
|
|
16
|
-
import * as generated from './fiserv.generated.js';
|
|
17
|
-
const core = generated;
|
|
18
|
-
/** The card-capture endpoint per environment, exactly as the Secure Data Capture frame writes it. */
|
|
19
|
-
export const FISERV_CARD_CAPTURE_ENDPOINTS = core.FISERV_CARD_CAPTURE_ENDPOINTS;
|
|
20
|
-
const CAPTURE_HOSTS = new Set(Object.values(core.FISERV_CARD_CAPTURE_ENDPOINTS).map((endpoint) => new URL(endpoint).hostname));
|
|
21
|
-
/**
|
|
22
|
-
* Whether `url` is on one of the two card-capture hosts (connect.fiservapis.com and
|
|
23
|
-
* connect-cert.fiservapis.com), whatever its path or query. The registry's Fiserv
|
|
24
|
-
* recognizer lists exactly these hosts, so a card request on one of them is Fiserv's.
|
|
25
|
-
*/
|
|
26
|
-
export function isFiservCaptureHost(url) {
|
|
27
|
-
try {
|
|
28
|
-
return CAPTURE_HOSTS.has(new URL(url).hostname);
|
|
29
|
-
}
|
|
30
|
-
catch {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
/** The pinned key with this id, in either environment, or null. */
|
|
35
|
-
export function fiservKeyPinById(id) {
|
|
36
|
-
return typeof id === 'string' ? core.FISERV_KEY_PINS.find((pin) => pin.id === id) ?? null : null;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* The id of the pin a paused capture's card may be sealed under (its envelope's key,
|
|
40
|
-
* pinned for its endpoint's environment and for the merchant its body names), or null.
|
|
41
|
-
*/
|
|
42
|
-
export function fiservCapturePinId(url, body) {
|
|
43
|
-
return core.fiservCapturePin({ url, body })?.id ?? null;
|
|
44
|
-
}
|
|
45
|
-
/** The card-capture endpoint a Fiserv preparation names for its environment. */
|
|
46
|
-
export function fiservPreparationUrl(environment) {
|
|
47
|
-
return core.fiservPreparationUrl(environment);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Whether the SDK pauses this capture body for the cardholder, or refuses it when no
|
|
51
|
-
* preparation is ready: every body except the captures that carry no Vault card.
|
|
52
|
-
* Fastlane (PaymentToken), ACH (PaymentCheck), gift and EBT captures share the endpoint
|
|
53
|
-
* and continue untouched, each only in its exact source shape. A body not proven
|
|
54
|
-
* card-free (one the adapter could not read, one over 64 KiB, one that is not JSON, a
|
|
55
|
-
* PaymentCard with a plaintext card, a non-card type or category that also carries a card
|
|
56
|
-
* member) is judged as a card capture, so the agent's placeholder never continues to
|
|
57
|
-
* Fiserv on it.
|
|
58
|
-
*/
|
|
59
|
-
export function isFiservPausableBody(body) {
|
|
60
|
-
return core.isFiservPausableBody(body);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Whether this build pays the request only through a prepared checkout because it is
|
|
64
|
-
* Fiserv's: a recognizer named fiserv, or a request on one of Fiserv's capture hosts.
|
|
65
|
-
* The served entry says so too (preparationRequired); this build carries Fiserv's own
|
|
66
|
-
* rules, so it requires the preparation whatever the served registry says, and a
|
|
67
|
-
* registry that dropped the flag never opens an ordinary Fiserv authorization.
|
|
68
|
-
*/
|
|
69
|
-
export function requiresFiservPreparation(psp, url) {
|
|
70
|
-
return psp === 'fiserv' || isFiservCaptureHost(url);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Whether a paused request is the capture a Fiserv preparation for `environment`
|
|
74
|
-
* consents to: that environment's endpoint exactly, the capture rules on the whole
|
|
75
|
-
* request, headers included, and an envelope under a key pinned for that environment
|
|
76
|
-
* and for the merchant the body names.
|
|
77
|
-
*/
|
|
78
|
-
export function isPreparedFiservRequest(url, method, body, environment, headers) {
|
|
79
|
-
return core.isPreparedFiservRequest(url, method, body, environment, headers);
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Whether an approval's substitution is exactly Fiserv's envelope: `encoding` json,
|
|
83
|
-
* `at` source.encryptionData, the four members keyId, encryptedKey, encryptionBlock and
|
|
84
|
-
* aesIv in their exact shape under a pinned key, and nothing removed.
|
|
85
|
-
*/
|
|
86
|
-
export function isFiservSubstitution(sub) {
|
|
87
|
-
if (!sub || typeof sub !== 'object' || Array.isArray(sub))
|
|
88
|
-
return false;
|
|
89
|
-
const value = sub;
|
|
90
|
-
return Object.keys(value).every((name) => ['encoding', 'at', 'fields', 'remove'].includes(name))
|
|
91
|
-
&& value.encoding === 'json' && value.at === core.FISERV_SUBSTITUTION.at
|
|
92
|
-
&& (value.remove === undefined || (Array.isArray(value.remove) && value.remove.length === 0))
|
|
93
|
-
&& core.fiservSubstitutionFieldsRefusal(value.fields) === null;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* The paused Fiserv capture with the approval's envelope written over the four members
|
|
97
|
-
* its source.encryptionData already carries, and every other byte the frame's own. It
|
|
98
|
-
* throws, writing nothing, for a body that is not the capture Agentcard covers, for any
|
|
99
|
-
* substitution but Fiserv's envelope, and for an envelope under another key than the one
|
|
100
|
-
* the paused capture names. Run this on a Fiserv approval, never substituteEncryptedFields.
|
|
101
|
-
*/
|
|
102
|
-
export function substituteFiservEnvelope(body, sub) {
|
|
103
|
-
return core.substituteFiservEnvelope(body, sub);
|
|
104
|
-
}
|
package/dist/hosted-form.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The hosted_form half of a replay: what the paused navigation is resolved
|
|
3
|
-
* with once the cardholder's device has submitted the processor's own form.
|
|
4
|
-
*
|
|
5
|
-
* On a hosted-form processor (Tranzila) the paused request is a top-level
|
|
6
|
-
* form navigation inside the processor's iframe, not an XHR. The cardholder's
|
|
7
|
-
* device rebuilds that form with the real card and submits it itself, so the
|
|
8
|
-
* processor's answer (approved, declined) is shown on the device and reaches
|
|
9
|
-
* the merchant from the processor. The agent's browser never gets it.
|
|
10
|
-
*
|
|
11
|
-
* The paused navigation still has to resolve to SOMETHING. Aborting it is the
|
|
12
|
-
* wrong something: an aborted navigation renders no error page, the iframe
|
|
13
|
-
* silently stays on the dummy-card form, and the agent's natural next move is
|
|
14
|
-
* to click Pay again. A fake copy of the processor's result page is wrong too:
|
|
15
|
-
* this SDK does not know the outcome or the merchant's contract, so it must
|
|
16
|
-
* not claim one. What it CAN say is exactly what happened: the cardholder
|
|
17
|
-
* completed this payment on their own device, do not resubmit, confirm the
|
|
18
|
-
* order with the merchant. This page says that, for a person and for an
|
|
19
|
-
* agent, and nothing else.
|
|
20
|
-
*/
|
|
21
|
-
export interface HostedFormSubmittedPageInput {
|
|
22
|
-
/** The approved authorization (`cauth_…`). */
|
|
23
|
-
authorizationId: string;
|
|
24
|
-
/** The merchant name the authorization was created with. */
|
|
25
|
-
merchant: string;
|
|
26
|
-
/** When the device reported the form left it (ISO 8601). */
|
|
27
|
-
submittedAt: string;
|
|
28
|
-
}
|
|
29
|
-
export interface SyntheticPage {
|
|
30
|
-
status: 200;
|
|
31
|
-
headers: Record<string, string>;
|
|
32
|
-
body: string;
|
|
33
|
-
}
|
|
34
|
-
/** The outcome word on the page, the header and the JSON: one spelling everywhere. */
|
|
35
|
-
export declare const HOSTED_FORM_SUBMITTED_OUTCOME = "submitted_on_device";
|
|
36
|
-
/**
|
|
37
|
-
* A self-contained HTML document: no external resources, no script that runs
|
|
38
|
-
* (the one `<script>` is `application/json`, inert by type), machine-readable
|
|
39
|
-
* through the meta tag, the header and the JSON block, and human-readable in
|
|
40
|
-
* one paragraph. `merchant` is integrator text and lands escaped; inside the
|
|
41
|
-
* JSON every `<`, `>` and `&` is a \u escape (still valid JSON), so a merchant
|
|
42
|
-
* name can never close the script block early or open a comment inside it.
|
|
43
|
-
*/
|
|
44
|
-
export declare function hostedFormSubmittedPage(input: HostedFormSubmittedPageInput): SyntheticPage;
|
package/dist/hosted-form.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The hosted_form half of a replay: what the paused navigation is resolved
|
|
3
|
-
* with once the cardholder's device has submitted the processor's own form.
|
|
4
|
-
*
|
|
5
|
-
* On a hosted-form processor (Tranzila) the paused request is a top-level
|
|
6
|
-
* form navigation inside the processor's iframe, not an XHR. The cardholder's
|
|
7
|
-
* device rebuilds that form with the real card and submits it itself, so the
|
|
8
|
-
* processor's answer (approved, declined) is shown on the device and reaches
|
|
9
|
-
* the merchant from the processor. The agent's browser never gets it.
|
|
10
|
-
*
|
|
11
|
-
* The paused navigation still has to resolve to SOMETHING. Aborting it is the
|
|
12
|
-
* wrong something: an aborted navigation renders no error page, the iframe
|
|
13
|
-
* silently stays on the dummy-card form, and the agent's natural next move is
|
|
14
|
-
* to click Pay again. A fake copy of the processor's result page is wrong too:
|
|
15
|
-
* this SDK does not know the outcome or the merchant's contract, so it must
|
|
16
|
-
* not claim one. What it CAN say is exactly what happened: the cardholder
|
|
17
|
-
* completed this payment on their own device, do not resubmit, confirm the
|
|
18
|
-
* order with the merchant. This page says that, for a person and for an
|
|
19
|
-
* agent, and nothing else.
|
|
20
|
-
*/
|
|
21
|
-
/** The outcome word on the page, the header and the JSON: one spelling everywhere. */
|
|
22
|
-
export const HOSTED_FORM_SUBMITTED_OUTCOME = 'submitted_on_device';
|
|
23
|
-
function escapeHtml(s) {
|
|
24
|
-
return String(s)
|
|
25
|
-
.replace(/&/g, '&')
|
|
26
|
-
.replace(/</g, '<')
|
|
27
|
-
.replace(/>/g, '>')
|
|
28
|
-
.replace(/"/g, '"')
|
|
29
|
-
.replace(/'/g, ''');
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* A self-contained HTML document: no external resources, no script that runs
|
|
33
|
-
* (the one `<script>` is `application/json`, inert by type), machine-readable
|
|
34
|
-
* through the meta tag, the header and the JSON block, and human-readable in
|
|
35
|
-
* one paragraph. `merchant` is integrator text and lands escaped; inside the
|
|
36
|
-
* JSON every `<`, `>` and `&` is a \u escape (still valid JSON), so a merchant
|
|
37
|
-
* name can never close the script block early or open a comment inside it.
|
|
38
|
-
*/
|
|
39
|
-
export function hostedFormSubmittedPage(input) {
|
|
40
|
-
const merchant = String(input.merchant ?? '');
|
|
41
|
-
const record = {
|
|
42
|
-
outcome: HOSTED_FORM_SUBMITTED_OUTCOME,
|
|
43
|
-
// In words, so an agent reading this block cannot take it for a receipt:
|
|
44
|
-
// the cardholder's device attested the form left it, nothing more.
|
|
45
|
-
payment: 'unverified',
|
|
46
|
-
attested_by: 'cardholder_device',
|
|
47
|
-
authorization_id: String(input.authorizationId),
|
|
48
|
-
merchant,
|
|
49
|
-
submitted_at: String(input.submittedAt),
|
|
50
|
-
next: "poll the merchant's order state; never resubmit",
|
|
51
|
-
};
|
|
52
|
-
const json = JSON.stringify(record).replace(/</g, '\\u003c').replace(/>/g, '\\u003e').replace(/&/g, '\\u0026');
|
|
53
|
-
const body = [
|
|
54
|
-
'<!doctype html>',
|
|
55
|
-
'<html lang="en">',
|
|
56
|
-
'<head>',
|
|
57
|
-
'<meta charset="utf-8">',
|
|
58
|
-
`<meta name="agentcard-checkout" content="${HOSTED_FORM_SUBMITTED_OUTCOME}">`,
|
|
59
|
-
'<meta name="robots" content="noindex">',
|
|
60
|
-
'<title>Submitted on the cardholder\'s device</title>',
|
|
61
|
-
'</head>',
|
|
62
|
-
'<body>',
|
|
63
|
-
`<p>The cardholder submitted this payment from their own device. Agentcard holds no evidence of the processor's answer: this is not a receipt. Do not resubmit this form. Confirm the order with the merchant${merchant ? ` (${escapeHtml(merchant)})` : ''}.</p>`,
|
|
64
|
-
`<script type="application/json" id="agentcard-checkout">${json}</script>`,
|
|
65
|
-
'</body>',
|
|
66
|
-
'</html>',
|
|
67
|
-
'',
|
|
68
|
-
].join('\n');
|
|
69
|
-
return {
|
|
70
|
-
status: 200,
|
|
71
|
-
headers: {
|
|
72
|
-
'content-type': 'text/html; charset=utf-8',
|
|
73
|
-
'cache-control': 'no-store',
|
|
74
|
-
'x-agentcard-checkout': HOSTED_FORM_SUBMITTED_OUTCOME,
|
|
75
|
-
},
|
|
76
|
-
body,
|
|
77
|
-
};
|
|
78
|
-
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export { VaultClient, CardEncryptedError, UnsupportedModeError, PreparationRequiredError, ApprovalTimeoutError, ApprovalDeclinedError, AmountMismatchError, PresetRefusedError, PRESET_REFUSAL_REASONS, IntentNotConfirmableError, ProcessorRefusedError, CheckoutApiError, redactUrl, SUPPORTED_MODES, PaymentOutcomeUnknownError, CheckoutCancelledError, CheckoutPreparationError, AdyenTestPlatformRefusedError, MerchantTotalError, } from './client.js';
|
|
2
|
-
export type { PausedRequest, ReplayResponse, TokenReplay, CseReplay, MerchantHostedReplay, HostedFormReplay, AmountAuthority, AuthorizeInput, VaultClientOptions, AdyenTestPlatformRefusal, MerchantTotalRefusal, PrepareCheckoutOptions, PrepareCheckoutInput, PreparedCheckout, RazorpayProcessorError, RuntimeCancelReason, ExecutionMetadata, } from './client.js';
|
|
3
|
-
export { attachToCdp, attachToPlaywright, corsHeadersFor, corsDecision, withCorsHeaders } from './cdp.js';
|
|
4
|
-
export { CheckoutAttachmentError } from './attachment.js';
|
|
5
|
-
export type { CdpLike, AttachOptions, CorsOutcome } from './cdp.js';
|
|
6
|
-
export type { StripeCheckoutOptions, StripeCheckoutBlockedDetail, StripeCheckoutBlockStage, StripeCheckoutBlockReason } from './stripe-checkout.js';
|
|
7
|
-
export { substituteEncryptedFields, SubstitutionError } from './substitute.js';
|
|
8
|
-
export type { Substitutions } from './substitute.js';
|
|
9
|
-
export { classifyDeclaredMerchantRequest, classifyMerchantRequest, substituteMerchantHostedBody } from './merchant-hosted.js';
|
|
10
|
-
export type { MerchantProfile, MerchantProfileStatus, MerchantRequestVerdict, MerchantHostedSubstitutions, MerchantHostedFact, JsonPathStep, SandboxMerchantDeclaration } from './merchant-hosted.js';
|
|
11
|
-
export { MerchantExchangeLog, merchantAmountExchanges, merchantAmountFromResponses, merchantChargeReport, merchantProfilePricedBySource, merchantTotalAtRelease, MERCHANT_EXCHANGES_MAX, } from './merchant-total.js';
|
|
12
|
-
export type { MerchantAmountCard, MerchantExchange, MerchantRequestSeen, MerchantTotalApproved, MerchantTotalCapture, MerchantTotalScope } from './merchant-total.js';
|
|
13
|
-
export { substituteFiservEnvelope } from './fiserv.js';
|
|
14
|
-
export { hostedFormSubmittedPage, HOSTED_FORM_SUBMITTED_OUTCOME } from './hosted-form.js';
|
|
15
|
-
export type { HostedFormSubmittedPageInput, SyntheticPage } from './hosted-form.js';
|
|
16
|
-
export { BUILTIN_REGISTRY, cardUrlPatterns, findRecognizer } from './registry.js';
|
|
17
|
-
export type { Recognizer, CheckoutMode } from './registry.js';
|
|
18
|
-
export type { CheckoutController, CheckoutState, MerchantResult, MerchantPaymentConfirmation, UserAction, LifecycleOptions, PaymentEndpointGuard } from './lifecycle.js';
|
package/dist/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { VaultClient, CardEncryptedError, UnsupportedModeError, PreparationRequiredError, ApprovalTimeoutError, ApprovalDeclinedError, AmountMismatchError, PresetRefusedError, PRESET_REFUSAL_REASONS, IntentNotConfirmableError, ProcessorRefusedError, CheckoutApiError, redactUrl, SUPPORTED_MODES, PaymentOutcomeUnknownError, CheckoutCancelledError, CheckoutPreparationError, AdyenTestPlatformRefusedError, MerchantTotalError, } from './client.js';
|
|
2
|
-
export { attachToCdp, attachToPlaywright, corsHeadersFor, corsDecision, withCorsHeaders } from './cdp.js';
|
|
3
|
-
export { CheckoutAttachmentError } from './attachment.js';
|
|
4
|
-
export { substituteEncryptedFields, SubstitutionError } from './substitute.js';
|
|
5
|
-
export { classifyDeclaredMerchantRequest, classifyMerchantRequest, substituteMerchantHostedBody } from './merchant-hosted.js';
|
|
6
|
-
// The merchant's own total for a raw CDP runtime that intercepts on its own (merchant-total.ts).
|
|
7
|
-
export { MerchantExchangeLog, merchantAmountExchanges, merchantAmountFromResponses, merchantChargeReport, merchantProfilePricedBySource, merchantTotalAtRelease, MERCHANT_EXCHANGES_MAX, } from './merchant-total.js';
|
|
8
|
-
export { substituteFiservEnvelope } from './fiserv.js';
|
|
9
|
-
export { hostedFormSubmittedPage, HOSTED_FORM_SUBMITTED_OUTCOME } from './hosted-form.js';
|
|
10
|
-
export { BUILTIN_REGISTRY, cardUrlPatterns, findRecognizer } from './registry.js';
|
package/dist/lifecycle.d.ts
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { CheckoutPreparationError, type PrepareCheckoutOptions, type PreparedCheckout, type ReplayResponse } from './client.js';
|
|
2
|
-
import type { CheckoutMode } from './registry.js';
|
|
3
|
-
/** The application's resolver confirmed the payment for this checkout authorization. */
|
|
4
|
-
export interface MerchantPaymentConfirmation {
|
|
5
|
-
kind: 'merchant_payment';
|
|
6
|
-
authorizationId: string;
|
|
7
|
-
}
|
|
8
|
-
/** Only authoritative merchant evidence can confirm completion; a processor token is insufficient. */
|
|
9
|
-
export type MerchantResult = {
|
|
10
|
-
status: 'completed';
|
|
11
|
-
orderId: string;
|
|
12
|
-
confirmation?: never;
|
|
13
|
-
} | {
|
|
14
|
-
status: 'completed';
|
|
15
|
-
confirmation: MerchantPaymentConfirmation;
|
|
16
|
-
orderId?: never;
|
|
17
|
-
} | {
|
|
18
|
-
status: 'failed';
|
|
19
|
-
} | {
|
|
20
|
-
status: 'pending' | 'unknown';
|
|
21
|
-
} | {
|
|
22
|
-
status: 'requires_user_action';
|
|
23
|
-
reason: '3ds' | 'redirect' | 'other';
|
|
24
|
-
};
|
|
25
|
-
export interface CheckoutState {
|
|
26
|
-
status: 'idle' | 'awaiting_approval' | 'ready_to_submit' | 'awaiting_merchant' | 'requires_user_action' | 'completed' | 'declined' | 'timed_out' | 'cancelled' | 'unsupported' | 'outcome_unknown' | 'failed';
|
|
27
|
-
authorizationId: string | null;
|
|
28
|
-
preparationId?: string;
|
|
29
|
-
mode?: CheckoutMode;
|
|
30
|
-
orderId?: string;
|
|
31
|
-
confirmation?: MerchantPaymentConfirmation;
|
|
32
|
-
/** Stable SDK category; never includes a request body, processor response, or approval link. */
|
|
33
|
-
reason?: string;
|
|
34
|
-
}
|
|
35
|
-
export interface UserAction {
|
|
36
|
-
reason: 'approval' | '3ds' | 'redirect' | 'other';
|
|
37
|
-
authorizationId: string | null;
|
|
38
|
-
/** Sensitive approval capability. Deliver privately; do not put this in ordinary telemetry. */
|
|
39
|
-
approvalUrl?: string;
|
|
40
|
-
}
|
|
41
|
-
export interface LifecycleOptions {
|
|
42
|
-
onStateChange?: (state: Readonly<CheckoutState>) => void;
|
|
43
|
-
onUserAction?: (action: UserAction) => void | Promise<void>;
|
|
44
|
-
/** Read authoritative merchant payment or order state; do not click Pay or initiate a new charge here. */
|
|
45
|
-
resolveMerchantResult?: (state: Readonly<CheckoutState>) => Promise<MerchantResult>;
|
|
46
|
-
/** Hold further card requests after handoff until the merchant result is reconciled. Default false for compatibility. */
|
|
47
|
-
requireMerchantResult?: boolean;
|
|
48
|
-
}
|
|
49
|
-
export interface CheckoutController {
|
|
50
|
-
getState(): Readonly<CheckoutState>;
|
|
51
|
-
/** Await device consent before the caller starts the first native Pay action. One use per attachment. */
|
|
52
|
-
prepare(options: PrepareCheckoutOptions): Promise<PreparedCheckout>;
|
|
53
|
-
/** Stop locally and best-effort retire an unbound preparation. Does not cancel a processor payment. */
|
|
54
|
-
cancel(): void;
|
|
55
|
-
/** Ask the application's merchant resolver. A rejection records unknown; never automatically retries payment. */
|
|
56
|
-
reconcile(): Promise<Readonly<CheckoutState>>;
|
|
57
|
-
/** Signal an observed challenge; the SDK cannot detect every processor's 3DS UI. */
|
|
58
|
-
requestUserAction(reason: '3ds' | 'redirect' | 'other'): Promise<void>;
|
|
59
|
-
/** Start a new attempt after merchant-confirmed failure. Cancelled, completed and unbound Stripe-token attachments cannot reset. */
|
|
60
|
-
retryAfterMerchantFailure(result: {
|
|
61
|
-
status: 'failed';
|
|
62
|
-
}): void;
|
|
63
|
-
}
|
|
64
|
-
/** How many times one approval's card-free Stripe confirmation may be checked before it is simply held. */
|
|
65
|
-
export declare const MAX_STRIPE_CONTINUATION_CHECKS = 3;
|
|
66
|
-
/** Shared by the raw CDP and Playwright transports. No browser ownership or payment execution lives here. */
|
|
67
|
-
export declare class CheckoutLifecycle implements CheckoutController {
|
|
68
|
-
private readonly options;
|
|
69
|
-
private state;
|
|
70
|
-
private held;
|
|
71
|
-
private active;
|
|
72
|
-
private cancelled;
|
|
73
|
-
private merchantAborted;
|
|
74
|
-
private unboundStripeToken;
|
|
75
|
-
private stripeTokenPrepared;
|
|
76
|
-
private stripeContinuation;
|
|
77
|
-
private stripeContinuationChecks;
|
|
78
|
-
private ownedShopOrderId;
|
|
79
|
-
private reconciliation;
|
|
80
|
-
private preparationHandler?;
|
|
81
|
-
private preparationUsed;
|
|
82
|
-
readonly abort: AbortController;
|
|
83
|
-
constructor(options: LifecycleOptions);
|
|
84
|
-
getState(): Readonly<CheckoutState>;
|
|
85
|
-
setPreparationHandler(handler: (options: PrepareCheckoutOptions) => Promise<PreparedCheckout>): void;
|
|
86
|
-
prepare(options: PrepareCheckoutOptions): Promise<PreparedCheckout>;
|
|
87
|
-
preparing(): void;
|
|
88
|
-
preparationCreated(preparationId: string): void;
|
|
89
|
-
prepared(preparation: PreparedCheckout): void;
|
|
90
|
-
preparationFailed(error: CheckoutPreparationError): void;
|
|
91
|
-
isBlocked(): boolean;
|
|
92
|
-
isCancelled(): boolean;
|
|
93
|
-
begin(): void;
|
|
94
|
-
end(): void;
|
|
95
|
-
private set;
|
|
96
|
-
approvalCreated(authorizationId: string): void;
|
|
97
|
-
approvalUrl(approvalUrl: string): void;
|
|
98
|
-
private notify;
|
|
99
|
-
cancel(): void;
|
|
100
|
-
/** The exact browser request is gone; a late approval cannot reopen it. */
|
|
101
|
-
merchantRequestAborted(): void;
|
|
102
|
-
/**
|
|
103
|
-
* The page abandoned its card request (its own script timed out) while
|
|
104
|
-
* the cardholder is still deciding. The approval stays pending and the
|
|
105
|
-
* page's next matching request will be answered from it, so the status
|
|
106
|
-
* stays `awaiting_approval`; the reason says the page has to ask again.
|
|
107
|
-
* Not a hold: nothing is refused, and no card or token has moved.
|
|
108
|
-
*/
|
|
109
|
-
merchantRequestLost(): void;
|
|
110
|
-
/**
|
|
111
|
-
* The cardholder approved, and there is no live page request to hand the
|
|
112
|
-
* answer to: the page gave up on its own request while they decided.
|
|
113
|
-
* `ready_to_submit` is the state a prepared checkout uses for "consent in
|
|
114
|
-
* hand, click Pay": the application's next Pay action produces the request
|
|
115
|
-
* this approval answers, with no second prompt on the phone.
|
|
116
|
-
*/
|
|
117
|
-
awaitingMerchantRetry(authorizationId: string): void;
|
|
118
|
-
/**
|
|
119
|
-
* The page never asked again inside the retry wait and the API confirmed
|
|
120
|
-
* the approval is retired: `declined`, like any other approval that ended
|
|
121
|
-
* with nothing charged, and not held, because the next card request is a
|
|
122
|
-
* new question (the cardholder is told to ask their agent to try again).
|
|
123
|
-
* A retirement the API refused or did not confirm is an unknown outcome and
|
|
124
|
-
* is reported through failed() instead, which holds.
|
|
125
|
-
*/
|
|
126
|
-
merchantNeverRetried(authorizationId: string | null): void;
|
|
127
|
-
/**
|
|
128
|
-
* A card request this SDK cannot pay was aborted. `reason`: an unrecognized
|
|
129
|
-
* declared payment endpoint (the default), a merchant profile Agentcard has not
|
|
130
|
-
* turned on (merchant_profile_observe), or a card request the profile cannot
|
|
131
|
-
* finish (merchant_request_unsupported).
|
|
132
|
-
*/
|
|
133
|
-
unsupported(reason?: 'unrecognized_payment_endpoint' | 'merchant_profile_observe' | 'merchant_request_unsupported'): void;
|
|
134
|
-
/**
|
|
135
|
-
* A card request that only a prepared checkout pays (an Adyen merchant
|
|
136
|
-
* profile's, or a Fiserv card capture) arrived with no preparation on this
|
|
137
|
-
* attachment and was aborted before any pause, prompt or authorization.
|
|
138
|
-
* Nothing is outstanding, so nothing is held; prepare() stays refused here, as
|
|
139
|
-
* after any first card request.
|
|
140
|
-
*/
|
|
141
|
-
preparationRequired(): void;
|
|
142
|
-
prepareHandoff(replay: ReplayResponse, requestUrl: string): void;
|
|
143
|
-
/**
|
|
144
|
-
* The approval a page's card-free Stripe confirmation may continue, or null.
|
|
145
|
-
* Only once a Stripe tokenization is being handed to the page, and while
|
|
146
|
-
* the checkout still awaits it (the page can send its confirmation before
|
|
147
|
-
* the browser acknowledges the delivery) or the merchant; for one check at
|
|
148
|
-
* a time and at most MAX_STRIPE_CONTINUATION_CHECKS checks. Reserves the check synchronously,
|
|
149
|
-
* so two confirmations can never both continue: the caller settles it with
|
|
150
|
-
* stripeContinuationChecked(). The hold stays on throughout.
|
|
151
|
-
*/
|
|
152
|
-
claimStripeContinuation(): string | null;
|
|
153
|
-
/**
|
|
154
|
-
* Settle a claimed check. True only when the API allowed it and the checkout
|
|
155
|
-
* still awaits the merchant (nothing cancelled, aborted or reconciled it
|
|
156
|
-
* while the API answered): the page's confirmation continues, and no later
|
|
157
|
-
* one will.
|
|
158
|
-
*/
|
|
159
|
-
stripeContinuationChecked(allowed: boolean): boolean;
|
|
160
|
-
private stripeContinuationOpen;
|
|
161
|
-
handedOff(replay: ReplayResponse): void;
|
|
162
|
-
failed(error: unknown, handoffStarted?: boolean): void;
|
|
163
|
-
requestUserAction(reason: '3ds' | 'redirect' | 'other'): Promise<void>;
|
|
164
|
-
reconcile(): Promise<Readonly<CheckoutState>>;
|
|
165
|
-
private resolve;
|
|
166
|
-
retryAfterMerchantFailure(result: {
|
|
167
|
-
status: 'failed';
|
|
168
|
-
}): void;
|
|
169
|
-
}
|
|
170
|
-
/** Exact origin and path, supplied by the integrator after observing a payment endpoint. No query/body matching. */
|
|
171
|
-
export interface PaymentEndpointGuard {
|
|
172
|
-
origin: string;
|
|
173
|
-
pathname: string;
|
|
174
|
-
methods?: readonly string[];
|
|
175
|
-
}
|
|
176
|
-
export declare function paymentEndpointGuards(input?: readonly PaymentEndpointGuard[]): {
|
|
177
|
-
patterns: string[];
|
|
178
|
-
matches(url: string, method?: string): boolean;
|
|
179
|
-
};
|