@vesant-sdk/fraud 0.2.0-dev.2f18a76 → 0.2.0-dev.31d63f0
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 +4 -1
- package/dist/index.d.mts +6 -9
- package/dist/index.d.ts +6 -9
- package/dist/index.js +23 -73
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -72
- package/dist/index.mjs.map +1 -1
- package/package.json +50 -50
package/README.md
CHANGED
|
@@ -75,7 +75,7 @@ Prefer typed fields for common reserved keys. Typed fields win if the same key a
|
|
|
75
75
|
|-------|--------|
|
|
76
76
|
| `$login` | `ip_country_mismatch` (device/session signals are server-side — send `device_id` + `session_id`) |
|
|
77
77
|
| `$update_account` | `two_fa_enabled`, `two_fa_disabled`, `two_fa_method_changed`; send current `user_email`, `name`, `phone`, `billing_address`, `payment_methods` for server-side diff |
|
|
78
|
-
| `$transaction` | `payment_method
|
|
78
|
+
| `$transaction` | `payment_method` (a recognized payment type such as `$credit_card` — see [Payment method normalization](#payment-method-normalization)), deposit/withdrawal counters, timing fields — see `TransactionRuleSignals` |
|
|
79
79
|
|
|
80
80
|
Do **not** send `new_device_added`, `email_changed`, `customer_age_years`, or `kyc_status` — Vesant derives or ignores these server-side.
|
|
81
81
|
|
|
@@ -205,6 +205,9 @@ The SDK normalizes `payment_methods` and `payment_method_details` before wire em
|
|
|
205
205
|
| `account_number_last4` | Unknown field | Auto-mapped to `account_number_last5` |
|
|
206
206
|
| `account_id` on payment_method | Unknown field | Moved to `metadata.payment_method_account_id` |
|
|
207
207
|
| `wallet_address_last4` on payment_method | Unknown field | Moved to metadata |
|
|
208
|
+
| `payment_method: 'bank_account'` (rule signal) | Unrecognized payment type | Auto-mapped to `$electronic_fund_transfer` |
|
|
209
|
+
|
|
210
|
+
An unrecognized `payment_method` rule signal (for example `card`) is not fixed: the request throws `ValidationError`. This check also applies when `skip_payment_method_normalization` is set.
|
|
208
211
|
|
|
209
212
|
Inspect wire output before production:
|
|
210
213
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { RiskLevel, Timestamp, BaseClient, RequestOptions } from '@vesant-sdk/core';
|
|
1
|
+
import { PaymentTypeValue, RiskLevel, Timestamp, BaseClient, RequestOptions } from '@vesant-sdk/core';
|
|
2
|
+
export { normalizePaymentType } from '@vesant-sdk/core';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Fraud event type unions aligned with fraud-service support matrix.
|
|
@@ -25,10 +26,11 @@ type FraudEventType = SupportedFraudEventType | (typeof PLANNED_FRAUD_EVENT_TYPE
|
|
|
25
26
|
declare function isPlannedFraudEventType(eventType: string): eventType is (typeof PLANNED_FRAUD_EVENT_TYPES)[number];
|
|
26
27
|
declare function isSupportedFraudEventType(eventType: string): eventType is SupportedFraudEventType;
|
|
27
28
|
|
|
28
|
-
declare const TransactionTypeValues: readonly ["$sale", "$authorize", "$capture", "$void", "$refund", "$deposit", "$withdrawal", "$transfer", "$buy", "$sell", "$send", "$receive"];
|
|
29
29
|
/**
|
|
30
30
|
* Enum types and const objects for fraud scoring requests.
|
|
31
31
|
*/
|
|
32
|
+
|
|
33
|
+
declare const TransactionTypeValues: readonly ["$sale", "$authorize", "$capture", "$void", "$refund", "$deposit", "$withdrawal", "$transfer", "$buy", "$sell", "$send", "$receive"];
|
|
32
34
|
type TransactionType = '$sale' | '$authorize' | '$capture' | '$void' | '$refund' | '$deposit' | '$withdrawal' | '$transfer' | '$buy' | '$sell' | '$send' | '$receive';
|
|
33
35
|
declare const TransactionType: {
|
|
34
36
|
readonly Sale: "$sale";
|
|
@@ -105,7 +107,7 @@ declare const TransactionStatus: {
|
|
|
105
107
|
readonly Pending: "$pending";
|
|
106
108
|
};
|
|
107
109
|
declare const PaymentTypeValues: readonly ["$cash", "$check", "$credit_card", "$crypto_currency", "$debit_card", "$digital_wallet", "$electronic_fund_transfer", "$financing", "$gift_card", "$invoice", "$in_app_purchase", "$money_order", "$points", "$prepaid_card", "$store_credit", "$third_party_processor", "$voucher", "$sepa_credit", "$sepa_instant_credit", "$sepa_direct_debit", "$ach_credit", "$ach_debit", "$wire_credit", "$wire_debit"];
|
|
108
|
-
type PaymentType =
|
|
110
|
+
type PaymentType = PaymentTypeValue;
|
|
109
111
|
declare const PaymentType: {
|
|
110
112
|
readonly Cash: "$cash";
|
|
111
113
|
readonly Check: "$check";
|
|
@@ -510,11 +512,6 @@ declare function normalizeScoreRequestForApi(request: FraudScoreRequest): Record
|
|
|
510
512
|
*/
|
|
511
513
|
declare function buildScoreRequestPreview(request: FraudScoreRequest): Record<string, unknown>;
|
|
512
514
|
|
|
513
|
-
/**
|
|
514
|
-
* Maps tenant-internal payment type signals to valid $payment_type values.
|
|
515
|
-
* Returns undefined when the value cannot be mapped.
|
|
516
|
-
*/
|
|
517
|
-
declare function normalizePaymentType(value: string | undefined): PaymentType | undefined;
|
|
518
515
|
/**
|
|
519
516
|
* Normalizes last-4/last-5 account digits for $account_number_last5.
|
|
520
517
|
*/
|
|
@@ -535,4 +532,4 @@ declare function normalizePaymentMethods(methods: PaymentMethod[] | undefined):
|
|
|
535
532
|
metadata?: Record<string, unknown>;
|
|
536
533
|
};
|
|
537
534
|
|
|
538
|
-
export { type AppInfo, type BillingAddress, type BrowserInfo, CHARGEBACK_FRAUD_EVENT_TYPE, type ChargebackFraudEventType, ChargebackReason, ChargebackReasonValues, type ChargebackScoreRequest, type ChargebackScoreResponseData, ChargebackState, ChargebackStateValues, type CreateAccountScoreRequest, type CreateOrderScoreRequest, type FraudAlertCallbackEvent, type FraudCallbackTrigger, FraudClient, type FraudCustomMetadata, type FraudDecision, type FraudEventType, type FraudReactionType, type FraudRiskLevel, type FraudRuleSignalMetadata, type FraudScoreRequest, type FraudScoreRequestBase, type FraudScoreResponseData, type FraudScoreResponseEnvelope, type FraudScoreResponseMetadata, LOGIN_RULE_SIGNAL_KEYS, type LoginFailureReason, LoginFailureReasonValues, type LoginRuleSignals, type LoginScoreRequest, LoginStatus, LoginStatusValues, type LogoutScoreRequest, PLANNED_FRAUD_EVENT_TYPES, PasswordUpdateReason, PasswordUpdateReasonValues, PasswordUpdateStatus, PasswordUpdateStatusValues, type PaymentMethod, PaymentType, PaymentTypeValues, type PlannedFraudEventType, type ReservedMetadata, SCORED_FRAUD_EVENT_TYPES, SUPPORTED_FRAUD_EVENT_TYPES, type ScoredFraudEventType, type ScoredFraudScoreRequest, type SupportedFraudEventType, TRANSACTION_RULE_SIGNAL_KEYS, TYPED_METADATA_KEYS, type TenantAction, type TransactionRuleSignals, type TransactionScoreRequest, TransactionStatus, TransactionStatusValues, TransactionType, TransactionTypeValues, UPDATE_ACCOUNT_RULE_SIGNAL_KEYS, type UpdateAccountRuleSignals, type UpdateAccountScoreRequest, type UpdatePasswordScoreRequest, type WagerScoreRequest, WagerStatus, WagerStatusValues, WalletType, WalletTypeValues, buildScoreRequestPreview, findMetadataConflictWithTypedFields, isFraudAlertCallbackEvent, isPlannedFraudEventType, isSupportedFraudEventType, normalizePaymentMethod, normalizePaymentMethods,
|
|
535
|
+
export { type AppInfo, type BillingAddress, type BrowserInfo, CHARGEBACK_FRAUD_EVENT_TYPE, type ChargebackFraudEventType, ChargebackReason, ChargebackReasonValues, type ChargebackScoreRequest, type ChargebackScoreResponseData, ChargebackState, ChargebackStateValues, type CreateAccountScoreRequest, type CreateOrderScoreRequest, type FraudAlertCallbackEvent, type FraudCallbackTrigger, FraudClient, type FraudCustomMetadata, type FraudDecision, type FraudEventType, type FraudReactionType, type FraudRiskLevel, type FraudRuleSignalMetadata, type FraudScoreRequest, type FraudScoreRequestBase, type FraudScoreResponseData, type FraudScoreResponseEnvelope, type FraudScoreResponseMetadata, LOGIN_RULE_SIGNAL_KEYS, type LoginFailureReason, LoginFailureReasonValues, type LoginRuleSignals, type LoginScoreRequest, LoginStatus, LoginStatusValues, type LogoutScoreRequest, PLANNED_FRAUD_EVENT_TYPES, PasswordUpdateReason, PasswordUpdateReasonValues, PasswordUpdateStatus, PasswordUpdateStatusValues, type PaymentMethod, PaymentType, PaymentTypeValues, type PlannedFraudEventType, type ReservedMetadata, SCORED_FRAUD_EVENT_TYPES, SUPPORTED_FRAUD_EVENT_TYPES, type ScoredFraudEventType, type ScoredFraudScoreRequest, type SupportedFraudEventType, TRANSACTION_RULE_SIGNAL_KEYS, TYPED_METADATA_KEYS, type TenantAction, type TransactionRuleSignals, type TransactionScoreRequest, TransactionStatus, TransactionStatusValues, TransactionType, TransactionTypeValues, UPDATE_ACCOUNT_RULE_SIGNAL_KEYS, type UpdateAccountRuleSignals, type UpdateAccountScoreRequest, type UpdatePasswordScoreRequest, type WagerScoreRequest, WagerStatus, WagerStatusValues, WalletType, WalletTypeValues, buildScoreRequestPreview, findMetadataConflictWithTypedFields, isFraudAlertCallbackEvent, isPlannedFraudEventType, isSupportedFraudEventType, normalizePaymentMethod, normalizePaymentMethods, normalizeScoreRequestForApi, toAccountNumberLast5, validateScoreRequest };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { RiskLevel, Timestamp, BaseClient, RequestOptions } from '@vesant-sdk/core';
|
|
1
|
+
import { PaymentTypeValue, RiskLevel, Timestamp, BaseClient, RequestOptions } from '@vesant-sdk/core';
|
|
2
|
+
export { normalizePaymentType } from '@vesant-sdk/core';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Fraud event type unions aligned with fraud-service support matrix.
|
|
@@ -25,10 +26,11 @@ type FraudEventType = SupportedFraudEventType | (typeof PLANNED_FRAUD_EVENT_TYPE
|
|
|
25
26
|
declare function isPlannedFraudEventType(eventType: string): eventType is (typeof PLANNED_FRAUD_EVENT_TYPES)[number];
|
|
26
27
|
declare function isSupportedFraudEventType(eventType: string): eventType is SupportedFraudEventType;
|
|
27
28
|
|
|
28
|
-
declare const TransactionTypeValues: readonly ["$sale", "$authorize", "$capture", "$void", "$refund", "$deposit", "$withdrawal", "$transfer", "$buy", "$sell", "$send", "$receive"];
|
|
29
29
|
/**
|
|
30
30
|
* Enum types and const objects for fraud scoring requests.
|
|
31
31
|
*/
|
|
32
|
+
|
|
33
|
+
declare const TransactionTypeValues: readonly ["$sale", "$authorize", "$capture", "$void", "$refund", "$deposit", "$withdrawal", "$transfer", "$buy", "$sell", "$send", "$receive"];
|
|
32
34
|
type TransactionType = '$sale' | '$authorize' | '$capture' | '$void' | '$refund' | '$deposit' | '$withdrawal' | '$transfer' | '$buy' | '$sell' | '$send' | '$receive';
|
|
33
35
|
declare const TransactionType: {
|
|
34
36
|
readonly Sale: "$sale";
|
|
@@ -105,7 +107,7 @@ declare const TransactionStatus: {
|
|
|
105
107
|
readonly Pending: "$pending";
|
|
106
108
|
};
|
|
107
109
|
declare const PaymentTypeValues: readonly ["$cash", "$check", "$credit_card", "$crypto_currency", "$debit_card", "$digital_wallet", "$electronic_fund_transfer", "$financing", "$gift_card", "$invoice", "$in_app_purchase", "$money_order", "$points", "$prepaid_card", "$store_credit", "$third_party_processor", "$voucher", "$sepa_credit", "$sepa_instant_credit", "$sepa_direct_debit", "$ach_credit", "$ach_debit", "$wire_credit", "$wire_debit"];
|
|
108
|
-
type PaymentType =
|
|
110
|
+
type PaymentType = PaymentTypeValue;
|
|
109
111
|
declare const PaymentType: {
|
|
110
112
|
readonly Cash: "$cash";
|
|
111
113
|
readonly Check: "$check";
|
|
@@ -510,11 +512,6 @@ declare function normalizeScoreRequestForApi(request: FraudScoreRequest): Record
|
|
|
510
512
|
*/
|
|
511
513
|
declare function buildScoreRequestPreview(request: FraudScoreRequest): Record<string, unknown>;
|
|
512
514
|
|
|
513
|
-
/**
|
|
514
|
-
* Maps tenant-internal payment type signals to valid $payment_type values.
|
|
515
|
-
* Returns undefined when the value cannot be mapped.
|
|
516
|
-
*/
|
|
517
|
-
declare function normalizePaymentType(value: string | undefined): PaymentType | undefined;
|
|
518
515
|
/**
|
|
519
516
|
* Normalizes last-4/last-5 account digits for $account_number_last5.
|
|
520
517
|
*/
|
|
@@ -535,4 +532,4 @@ declare function normalizePaymentMethods(methods: PaymentMethod[] | undefined):
|
|
|
535
532
|
metadata?: Record<string, unknown>;
|
|
536
533
|
};
|
|
537
534
|
|
|
538
|
-
export { type AppInfo, type BillingAddress, type BrowserInfo, CHARGEBACK_FRAUD_EVENT_TYPE, type ChargebackFraudEventType, ChargebackReason, ChargebackReasonValues, type ChargebackScoreRequest, type ChargebackScoreResponseData, ChargebackState, ChargebackStateValues, type CreateAccountScoreRequest, type CreateOrderScoreRequest, type FraudAlertCallbackEvent, type FraudCallbackTrigger, FraudClient, type FraudCustomMetadata, type FraudDecision, type FraudEventType, type FraudReactionType, type FraudRiskLevel, type FraudRuleSignalMetadata, type FraudScoreRequest, type FraudScoreRequestBase, type FraudScoreResponseData, type FraudScoreResponseEnvelope, type FraudScoreResponseMetadata, LOGIN_RULE_SIGNAL_KEYS, type LoginFailureReason, LoginFailureReasonValues, type LoginRuleSignals, type LoginScoreRequest, LoginStatus, LoginStatusValues, type LogoutScoreRequest, PLANNED_FRAUD_EVENT_TYPES, PasswordUpdateReason, PasswordUpdateReasonValues, PasswordUpdateStatus, PasswordUpdateStatusValues, type PaymentMethod, PaymentType, PaymentTypeValues, type PlannedFraudEventType, type ReservedMetadata, SCORED_FRAUD_EVENT_TYPES, SUPPORTED_FRAUD_EVENT_TYPES, type ScoredFraudEventType, type ScoredFraudScoreRequest, type SupportedFraudEventType, TRANSACTION_RULE_SIGNAL_KEYS, TYPED_METADATA_KEYS, type TenantAction, type TransactionRuleSignals, type TransactionScoreRequest, TransactionStatus, TransactionStatusValues, TransactionType, TransactionTypeValues, UPDATE_ACCOUNT_RULE_SIGNAL_KEYS, type UpdateAccountRuleSignals, type UpdateAccountScoreRequest, type UpdatePasswordScoreRequest, type WagerScoreRequest, WagerStatus, WagerStatusValues, WalletType, WalletTypeValues, buildScoreRequestPreview, findMetadataConflictWithTypedFields, isFraudAlertCallbackEvent, isPlannedFraudEventType, isSupportedFraudEventType, normalizePaymentMethod, normalizePaymentMethods,
|
|
535
|
+
export { type AppInfo, type BillingAddress, type BrowserInfo, CHARGEBACK_FRAUD_EVENT_TYPE, type ChargebackFraudEventType, ChargebackReason, ChargebackReasonValues, type ChargebackScoreRequest, type ChargebackScoreResponseData, ChargebackState, ChargebackStateValues, type CreateAccountScoreRequest, type CreateOrderScoreRequest, type FraudAlertCallbackEvent, type FraudCallbackTrigger, FraudClient, type FraudCustomMetadata, type FraudDecision, type FraudEventType, type FraudReactionType, type FraudRiskLevel, type FraudRuleSignalMetadata, type FraudScoreRequest, type FraudScoreRequestBase, type FraudScoreResponseData, type FraudScoreResponseEnvelope, type FraudScoreResponseMetadata, LOGIN_RULE_SIGNAL_KEYS, type LoginFailureReason, LoginFailureReasonValues, type LoginRuleSignals, type LoginScoreRequest, LoginStatus, LoginStatusValues, type LogoutScoreRequest, PLANNED_FRAUD_EVENT_TYPES, PasswordUpdateReason, PasswordUpdateReasonValues, PasswordUpdateStatus, PasswordUpdateStatusValues, type PaymentMethod, PaymentType, PaymentTypeValues, type PlannedFraudEventType, type ReservedMetadata, SCORED_FRAUD_EVENT_TYPES, SUPPORTED_FRAUD_EVENT_TYPES, type ScoredFraudEventType, type ScoredFraudScoreRequest, type SupportedFraudEventType, TRANSACTION_RULE_SIGNAL_KEYS, TYPED_METADATA_KEYS, type TenantAction, type TransactionRuleSignals, type TransactionScoreRequest, TransactionStatus, TransactionStatusValues, TransactionType, TransactionTypeValues, UPDATE_ACCOUNT_RULE_SIGNAL_KEYS, type UpdateAccountRuleSignals, type UpdateAccountScoreRequest, type UpdatePasswordScoreRequest, type WagerScoreRequest, WagerStatus, WagerStatusValues, WalletType, WalletTypeValues, buildScoreRequestPreview, findMetadataConflictWithTypedFields, isFraudAlertCallbackEvent, isPlannedFraudEventType, isSupportedFraudEventType, normalizePaymentMethod, normalizePaymentMethods, normalizeScoreRequestForApi, toAccountNumberLast5, validateScoreRequest };
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
var core = require('@vesant-sdk/core');
|
|
4
4
|
|
|
5
5
|
// src/client.ts
|
|
6
|
-
|
|
7
|
-
// src/types/enums.ts
|
|
8
6
|
var TransactionTypeValues = [
|
|
9
7
|
"$sale",
|
|
10
8
|
"$authorize",
|
|
@@ -121,32 +119,7 @@ var TransactionStatus = {
|
|
|
121
119
|
Failure: "$failure",
|
|
122
120
|
Pending: "$pending"
|
|
123
121
|
};
|
|
124
|
-
var PaymentTypeValues =
|
|
125
|
-
"$cash",
|
|
126
|
-
"$check",
|
|
127
|
-
"$credit_card",
|
|
128
|
-
"$crypto_currency",
|
|
129
|
-
"$debit_card",
|
|
130
|
-
"$digital_wallet",
|
|
131
|
-
"$electronic_fund_transfer",
|
|
132
|
-
"$financing",
|
|
133
|
-
"$gift_card",
|
|
134
|
-
"$invoice",
|
|
135
|
-
"$in_app_purchase",
|
|
136
|
-
"$money_order",
|
|
137
|
-
"$points",
|
|
138
|
-
"$prepaid_card",
|
|
139
|
-
"$store_credit",
|
|
140
|
-
"$third_party_processor",
|
|
141
|
-
"$voucher",
|
|
142
|
-
"$sepa_credit",
|
|
143
|
-
"$sepa_instant_credit",
|
|
144
|
-
"$sepa_direct_debit",
|
|
145
|
-
"$ach_credit",
|
|
146
|
-
"$ach_debit",
|
|
147
|
-
"$wire_credit",
|
|
148
|
-
"$wire_debit"
|
|
149
|
-
];
|
|
122
|
+
var PaymentTypeValues = core.PAYMENT_TYPE_VALUES;
|
|
150
123
|
var PaymentType = {
|
|
151
124
|
Cash: "$cash",
|
|
152
125
|
Check: "$check",
|
|
@@ -201,35 +174,6 @@ var TRANSACTION_RULE_SIGNAL_KEYS = [
|
|
|
201
174
|
"days_since_last_activity",
|
|
202
175
|
"hours_since_account_creation"
|
|
203
176
|
];
|
|
204
|
-
|
|
205
|
-
// src/normalization/payment-methods.ts
|
|
206
|
-
var PAYMENT_TYPE_ALIASES = {
|
|
207
|
-
bank_account: "$electronic_fund_transfer",
|
|
208
|
-
electronic_fund_transfer: "$electronic_fund_transfer",
|
|
209
|
-
credit_card: "$credit_card",
|
|
210
|
-
crypto_currency: "$crypto_currency",
|
|
211
|
-
debit_card: "$debit_card",
|
|
212
|
-
digital_wallet: "$digital_wallet",
|
|
213
|
-
cash: "$cash",
|
|
214
|
-
check: "$check",
|
|
215
|
-
financing: "$financing",
|
|
216
|
-
gift_card: "$gift_card",
|
|
217
|
-
invoice: "$invoice",
|
|
218
|
-
in_app_purchase: "$in_app_purchase",
|
|
219
|
-
money_order: "$money_order",
|
|
220
|
-
points: "$points",
|
|
221
|
-
prepaid_card: "$prepaid_card",
|
|
222
|
-
store_credit: "$store_credit",
|
|
223
|
-
third_party_processor: "$third_party_processor",
|
|
224
|
-
voucher: "$voucher",
|
|
225
|
-
sepa_credit: "$sepa_credit",
|
|
226
|
-
sepa_instant_credit: "$sepa_instant_credit",
|
|
227
|
-
sepa_direct_debit: "$sepa_direct_debit",
|
|
228
|
-
ach_credit: "$ach_credit",
|
|
229
|
-
ach_debit: "$ach_debit",
|
|
230
|
-
wire_credit: "$wire_credit",
|
|
231
|
-
wire_debit: "$wire_debit"
|
|
232
|
-
};
|
|
233
177
|
var PAYMENT_METHOD_FIELD_WHITELIST = /* @__PURE__ */ new Set([
|
|
234
178
|
"payment_type",
|
|
235
179
|
"payment_gateway",
|
|
@@ -278,19 +222,6 @@ function warnDeprecatedKey(key) {
|
|
|
278
222
|
console.warn(message);
|
|
279
223
|
}
|
|
280
224
|
}
|
|
281
|
-
function normalizePaymentType(value) {
|
|
282
|
-
if (value === void 0 || value === null) return void 0;
|
|
283
|
-
const trimmed = String(value).trim();
|
|
284
|
-
if (trimmed === "") return void 0;
|
|
285
|
-
const normalized = trimmed.startsWith("$") ? trimmed.slice(1) : trimmed;
|
|
286
|
-
const alias = PAYMENT_TYPE_ALIASES[normalized.toLowerCase()];
|
|
287
|
-
if (alias) return alias;
|
|
288
|
-
const withPrefix = `$${normalized}`;
|
|
289
|
-
if (PaymentTypeValues.includes(withPrefix)) {
|
|
290
|
-
return withPrefix;
|
|
291
|
-
}
|
|
292
|
-
return void 0;
|
|
293
|
-
}
|
|
294
225
|
function toAccountNumberLast5(value) {
|
|
295
226
|
if (value === void 0 || value === null) return void 0;
|
|
296
227
|
const digits = String(value).replace(/\D/g, "");
|
|
@@ -306,7 +237,7 @@ function normalizePaymentMethod(raw) {
|
|
|
306
237
|
const metadataExtras = {};
|
|
307
238
|
const method = {};
|
|
308
239
|
const rawPaymentType = raw.payment_type !== void 0 ? String(raw.payment_type) : raw.$payment_type !== void 0 ? String(raw.$payment_type) : void 0;
|
|
309
|
-
const normalizedType = normalizePaymentType(rawPaymentType);
|
|
240
|
+
const normalizedType = core.normalizePaymentType(rawPaymentType);
|
|
310
241
|
if (rawPaymentType !== void 0 && normalizedType === void 0) {
|
|
311
242
|
return null;
|
|
312
243
|
}
|
|
@@ -572,6 +503,9 @@ function buildBaseReservedMetadata(body) {
|
|
|
572
503
|
}
|
|
573
504
|
function normalizeBaseReservedFields(body) {
|
|
574
505
|
const reservedMetadata = buildBaseReservedMetadata(body);
|
|
506
|
+
if (typeof reservedMetadata.payment_method === "string") {
|
|
507
|
+
reservedMetadata.payment_method = core.normalizePaymentType(reservedMetadata.payment_method) ?? reservedMetadata.payment_method;
|
|
508
|
+
}
|
|
575
509
|
const stripped = stripSdkOnlyFields(body, [...BASE_RESERVED_FIELD_KEYS]);
|
|
576
510
|
if ("user_reference" in stripped) {
|
|
577
511
|
stripped[WIRE_USER_REFERENCE_KEY] = stripped.user_reference;
|
|
@@ -842,7 +776,7 @@ function validatePaymentMethods(request, errors, prefix) {
|
|
|
842
776
|
}
|
|
843
777
|
}
|
|
844
778
|
const rawType2 = raw.payment_type !== void 0 ? String(raw.payment_type) : void 0;
|
|
845
|
-
if (rawType2 !== void 0 && normalizePaymentType(rawType2) === void 0) {
|
|
779
|
+
if (rawType2 !== void 0 && core.normalizePaymentType(rawType2) === void 0) {
|
|
846
780
|
errors.push(
|
|
847
781
|
`${prefix}payment_methods[${index}].payment_type is not a recognized payment type`
|
|
848
782
|
);
|
|
@@ -860,11 +794,23 @@ function validatePaymentMethods(request, errors, prefix) {
|
|
|
860
794
|
}
|
|
861
795
|
});
|
|
862
796
|
}
|
|
797
|
+
function validatePaymentMethodSignal(value, field, errors, prefix) {
|
|
798
|
+
if (value === void 0) return;
|
|
799
|
+
if (typeof value !== "string" || core.normalizePaymentType(value) === void 0) {
|
|
800
|
+
errors.push(`${prefix}${field} is not a recognized payment type`);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
863
803
|
function validateBase(request, errors, prefix) {
|
|
864
804
|
assertNonEmpty(request.customer_id, "customer_id", errors, prefix);
|
|
865
805
|
assertNonEmpty(request.user_reference, "user_reference", errors, prefix);
|
|
866
806
|
assertNonEmpty(request.event_type, "event_type", errors, prefix);
|
|
867
807
|
validateMetadata(request.metadata, request, errors, prefix);
|
|
808
|
+
validatePaymentMethodSignal(
|
|
809
|
+
request.metadata?.payment_method,
|
|
810
|
+
"metadata.payment_method",
|
|
811
|
+
errors,
|
|
812
|
+
prefix
|
|
813
|
+
);
|
|
868
814
|
}
|
|
869
815
|
function validateLogin(request, errors, prefix) {
|
|
870
816
|
assertEnum(request.login_status, LoginStatusValues, "login_status", errors, prefix);
|
|
@@ -909,6 +855,7 @@ function validateTransaction(request, errors, prefix) {
|
|
|
909
855
|
errors,
|
|
910
856
|
prefix
|
|
911
857
|
);
|
|
858
|
+
validatePaymentMethodSignal(request.payment_method, "payment_method", errors, prefix);
|
|
912
859
|
if (request.decline_category !== void 0 && request.transaction_status !== "$failure") {
|
|
913
860
|
errors.push(
|
|
914
861
|
`${prefix}decline_category is only allowed when transaction_status is '$failure'`
|
|
@@ -1067,6 +1014,10 @@ function isFraudAlertCallbackEvent(value) {
|
|
|
1067
1014
|
return typeof value === "object" && value !== null && value.event_type === "fraud.alert.callback";
|
|
1068
1015
|
}
|
|
1069
1016
|
|
|
1017
|
+
Object.defineProperty(exports, "normalizePaymentType", {
|
|
1018
|
+
enumerable: true,
|
|
1019
|
+
get: function () { return core.normalizePaymentType; }
|
|
1020
|
+
});
|
|
1070
1021
|
exports.CHARGEBACK_FRAUD_EVENT_TYPE = CHARGEBACK_FRAUD_EVENT_TYPE;
|
|
1071
1022
|
exports.ChargebackReason = ChargebackReason;
|
|
1072
1023
|
exports.ChargebackReasonValues = ChargebackReasonValues;
|
|
@@ -1104,7 +1055,6 @@ exports.isPlannedFraudEventType = isPlannedFraudEventType;
|
|
|
1104
1055
|
exports.isSupportedFraudEventType = isSupportedFraudEventType;
|
|
1105
1056
|
exports.normalizePaymentMethod = normalizePaymentMethod;
|
|
1106
1057
|
exports.normalizePaymentMethods = normalizePaymentMethods;
|
|
1107
|
-
exports.normalizePaymentType = normalizePaymentType;
|
|
1108
1058
|
exports.normalizeScoreRequestForApi = normalizeScoreRequestForApi;
|
|
1109
1059
|
exports.toAccountNumberLast5 = toAccountNumberLast5;
|
|
1110
1060
|
exports.validateScoreRequest = validateScoreRequest;
|