@agent-cards/sdk 0.21.0 → 0.23.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/CHANGELOG.md +87 -2
- package/PREFLIGHT.md +32 -0
- package/README.md +1177 -23
- package/dist/aci.d.ts +173 -0
- package/dist/aci.generated.d.ts +87 -0
- package/dist/aci.generated.js +306 -0
- package/dist/aci.js +371 -0
- package/dist/adyen-merchant-hosted.generated.d.ts +3 -3
- package/dist/adyen-merchant-hosted.generated.js +302 -56
- package/dist/agentcard.d.ts +9 -2
- package/dist/agentcard.js +4 -2
- package/dist/amadeus-checkout.generated.d.ts +57 -0
- package/dist/amadeus-checkout.generated.js +549 -0
- package/dist/amadeus.d.ts +41 -0
- package/dist/amadeus.js +81 -0
- package/dist/builtin-registry.generated.js +1 -1
- package/dist/card-endpoint-facts.d.ts +96 -0
- package/dist/card-endpoint-facts.js +275 -0
- package/dist/card-endpoint-page.d.ts +54 -0
- package/dist/card-endpoint-page.js +69 -0
- package/dist/card-endpoint.d.ts +298 -0
- package/dist/card-endpoint.js +438 -0
- package/dist/card-fields.generated.d.ts +5 -3
- package/dist/card-fields.generated.js +284 -7
- package/dist/cdp.d.ts +5 -1
- package/dist/cdp.js +1155 -141
- package/dist/client.d.ts +456 -20
- package/dist/client.js +1072 -104
- package/dist/creditguard.generated.d.ts +79 -0
- package/dist/creditguard.generated.js +662 -0
- package/dist/cse-body.js +11 -1
- package/dist/cybersource-flex.d.ts +30 -0
- package/dist/cybersource-flex.generated.d.ts +27 -1
- package/dist/cybersource-flex.generated.js +42 -2
- package/dist/cybersource-flex.js +46 -0
- package/dist/datatrans.d.ts +96 -0
- package/dist/datatrans.generated.d.ts +64 -0
- package/dist/datatrans.generated.js +426 -0
- package/dist/datatrans.js +178 -0
- package/dist/ekashu.d.ts +35 -0
- package/dist/ekashu.js +55 -0
- package/dist/elavon-converge.d.ts +37 -0
- package/dist/elavon-converge.generated.d.ts +49 -0
- package/dist/elavon-converge.generated.js +439 -0
- package/dist/elavon-converge.js +84 -0
- package/dist/eprotect.d.ts +152 -0
- package/dist/eprotect.generated.d.ts +77 -0
- package/dist/eprotect.generated.js +498 -0
- package/dist/eprotect.js +222 -0
- package/dist/hosted-form.d.ts +3 -2
- package/dist/hosted-form.js +3 -2
- package/dist/index.d.ts +17 -3
- package/dist/index.js +6 -1
- package/dist/juspay-gate.d.ts +82 -0
- package/dist/juspay-gate.js +126 -0
- package/dist/juspay.generated.d.ts +89 -0
- package/dist/juspay.generated.js +705 -0
- package/dist/lifecycle.d.ts +60 -6
- package/dist/lifecycle.js +122 -8
- package/dist/merchant-card-endpoints.generated.d.ts +122 -0
- package/dist/merchant-card-endpoints.generated.js +4261 -0
- package/dist/merchant-hosted.d.ts +4 -1
- package/dist/merchant-hosted.js +5 -2
- package/dist/merchant-session-probe.d.ts +48 -0
- package/dist/merchant-session-probe.js +53 -0
- package/dist/merchant-session.generated.d.ts +69 -0
- package/dist/merchant-session.generated.js +919 -0
- package/dist/payrails.d.ts +133 -0
- package/dist/payrails.generated.d.ts +73 -0
- package/dist/payrails.generated.js +596 -0
- package/dist/payrails.js +305 -0
- package/dist/pelecard.d.ts +32 -0
- package/dist/pelecard.generated.d.ts +32 -0
- package/dist/pelecard.generated.js +283 -0
- package/dist/pelecard.js +42 -0
- package/dist/pre-claim.d.ts +81 -2
- package/dist/pre-claim.js +1023 -5
- package/dist/preflight-catalog.json +2267 -288
- package/dist/preflight-schemas.json +183 -6
- package/dist/preflight.generated.d.ts +1 -1
- package/dist/preflight.generated.js +243 -4
- package/dist/preparation.d.ts +12 -3
- package/dist/preparation.js +63 -12
- package/dist/prepared-processor.d.ts +84 -5
- package/dist/prepared-processor.js +147 -6
- package/dist/primer.d.ts +53 -0
- package/dist/primer.generated.d.ts +38 -0
- package/dist/primer.generated.js +624 -0
- package/dist/primer.js +82 -0
- package/dist/registry.d.ts +100 -8
- package/dist/registry.js +85 -11
- package/dist/shiji-sts.d.ts +144 -0
- package/dist/shiji-sts.generated.d.ts +72 -0
- package/dist/shiji-sts.generated.js +913 -0
- package/dist/shiji-sts.js +222 -0
- package/dist/stripe-checkout.generated.d.ts +1 -1
- package/dist/stripe-checkout.generated.js +764 -9
- package/dist/stripe-setup.d.ts +16 -0
- package/dist/stripe-setup.js +61 -0
- package/dist/substitutions.generated.js +187 -29
- package/dist/verifone.d.ts +68 -0
- package/dist/verifone.generated.d.ts +51 -0
- package/dist/verifone.generated.js +1413 -0
- package/dist/verifone.js +119 -0
- package/dist/voice-types.d.ts +27 -0
- package/dist/voice.d.ts +6 -1
- package/dist/voice.js +6 -1
- package/dist/wspay.d.ts +41 -0
- package/dist/wspay.generated.d.ts +41 -0
- package/dist/wspay.generated.js +370 -0
- package/dist/wspay.js +65 -0
- package/examples/preflight/kernel-native/inventory.json +1 -1
- package/package.json +3 -3
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
// Generated from @agent-cards/payment-core. Do not edit.
|
|
3
|
-
// artifact-sha256:
|
|
3
|
+
// artifact-sha256: 5c2c8becc2301811aee1b42b47148039ab07c8854932a21e80687e18090f1a93
|
|
4
|
+
// src/card-number-key.js
|
|
5
|
+
var CARD_NUMBER_KEY = /^(number|card_number|cardnumber|cardNum|card_num|pan)$/i;
|
|
4
6
|
// src/json-path.js
|
|
5
7
|
var FORBIDDEN_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
6
8
|
function isPlainObject(v) {
|
|
@@ -24,10 +26,188 @@ function jsonAt(root, path) {
|
|
|
24
26
|
}
|
|
25
27
|
return { found: true, value: node };
|
|
26
28
|
}
|
|
29
|
+
// src/elavon-converge.js
|
|
30
|
+
var CONVERGE_PROCESS_URLS = /* @__PURE__ */ Object.freeze([
|
|
31
|
+
"https://api.convergepay.com/hosted-payments/service/payment/hpp/process",
|
|
32
|
+
"https://api.demo.convergepay.com/hosted-payments/service/payment/hpp/process"
|
|
33
|
+
]);
|
|
34
|
+
var TOP_LEVEL_KEYS = /* @__PURE__ */ Object.freeze(["paymentType", "paymentData", "context", "captchaToken", "shippingSameAsBilling"]);
|
|
35
|
+
var WALLET_FIELDS = /* @__PURE__ */ Object.freeze([
|
|
36
|
+
"ssl_ewallet",
|
|
37
|
+
"googlepay_authmethod",
|
|
38
|
+
"ssl_google_pay",
|
|
39
|
+
"ssl_applepay_web",
|
|
40
|
+
"ssl_dsrp_cryptogram",
|
|
41
|
+
"ssl_visapayload",
|
|
42
|
+
"ssl_ewallet_shipping"
|
|
43
|
+
]);
|
|
44
|
+
var SERVICE_FEE_FIELDS = /* @__PURE__ */ Object.freeze(["ssl_service_fee_agree", "ssl_service_fee_amount", "ssl_service_fee_percent"]);
|
|
45
|
+
var THREE_DS_FIELDS = /* @__PURE__ */ Object.freeze([
|
|
46
|
+
"ssl_transaction_type",
|
|
47
|
+
"ssl_eci_ind",
|
|
48
|
+
"ssl_3dsecure_value",
|
|
49
|
+
"ssl_dir_server_tran_id",
|
|
50
|
+
"ssl_xid",
|
|
51
|
+
"ssl_program_protocol"
|
|
52
|
+
]);
|
|
53
|
+
var THREE_DS_PREFIXES = /* @__PURE__ */ Object.freeze(["ssl_3ds_", "ssl_fsg_"]);
|
|
54
|
+
var SURCHARGE_FIELDS = /* @__PURE__ */ Object.freeze([
|
|
55
|
+
"ssl_credit_surcharge_agree",
|
|
56
|
+
"ssl_credit_surcharge_amount",
|
|
57
|
+
"bypass_credit_surcharge",
|
|
58
|
+
"ssl_amount_subtotal",
|
|
59
|
+
"ssl_total_amount",
|
|
60
|
+
"ssl_surcharge_fee_total"
|
|
61
|
+
]);
|
|
62
|
+
var RECURRING_FIELDS = /* @__PURE__ */ Object.freeze([
|
|
63
|
+
"recurring",
|
|
64
|
+
"installment",
|
|
65
|
+
"ssl_billing_cycle",
|
|
66
|
+
"ssl_next_payment_date",
|
|
67
|
+
"ssl_total_installments",
|
|
68
|
+
"ssl_skip_payment",
|
|
69
|
+
"ssl_recurring_id",
|
|
70
|
+
"ssl_recurring_batch_count",
|
|
71
|
+
"ssl_installment_id"
|
|
72
|
+
]);
|
|
73
|
+
var CARD_SAVING_FLAGS = /* @__PURE__ */ Object.freeze(["ssl_get_token", "ssl_add_token"]);
|
|
74
|
+
var CREDENTIAL_FIELDS = /* @__PURE__ */ Object.freeze(["ssl_account_id", "ssl_merchant_id", "ssl_user_id", "ssl_pin", "ssl_vendor_id"]);
|
|
75
|
+
var AMOUNT_ADD_ON_FIELDS = /* @__PURE__ */ Object.freeze(["ssl_tip_amount", "ssl_cashback_amount"]);
|
|
76
|
+
var CARD_NUMBER = /^\d{12,19}$/;
|
|
77
|
+
var EXPIRY_MMYY = /^(0[1-9]|1[0-2])\d{2}$/;
|
|
78
|
+
var CVC = /^\d{3,4}$/;
|
|
79
|
+
var AMOUNT = /^(\d{1,13})(?:\.(\d{1,2}))?$/;
|
|
80
|
+
var isRecord = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
81
|
+
var owns = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
82
|
+
var refuse = (code) => Object.freeze({ verdict: "refuse", code });
|
|
83
|
+
var CARD = /* @__PURE__ */ Object.freeze({ verdict: "card" });
|
|
84
|
+
var CONTINUE = /* @__PURE__ */ Object.freeze({ verdict: "continue" });
|
|
85
|
+
function parseConvergeBody(body) {
|
|
86
|
+
if (typeof body !== "string" || body === "" || body.length > 131072)
|
|
87
|
+
return null;
|
|
88
|
+
let parsed;
|
|
89
|
+
try {
|
|
90
|
+
parsed = JSON.parse(body);
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
if (!isRecord(parsed) || JSON.stringify(parsed) !== body)
|
|
96
|
+
return null;
|
|
97
|
+
return parsed;
|
|
98
|
+
}
|
|
99
|
+
function convergeAmountCents(value) {
|
|
100
|
+
const text = typeof value === "number" && Number.isFinite(value) ? String(value) : value;
|
|
101
|
+
const m = typeof text === "string" ? AMOUNT.exec(text) : null;
|
|
102
|
+
if (!m)
|
|
103
|
+
return null;
|
|
104
|
+
const cents = Number(m[1]) * 100 + Number(((m[2] ?? "") + "00").slice(0, 2));
|
|
105
|
+
return Number.isSafeInteger(cents) && cents > 0 ? cents : null;
|
|
106
|
+
}
|
|
107
|
+
function convergeBodyVerdict(body) {
|
|
108
|
+
const parsed = parseConvergeBody(body);
|
|
109
|
+
if (parsed === null || !Object.keys(parsed).every((key) => TOP_LEVEL_KEYS.includes(key)))
|
|
110
|
+
return refuse("converge_body_malformed");
|
|
111
|
+
const data = parsed.paymentData;
|
|
112
|
+
if (!isRecord(data))
|
|
113
|
+
return refuse("converge_body_malformed");
|
|
114
|
+
const type = parsed.paymentType;
|
|
115
|
+
if (type === "ELECTRONICCHECK" || type === "FINANCING") {
|
|
116
|
+
return owns(data, "ssl_card_number") ? refuse("converge_payment_type_refused") : CONTINUE;
|
|
117
|
+
}
|
|
118
|
+
if (type === "DEBITCARD") {
|
|
119
|
+
return refuse(typeof data.ssl_transaction_type === "string" && /DISBURSEMENT/i.test(data.ssl_transaction_type) ? "converge_push_to_card_refused" : "converge_debit_card_refused");
|
|
120
|
+
}
|
|
121
|
+
if (type === "GIFTCARD")
|
|
122
|
+
return refuse("converge_gift_card_refused");
|
|
123
|
+
if (type !== "CREDITCARD")
|
|
124
|
+
return refuse("converge_payment_type_refused");
|
|
125
|
+
const keys = Object.keys(data);
|
|
126
|
+
if (CREDENTIAL_FIELDS.some((key) => owns(data, key)))
|
|
127
|
+
return refuse("converge_credential_refused");
|
|
128
|
+
if (WALLET_FIELDS.some((key) => owns(data, key)))
|
|
129
|
+
return refuse("converge_wallet_refused");
|
|
130
|
+
if (owns(parsed, "captchaToken"))
|
|
131
|
+
return refuse("converge_captcha_refused");
|
|
132
|
+
if (SERVICE_FEE_FIELDS.some((key) => owns(data, key)))
|
|
133
|
+
return refuse("converge_service_fee_refused");
|
|
134
|
+
if (THREE_DS_FIELDS.some((key) => owns(data, key)) || keys.some((key) => THREE_DS_PREFIXES.some((prefix) => key.startsWith(prefix))))
|
|
135
|
+
return refuse("converge_3ds_follow_up_refused");
|
|
136
|
+
if (SURCHARGE_FIELDS.some((key) => owns(data, key)))
|
|
137
|
+
return refuse("converge_surcharge_refused");
|
|
138
|
+
if (AMOUNT_ADD_ON_FIELDS.some((key) => owns(data, key)))
|
|
139
|
+
return refuse("converge_amount_add_on_refused");
|
|
140
|
+
if (owns(data, "ssl_token") || CARD_SAVING_FLAGS.some((key) => owns(data, key) && !(typeof data[key] === "string" && /^n$/i.test(data[key])))) {
|
|
141
|
+
return refuse("converge_card_saving_refused");
|
|
142
|
+
}
|
|
143
|
+
if (RECURRING_FIELDS.some((key) => owns(data, key)))
|
|
144
|
+
return refuse("converge_recurring_refused");
|
|
145
|
+
if (owns(data, "ssl_transaction_currency") && !(typeof data.ssl_transaction_currency === "string" && /^usd$/i.test(data.ssl_transaction_currency))) {
|
|
146
|
+
return refuse("converge_currency_refused");
|
|
147
|
+
}
|
|
148
|
+
if (convergeAmountCents(data.ssl_amount) === null)
|
|
149
|
+
return refuse("converge_amount_missing");
|
|
150
|
+
if (typeof parsed.context !== "string" || parsed.context === "")
|
|
151
|
+
return refuse("converge_context_missing");
|
|
152
|
+
if (owns(parsed, "shippingSameAsBilling") && typeof parsed.shippingSameAsBilling !== "boolean")
|
|
153
|
+
return refuse("converge_body_malformed");
|
|
154
|
+
if (!owns(data, "ssl_card_number") || data.ssl_card_number === "" || data.ssl_card_number === null)
|
|
155
|
+
return refuse("converge_card_missing");
|
|
156
|
+
if (typeof data.ssl_card_number !== "string" || !CARD_NUMBER.test(data.ssl_card_number) || typeof data.ssl_exp_date !== "string" || !EXPIRY_MMYY.test(data.ssl_exp_date) || typeof data.ssl_cvv2cvc2 !== "string" || !CVC.test(data.ssl_cvv2cvc2))
|
|
157
|
+
return refuse("converge_card_malformed");
|
|
158
|
+
return CARD;
|
|
159
|
+
}
|
|
160
|
+
function isConvergeProcessUrl(url) {
|
|
161
|
+
if (typeof url !== "string")
|
|
162
|
+
return false;
|
|
163
|
+
let parsed;
|
|
164
|
+
try {
|
|
165
|
+
parsed = new URL(url);
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
return parsed.href === url && CONVERGE_PROCESS_URLS.includes(parsed.href);
|
|
171
|
+
}
|
|
172
|
+
// src/amadeus-body.js
|
|
173
|
+
var AMADEUS_CARD_MOPID = /^creditcard[0-9]*$/;
|
|
174
|
+
var record = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
175
|
+
var owns2 = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
176
|
+
var holdsPan = (mopdata) => record(mopdata) && owns2(mopdata, "pan") && mopdata.pan !== null && mopdata.pan !== "";
|
|
177
|
+
function amadeusBodyKind(body) {
|
|
178
|
+
let value;
|
|
179
|
+
try {
|
|
180
|
+
value = typeof body === "string" ? JSON.parse(body) : void 0;
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
return "card";
|
|
184
|
+
}
|
|
185
|
+
if (!record(value))
|
|
186
|
+
return "card";
|
|
187
|
+
if (value.action === "add") {
|
|
188
|
+
const entries = Array.isArray(value.data) ? value.data : [value.data];
|
|
189
|
+
return entries.some((entry) => record(entry) && typeof entry.mopid === "string" && AMADEUS_CARD_MOPID.test(entry.mopid) && holdsPan(entry.mopdata)) ? "card" : "other";
|
|
190
|
+
}
|
|
191
|
+
if (value.action === "store")
|
|
192
|
+
return record(value.data) && holdsPan(value.data.mopdata) ? "card" : "other";
|
|
193
|
+
return "other";
|
|
194
|
+
}
|
|
27
195
|
// src/card-fields.js
|
|
196
|
+
function processorGate(recognizer, url, body) {
|
|
197
|
+
if (!recognizer || recognizer.psp !== "elavon_converge")
|
|
198
|
+
return null;
|
|
199
|
+
if (url !== void 0 && !isConvergeProcessUrl(url))
|
|
200
|
+
return { verdict: "refuse", code: "converge_url_refused" };
|
|
201
|
+
return convergeBodyVerdict(body);
|
|
202
|
+
}
|
|
28
203
|
function carriesCardFields(recognizer, body) {
|
|
29
|
-
|
|
30
|
-
|
|
204
|
+
const gate = processorGate(recognizer, void 0, body);
|
|
205
|
+
if (gate !== null)
|
|
206
|
+
return gate.verdict === "card";
|
|
207
|
+
if (recognizer && recognizer.encoding === "json") {
|
|
208
|
+
const claimed = carriesJsonCardFields(recognizer.jsonCardFields, body, DECLARED_PATHS_ONLY.has(recognizer.psp));
|
|
209
|
+
return claimed && recognizer.psp === "amadeus_checkout" ? amadeusBodyKind(body) === "card" : claimed;
|
|
210
|
+
}
|
|
31
211
|
const fields = recognizer && recognizer.cardFields;
|
|
32
212
|
if (!Array.isArray(fields) || fields.length === 0)
|
|
33
213
|
return true;
|
|
@@ -35,6 +215,8 @@ function carriesCardFields(recognizer, body) {
|
|
|
35
215
|
return true;
|
|
36
216
|
if (typeof body !== "string" || body === "")
|
|
37
217
|
return false;
|
|
218
|
+
const anyCase = recognizer.caseInsensitiveFormKeys === true;
|
|
219
|
+
const wanted = anyCase ? fields.map((field) => String(field).toLowerCase()) : fields;
|
|
38
220
|
for (const chunk of body.split("&")) {
|
|
39
221
|
const eq = chunk.indexOf("=");
|
|
40
222
|
if (eq <= 0 || eq === chunk.length - 1)
|
|
@@ -46,14 +228,40 @@ function carriesCardFields(recognizer, body) {
|
|
|
46
228
|
catch {
|
|
47
229
|
continue;
|
|
48
230
|
}
|
|
49
|
-
if (
|
|
231
|
+
if (wanted.includes(anyCase ? key.trim().toLowerCase() : key))
|
|
50
232
|
return true;
|
|
51
233
|
}
|
|
52
234
|
return false;
|
|
53
235
|
}
|
|
54
|
-
|
|
236
|
+
var DECLARED_PATHS_ONLY = /* @__PURE__ */ new Set(["primer", "pelecard", "creditguard", "payrails"]);
|
|
237
|
+
function carriesJsonCardFields(paths, body, declaredOnly) {
|
|
55
238
|
if (!Array.isArray(paths) || paths.length === 0 || !paths.every((path) => isJsonPath(path) && path.length > 0))
|
|
56
239
|
return true;
|
|
240
|
+
if (declaredOnly)
|
|
241
|
+
return declaredPathHoldsCard(paths, body);
|
|
242
|
+
let parsed;
|
|
243
|
+
try {
|
|
244
|
+
parsed = typeof body === "string" ? JSON.parse(body) : void 0;
|
|
245
|
+
}
|
|
246
|
+
catch {
|
|
247
|
+
return true;
|
|
248
|
+
}
|
|
249
|
+
if (!isPlainObject(parsed))
|
|
250
|
+
return true;
|
|
251
|
+
if (paths.some((path) => {
|
|
252
|
+
const at = jsonAt(parsed, path);
|
|
253
|
+
return at.found && (typeof at.value === "string" && at.value !== "" || typeof at.value === "number");
|
|
254
|
+
}))
|
|
255
|
+
return true;
|
|
256
|
+
const declared = /* @__PURE__ */ new Set();
|
|
257
|
+
for (const path of paths) {
|
|
258
|
+
const last = path[path.length - 1];
|
|
259
|
+
if (typeof last === "string")
|
|
260
|
+
declared.add(last.toLowerCase());
|
|
261
|
+
}
|
|
262
|
+
return namesCardNumber(parsed, declared);
|
|
263
|
+
}
|
|
264
|
+
function declaredPathHoldsCard(paths, body) {
|
|
57
265
|
if (typeof body !== "string" || body === "")
|
|
58
266
|
return false;
|
|
59
267
|
let parsed;
|
|
@@ -68,9 +276,74 @@ function carriesJsonCardFields(paths, body) {
|
|
|
68
276
|
return at.found && (typeof at.value === "string" && at.value !== "" || typeof at.value === "number");
|
|
69
277
|
});
|
|
70
278
|
}
|
|
279
|
+
function namesCardNumber(root, declared) {
|
|
280
|
+
const pending = [root];
|
|
281
|
+
while (pending.length > 0) {
|
|
282
|
+
const node = pending.pop();
|
|
283
|
+
const named = !Array.isArray(node);
|
|
284
|
+
for (const key of Object.keys(node)) {
|
|
285
|
+
if (named) {
|
|
286
|
+
const name = key.slice(key.lastIndexOf(".") + 1).toLowerCase();
|
|
287
|
+
if (declared.has(name) || CARD_NUMBER_KEY.test(name) || name.endsWith("cardnumber"))
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
const value = node[key];
|
|
291
|
+
if (value !== null && typeof value === "object")
|
|
292
|
+
pending.push(value);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
function splitCardLeg(recognizer, body) {
|
|
298
|
+
const split = recognizer && recognizer.splitCard;
|
|
299
|
+
if (!split || typeof split !== "object" || recognizer.encoding !== "form")
|
|
300
|
+
return null;
|
|
301
|
+
if (typeof body !== "string" || body === "" || carriesCardFields(recognizer, body))
|
|
302
|
+
return null;
|
|
303
|
+
const list = (value) => Array.isArray(value) ? value.filter((key) => typeof key === "string" && key !== "") : [];
|
|
304
|
+
const absorb = list(split.absorb);
|
|
305
|
+
const pass = list(split.pass);
|
|
306
|
+
const sibling = list(split.siblingKeys);
|
|
307
|
+
const own = [];
|
|
308
|
+
const seen = /* @__PURE__ */ new Set();
|
|
309
|
+
for (const chunk of body.split("&")) {
|
|
310
|
+
const eq = chunk.indexOf("=");
|
|
311
|
+
if (eq <= 0)
|
|
312
|
+
return null;
|
|
313
|
+
let key;
|
|
314
|
+
try {
|
|
315
|
+
key = decodeURIComponent(chunk.slice(0, eq).replace(/\+/g, " "));
|
|
316
|
+
}
|
|
317
|
+
catch {
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
if (seen.has(key))
|
|
321
|
+
return null;
|
|
322
|
+
seen.add(key);
|
|
323
|
+
if (!sibling.includes(key))
|
|
324
|
+
own.push(key);
|
|
325
|
+
}
|
|
326
|
+
if (own.length === 0)
|
|
327
|
+
return null;
|
|
328
|
+
if (own.every((key) => absorb.includes(key)))
|
|
329
|
+
return "absorb";
|
|
330
|
+
if (own.every((key) => pass.includes(key)))
|
|
331
|
+
return "pass";
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
71
334
|
function requestWithoutCard(recognizer, url, body) {
|
|
72
|
-
|
|
335
|
+
const gate = processorGate(recognizer, url, body);
|
|
336
|
+
if (gate !== null) {
|
|
337
|
+
if (gate.verdict === "card")
|
|
338
|
+
return null;
|
|
339
|
+
if (gate.verdict === "refuse")
|
|
340
|
+
return "refuse";
|
|
341
|
+
}
|
|
342
|
+
else if (carriesCardFields(recognizer, body)) {
|
|
73
343
|
return null;
|
|
344
|
+
}
|
|
345
|
+
if (splitCardLeg(recognizer, body) === "pass")
|
|
346
|
+
return "continue";
|
|
74
347
|
const pass = recognizer && recognizer.passWithoutCard;
|
|
75
348
|
if (typeof pass === "string" && pass !== "") {
|
|
76
349
|
let parsed;
|
|
@@ -85,4 +358,8 @@ function requestWithoutCard(recognizer, url, body) {
|
|
|
85
358
|
}
|
|
86
359
|
return "refuse";
|
|
87
360
|
}
|
|
88
|
-
|
|
361
|
+
function cardRequestRefusal(recognizer, url, body) {
|
|
362
|
+
const gate = processorGate(recognizer, url, body);
|
|
363
|
+
return gate !== null && gate.verdict === "refuse" ? gate.code : null;
|
|
364
|
+
}
|
|
365
|
+
export { cardRequestRefusal, carriesCardFields, requestWithoutCard, splitCardLeg };
|
package/dist/cdp.d.ts
CHANGED
|
@@ -128,7 +128,9 @@ export interface AttachOptions extends LifecycleOptions, ExecutionMetadata {
|
|
|
128
128
|
* and is read right before the card is sent; a hint lets a bad purchase be
|
|
129
129
|
* refused the moment it opens, and one that disagrees with the processor is
|
|
130
130
|
* refused with nothing charged. Required for GMO, whose card token request
|
|
131
|
-
* names no amount
|
|
131
|
+
* names no amount, for Pelecard, whose submission names none either, and for
|
|
132
|
+
* WSPay, whose confirm names none: without it such a request fails with
|
|
133
|
+
* AmountRequiredError.
|
|
132
134
|
*/
|
|
133
135
|
amount?: number | string;
|
|
134
136
|
currency?: string;
|
|
@@ -139,6 +141,8 @@ export interface AttachOptions extends LifecycleOptions, ExecutionMetadata {
|
|
|
139
141
|
* (`{ amount: 4210, currency: 'usd' }`), read off the page however your
|
|
140
142
|
* page spells it; the adapters call it when a card request pauses, give it
|
|
141
143
|
* one second, and send nothing when it yields nothing. Absent: no page total.
|
|
144
|
+
* Required for Pelecard: a Pelecard submission with no page total fails with
|
|
145
|
+
* PageAmountRequiredError, and the page's next submission reads it again.
|
|
142
146
|
*/
|
|
143
147
|
pageAmount?: () => Promise<{
|
|
144
148
|
amount: number;
|