@pandait.tech/payment-nuvei 0.1.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 +211 -0
- package/dist/handlers/index.cjs +1671 -0
- package/dist/handlers/index.cjs.map +1 -0
- package/dist/handlers/index.d.cts +413 -0
- package/dist/handlers/index.d.ts +413 -0
- package/dist/handlers/index.js +1656 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/index.cjs +170 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +115 -0
- package/dist/index.d.ts +115 -0
- package/dist/index.js +157 -0
- package/dist/index.js.map +1 -0
- package/dist/payment-links/index.cjs +58 -0
- package/dist/payment-links/index.cjs.map +1 -0
- package/dist/payment-links/index.d.cts +60 -0
- package/dist/payment-links/index.d.ts +60 -0
- package/dist/payment-links/index.js +49 -0
- package/dist/payment-links/index.js.map +1 -0
- package/dist/ui/index.cjs +1236 -0
- package/dist/ui/index.cjs.map +1 -0
- package/dist/ui/index.d.cts +148 -0
- package/dist/ui/index.d.ts +148 -0
- package/dist/ui/index.js +1222 -0
- package/dist/ui/index.js.map +1 -0
- package/package.json +90 -0
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
+
import { Auth } from 'firebase-admin/auth';
|
|
3
|
+
import { Firestore } from 'firebase-admin/firestore';
|
|
4
|
+
|
|
5
|
+
/** Firestore document shape — handlers treat data as generic records. Consumer's onPaymentSucceeded callback gets the full doc and can cast to its own typed Order. */
|
|
6
|
+
type FirestoreData = Record<string, unknown>;
|
|
7
|
+
/** Order shape the handler reads/writes. Permissive on purpose — consumer extends. */
|
|
8
|
+
interface MinimalOrder extends FirestoreData {
|
|
9
|
+
id?: string;
|
|
10
|
+
status?: string;
|
|
11
|
+
userId?: string;
|
|
12
|
+
items?: Array<{
|
|
13
|
+
productId: string;
|
|
14
|
+
name: string;
|
|
15
|
+
price: number;
|
|
16
|
+
quantity: number;
|
|
17
|
+
}>;
|
|
18
|
+
total?: number;
|
|
19
|
+
subtotal?: number;
|
|
20
|
+
vat?: number;
|
|
21
|
+
discount?: number;
|
|
22
|
+
promotionId?: string;
|
|
23
|
+
couponCode?: string;
|
|
24
|
+
shippingAddress?: {
|
|
25
|
+
fullName?: string;
|
|
26
|
+
} & FirestoreData;
|
|
27
|
+
postPurchaseNote?: string;
|
|
28
|
+
paymentLinkId?: string;
|
|
29
|
+
tallerId?: string;
|
|
30
|
+
courseId?: string;
|
|
31
|
+
/** Set by charge.ts when the user opted out of saving the card AND the order
|
|
32
|
+
* enters an intermediate status (3ds-pending / otp-pending). The downstream
|
|
33
|
+
* handler that finalizes the payment (3ds-complete, webhook BY_CRES) reads
|
|
34
|
+
* these to call deleteCard on the SDK once the order transitions to paid. */
|
|
35
|
+
deleteCardAfterPayment?: boolean;
|
|
36
|
+
/** Nuvei card token. Persisted alongside deleteCardAfterPayment so the
|
|
37
|
+
* downstream handler can pass it to deleteCard(token, userId). */
|
|
38
|
+
paymentToken?: string;
|
|
39
|
+
}
|
|
40
|
+
/** Args passed to email.sendPaymentConfirmation. */
|
|
41
|
+
interface PaymentConfirmationArgs {
|
|
42
|
+
to: string;
|
|
43
|
+
customerName: string;
|
|
44
|
+
orderId: string;
|
|
45
|
+
transactionId: string;
|
|
46
|
+
authorizationCode: string;
|
|
47
|
+
items: MinimalOrder["items"];
|
|
48
|
+
subtotal: number;
|
|
49
|
+
discount?: number;
|
|
50
|
+
couponCode?: string;
|
|
51
|
+
vat: number;
|
|
52
|
+
total: number;
|
|
53
|
+
postPurchaseNote?: string;
|
|
54
|
+
}
|
|
55
|
+
/** Args passed to email.sendPaymentFailed. `retryUrl` is optional — consumers' email templates typically have their own absolute default (e.g. `https://shop.example.com/checkout`). If the handler's `getRetryUrl` dep is not configured, this field is omitted and the template default applies. */
|
|
56
|
+
interface PaymentFailedArgs {
|
|
57
|
+
to: string;
|
|
58
|
+
customerName: string;
|
|
59
|
+
orderId: string;
|
|
60
|
+
errorMessage: string;
|
|
61
|
+
items: MinimalOrder["items"];
|
|
62
|
+
total: number;
|
|
63
|
+
retryUrl?: string;
|
|
64
|
+
}
|
|
65
|
+
/** Args passed to email.sendPaymentPending (webhook fallback when auth_code missing). */
|
|
66
|
+
interface PaymentPendingArgs {
|
|
67
|
+
to: string;
|
|
68
|
+
customerName: string;
|
|
69
|
+
orderId: string;
|
|
70
|
+
transactionId: string;
|
|
71
|
+
items: MinimalOrder["items"];
|
|
72
|
+
subtotal: number;
|
|
73
|
+
discount?: number;
|
|
74
|
+
couponCode?: string;
|
|
75
|
+
vat: number;
|
|
76
|
+
total: number;
|
|
77
|
+
}
|
|
78
|
+
/** Email service contract — full surface used across all handlers. Each handler factory picks which methods it requires via Pick<>. */
|
|
79
|
+
interface EmailService {
|
|
80
|
+
sendPaymentConfirmation: (args: PaymentConfirmationArgs) => Promise<{
|
|
81
|
+
success: boolean;
|
|
82
|
+
}>;
|
|
83
|
+
sendPaymentFailed: (args: PaymentFailedArgs) => Promise<unknown>;
|
|
84
|
+
sendPaymentPending: (args: PaymentPendingArgs) => Promise<unknown>;
|
|
85
|
+
}
|
|
86
|
+
/** Firebase admin services the handler needs. */
|
|
87
|
+
interface FirebaseDeps {
|
|
88
|
+
db: Firestore;
|
|
89
|
+
auth: Auth;
|
|
90
|
+
}
|
|
91
|
+
/** Rate limit check. Returns true if allowed, false if rate-limited. */
|
|
92
|
+
type RateLimitFn = (key: string, limit: number, windowMs: number) => Promise<boolean>;
|
|
93
|
+
/** Turnstile (Cloudflare bot protection) verification. */
|
|
94
|
+
type TurnstileFn = (token: string, ip?: string) => Promise<{
|
|
95
|
+
success: boolean;
|
|
96
|
+
}>;
|
|
97
|
+
/** Pricing function — receives product data, returns the effective final subtotal. */
|
|
98
|
+
type GetPriceDisplayFn = (product: {
|
|
99
|
+
price: number;
|
|
100
|
+
autoDiscounts?: unknown;
|
|
101
|
+
}) => {
|
|
102
|
+
finalSubtotal: number;
|
|
103
|
+
};
|
|
104
|
+
/** Custom order validation result. Used for non-standard order flows (paymentLinks, talleres). */
|
|
105
|
+
type CustomOrderValidationResult = {
|
|
106
|
+
handled: false;
|
|
107
|
+
} | {
|
|
108
|
+
handled: true;
|
|
109
|
+
valid: true;
|
|
110
|
+
} | {
|
|
111
|
+
handled: true;
|
|
112
|
+
valid: false;
|
|
113
|
+
error: string;
|
|
114
|
+
status: number;
|
|
115
|
+
};
|
|
116
|
+
/** Custom order validator. Receives the order doc + amount; returns whether this is a custom-flow order and whether it's valid. */
|
|
117
|
+
type ValidateCustomOrderFn = (args: {
|
|
118
|
+
orderId: string;
|
|
119
|
+
orderData: MinimalOrder;
|
|
120
|
+
amount: number;
|
|
121
|
+
}) => Promise<CustomOrderValidationResult>;
|
|
122
|
+
|
|
123
|
+
/** Dependencies the charge handler factory needs. */
|
|
124
|
+
interface ChargeHandlerDeps {
|
|
125
|
+
/** Firebase Admin services. Provided by the consumer (so the package never owns its own Firebase init). */
|
|
126
|
+
firebase: FirebaseDeps;
|
|
127
|
+
/** Email service. Consumer wires up Resend (or any provider) with their own branding/templates. */
|
|
128
|
+
email: EmailService;
|
|
129
|
+
/** Pricing function — receives product fields and returns the effective final subtotal. Consumer-specific because pricing rules vary per business. */
|
|
130
|
+
getPriceDisplay: GetPriceDisplayFn;
|
|
131
|
+
/** Merchant name. Used as fallback for the Nuvei transaction description when the request body doesn't provide one (visible to the cardholder in their bank statement). */
|
|
132
|
+
merchantName: string;
|
|
133
|
+
/** Optional rate limit check. If omitted, no rate limiting is applied. */
|
|
134
|
+
rateLimit?: RateLimitFn;
|
|
135
|
+
/** Optional Turnstile (Cloudflare bot protection) verification. If omitted, the turnstileToken from the body is ignored. */
|
|
136
|
+
turnstile?: TurnstileFn;
|
|
137
|
+
/** Optional Cloud Functions base URL for the 3DS challenge callback (termUrl). If omitted, falls back to `process.env.CLOUD_FUNCTIONS_BASE_URL`. */
|
|
138
|
+
cloudFunctionsBaseUrl?: string;
|
|
139
|
+
/** Optional custom order validator — used for non-standard order flows (e.g. paymentLinks, taller-specific orders). If returned result is `{ handled: false }` the handler runs standard product/promotion validation. */
|
|
140
|
+
validateCustomOrder?: ValidateCustomOrderFn;
|
|
141
|
+
/** Optional post-success hook — runs after the order is marked paid and the Firestore batch commits. Use this for course enrollment, paymentLink usage tracking, fulfillment triggers, etc. Errors are caught and logged but don't fail the response. */
|
|
142
|
+
onPaymentSucceeded?: (order: MinimalOrder & {
|
|
143
|
+
id: string;
|
|
144
|
+
}) => Promise<void>;
|
|
145
|
+
/** Optional retry URL builder for payment-failed emails. Receives the order, returns the URL the customer should be sent to. Default: `https://${request.host}/checkout`. */
|
|
146
|
+
getRetryUrl?: (order: MinimalOrder & {
|
|
147
|
+
id: string;
|
|
148
|
+
}) => string;
|
|
149
|
+
/** Optional logger (defaults to console). */
|
|
150
|
+
logger?: Pick<Console, "log" | "error" | "warn">;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Creates a Next.js App Router POST handler for the `/api/payment/charge` endpoint.
|
|
154
|
+
*
|
|
155
|
+
* Performs: session verification, rate limiting, Turnstile, order/stock/price/coupon
|
|
156
|
+
* validation, Nuvei debit call, 3DS/OTP handling, Firestore order updates, email
|
|
157
|
+
* dispatch, and optional post-success side effects via `onPaymentSucceeded`.
|
|
158
|
+
*/
|
|
159
|
+
declare function createChargeHandler(deps: ChargeHandlerDeps): (request: NextRequest) => Promise<NextResponse<{
|
|
160
|
+
error: string;
|
|
161
|
+
}> | NextResponse<{
|
|
162
|
+
success: boolean;
|
|
163
|
+
transactionId: string;
|
|
164
|
+
authorizationCode: string | null;
|
|
165
|
+
orderId: string;
|
|
166
|
+
emailSent: boolean;
|
|
167
|
+
}> | NextResponse<{
|
|
168
|
+
review: boolean;
|
|
169
|
+
orderId: string;
|
|
170
|
+
transactionId: string;
|
|
171
|
+
}> | NextResponse<{
|
|
172
|
+
challenge: boolean;
|
|
173
|
+
challengeHtml: string;
|
|
174
|
+
isDeviceFingerprint: boolean;
|
|
175
|
+
orderId: string;
|
|
176
|
+
nuveiTransactionId: string;
|
|
177
|
+
statusDetail: number;
|
|
178
|
+
}> | NextResponse<{
|
|
179
|
+
otpRequired: boolean;
|
|
180
|
+
orderId: string;
|
|
181
|
+
nuveiTransactionId: string;
|
|
182
|
+
statusDetail: number;
|
|
183
|
+
}>>;
|
|
184
|
+
|
|
185
|
+
interface NuveiWebhookPayload {
|
|
186
|
+
transaction: {
|
|
187
|
+
id: string;
|
|
188
|
+
status: string;
|
|
189
|
+
status_detail: number;
|
|
190
|
+
dev_reference: string;
|
|
191
|
+
amount: number;
|
|
192
|
+
authorization_code: string | null;
|
|
193
|
+
message: string | null;
|
|
194
|
+
carrier_code: string | null;
|
|
195
|
+
};
|
|
196
|
+
user: {
|
|
197
|
+
id: string;
|
|
198
|
+
email: string;
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
/** Dependencies the webhook handler factory needs. */
|
|
202
|
+
interface WebhookHandlerDeps {
|
|
203
|
+
firebase: FirebaseDeps;
|
|
204
|
+
email: Pick<EmailService, "sendPaymentConfirmation" | "sendPaymentPending">;
|
|
205
|
+
/** Optional post-success hook. Fires when the webhook transitions an order to "paid" (either via direct status_detail=3 or via verify BY_CRES). Used for enrollment, fulfillment triggers, paymentLink usage tracking, etc. */
|
|
206
|
+
onPaymentSucceeded?: (order: MinimalOrder & {
|
|
207
|
+
id: string;
|
|
208
|
+
}) => Promise<void>;
|
|
209
|
+
/** Optional custom dev_reference handler. If the webhook's `transaction.dev_reference` matches a custom format (e.g. "pn_<id>" for Plan Novios), the consumer returns a NextResponse and the standard order flow is skipped. Return null to fall through to standard order processing. */
|
|
210
|
+
handleCustomDevReference?: (devReference: string, transaction: NuveiWebhookPayload["transaction"], payload: NuveiWebhookPayload) => Promise<NextResponse | null>;
|
|
211
|
+
logger?: Pick<Console, "log" | "error" | "warn">;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Creates a Next.js App Router POST handler for the Nuvei webhook callback.
|
|
215
|
+
* Reference: https://developers.paymentez.com/api/#webhook
|
|
216
|
+
*/
|
|
217
|
+
declare function createWebhookHandler(deps: WebhookHandlerDeps): (request: NextRequest) => Promise<NextResponse<unknown>>;
|
|
218
|
+
|
|
219
|
+
/** Dependencies the 3DS callback handler factory needs. */
|
|
220
|
+
interface ThreeDSCallbackHandlerDeps {
|
|
221
|
+
firebase: {
|
|
222
|
+
db: Firestore;
|
|
223
|
+
};
|
|
224
|
+
logger?: Pick<Console, "log" | "error" | "warn">;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Creates a Next.js App Router route module for the 3DS callback endpoint.
|
|
228
|
+
* Returns `{ POST, GET }` because the ACS may call either depending on bank/issuer.
|
|
229
|
+
*
|
|
230
|
+
* Usage:
|
|
231
|
+
* export const { POST, GET } = create3dsCallbackHandler({ firebase: { db } });
|
|
232
|
+
*/
|
|
233
|
+
declare function create3dsCallbackHandler(deps: ThreeDSCallbackHandlerDeps): {
|
|
234
|
+
POST: (request: NextRequest) => Promise<NextResponse<unknown>>;
|
|
235
|
+
GET: (request: NextRequest) => Promise<NextResponse<unknown>>;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
/** Dependencies the 3DS complete handler factory needs. */
|
|
239
|
+
interface ThreeDSCompleteHandlerDeps {
|
|
240
|
+
firebase: FirebaseDeps;
|
|
241
|
+
email: Pick<EmailService, "sendPaymentConfirmation" | "sendPaymentFailed">;
|
|
242
|
+
/** Optional post-success hook for consumer-specific side effects after verify succeeds. */
|
|
243
|
+
onPaymentSucceeded?: (order: MinimalOrder & {
|
|
244
|
+
id: string;
|
|
245
|
+
}) => Promise<void>;
|
|
246
|
+
/** Optional retry URL builder for payment-failed emails sent when 3DS verification fails or the auth status is rejected. If omitted, the consumer's email template default is used. */
|
|
247
|
+
getRetryUrl?: (order: MinimalOrder & {
|
|
248
|
+
id: string;
|
|
249
|
+
}) => string;
|
|
250
|
+
logger?: Pick<Console, "log" | "error" | "warn">;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Creates a Next.js App Router POST handler for the 3DS complete endpoint.
|
|
254
|
+
* Called by the client after challenge completion to finalize the payment.
|
|
255
|
+
*/
|
|
256
|
+
declare function create3dsCompleteHandler(deps: ThreeDSCompleteHandlerDeps): (request: NextRequest) => Promise<NextResponse<{
|
|
257
|
+
error: string;
|
|
258
|
+
}> | NextResponse<{
|
|
259
|
+
success: boolean;
|
|
260
|
+
transactionId: unknown;
|
|
261
|
+
authorizationCode: {} | null;
|
|
262
|
+
orderId: string;
|
|
263
|
+
}> | NextResponse<{
|
|
264
|
+
stillPending: boolean;
|
|
265
|
+
}> | NextResponse<{
|
|
266
|
+
challenge: boolean;
|
|
267
|
+
challengeHtml: string;
|
|
268
|
+
isDeviceFingerprint: boolean;
|
|
269
|
+
orderId: string;
|
|
270
|
+
nuveiTransactionId: {};
|
|
271
|
+
statusDetail: number;
|
|
272
|
+
}>>;
|
|
273
|
+
|
|
274
|
+
/** Dependencies the 3DS timeout handler factory needs. */
|
|
275
|
+
interface ThreeDSTimeoutHandlerDeps {
|
|
276
|
+
firebase: FirebaseDeps;
|
|
277
|
+
email: Pick<EmailService, "sendPaymentFailed">;
|
|
278
|
+
/** Optional retry URL builder. Default: "/checkout". */
|
|
279
|
+
getRetryUrl?: (order: MinimalOrder & {
|
|
280
|
+
id: string;
|
|
281
|
+
}) => string;
|
|
282
|
+
logger?: Pick<Console, "log" | "error" | "warn">;
|
|
283
|
+
}
|
|
284
|
+
declare function create3dsTimeoutHandler(deps: ThreeDSTimeoutHandlerDeps): (request: NextRequest) => Promise<NextResponse<{
|
|
285
|
+
error: string;
|
|
286
|
+
}> | NextResponse<{
|
|
287
|
+
alreadyResolved: boolean;
|
|
288
|
+
}> | NextResponse<{
|
|
289
|
+
ok: boolean;
|
|
290
|
+
}>>;
|
|
291
|
+
|
|
292
|
+
/** Dependencies the refund handler factory needs. */
|
|
293
|
+
interface RefundHandlerDeps {
|
|
294
|
+
firebase: FirebaseDeps;
|
|
295
|
+
/** Optional hook after a successful refund (e.g. revoke course access, send email). */
|
|
296
|
+
onRefundSucceeded?: (order: MinimalOrder & {
|
|
297
|
+
id: string;
|
|
298
|
+
}) => Promise<void>;
|
|
299
|
+
logger?: Pick<Console, "log" | "error" | "warn">;
|
|
300
|
+
}
|
|
301
|
+
declare function createRefundHandler(deps: RefundHandlerDeps): (request: NextRequest) => Promise<NextResponse<{
|
|
302
|
+
error: string;
|
|
303
|
+
}> | NextResponse<{
|
|
304
|
+
success: boolean;
|
|
305
|
+
detail: string;
|
|
306
|
+
}>>;
|
|
307
|
+
|
|
308
|
+
/** Dependencies the init-checkout handler factory needs. */
|
|
309
|
+
interface InitCheckoutHandlerDeps {
|
|
310
|
+
firebase: {
|
|
311
|
+
auth: Auth;
|
|
312
|
+
};
|
|
313
|
+
/** Default description shown to the customer in the Nuvei checkout if the request body doesn't provide one. Use the merchant name (e.g. "Pago Acme Shop"). */
|
|
314
|
+
defaultDescription: string;
|
|
315
|
+
/** Theme colors for the Nuvei checkout modal. */
|
|
316
|
+
themeColors: {
|
|
317
|
+
primary: string;
|
|
318
|
+
secondary: string;
|
|
319
|
+
};
|
|
320
|
+
logger?: Pick<Console, "log" | "error" | "warn">;
|
|
321
|
+
}
|
|
322
|
+
declare function createInitCheckoutHandler(deps: InitCheckoutHandlerDeps): (request: NextRequest) => Promise<NextResponse<{
|
|
323
|
+
error: string;
|
|
324
|
+
}> | NextResponse<{
|
|
325
|
+
reference: string;
|
|
326
|
+
checkoutUrl: string | undefined;
|
|
327
|
+
}>>;
|
|
328
|
+
|
|
329
|
+
/** Dependencies the cards handler factory needs. */
|
|
330
|
+
interface CardsHandlerDeps {
|
|
331
|
+
firebase: FirebaseDeps;
|
|
332
|
+
/** Whether to consult users/{uid}/verifiedCards to upgrade "review" status to "valid" client-side. Defaults to true. Set false if your client doesn't use the Diners/Pichincha verify flow. */
|
|
333
|
+
enableVerifiedCardsTracking?: boolean;
|
|
334
|
+
logger?: Pick<Console, "log" | "error" | "warn">;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Creates a Next.js App Router route module for the cards endpoint.
|
|
338
|
+
* Returns `{ GET, DELETE }` to be re-exported by the consumer's route.ts.
|
|
339
|
+
*
|
|
340
|
+
* Usage:
|
|
341
|
+
* export const { GET, DELETE } = createCardsHandler({ firebase: { db, auth } });
|
|
342
|
+
*/
|
|
343
|
+
declare function createCardsHandler(deps: CardsHandlerDeps): {
|
|
344
|
+
GET: (request: NextRequest) => Promise<NextResponse<{
|
|
345
|
+
error: string;
|
|
346
|
+
}> | NextResponse<{
|
|
347
|
+
cards: {
|
|
348
|
+
bin: string;
|
|
349
|
+
status: string;
|
|
350
|
+
token: string;
|
|
351
|
+
holder_name: string;
|
|
352
|
+
expiry_year: string;
|
|
353
|
+
expiry_month: string;
|
|
354
|
+
transaction_reference: string;
|
|
355
|
+
type: string;
|
|
356
|
+
number: string;
|
|
357
|
+
}[];
|
|
358
|
+
}>>;
|
|
359
|
+
DELETE: (request: NextRequest) => Promise<NextResponse<{
|
|
360
|
+
error: string;
|
|
361
|
+
}> | NextResponse<{
|
|
362
|
+
message: string;
|
|
363
|
+
}>>;
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
/** Dependencies the verify handler factory needs. */
|
|
367
|
+
interface VerifyHandlerDeps {
|
|
368
|
+
firebase: FirebaseDeps;
|
|
369
|
+
/** Whether to persist verification in users/{uid}/verifiedCards/{token}. Defaults to true. */
|
|
370
|
+
enableVerifiedCardsTracking?: boolean;
|
|
371
|
+
logger?: Pick<Console, "log" | "error" | "warn">;
|
|
372
|
+
}
|
|
373
|
+
declare function createVerifyHandler(deps: VerifyHandlerDeps): (request: NextRequest) => Promise<NextResponse<{
|
|
374
|
+
error: string;
|
|
375
|
+
}> | NextResponse<{
|
|
376
|
+
success: boolean;
|
|
377
|
+
transaction: {
|
|
378
|
+
status: string;
|
|
379
|
+
status_detail: number;
|
|
380
|
+
id: string;
|
|
381
|
+
message: string | null;
|
|
382
|
+
} | undefined;
|
|
383
|
+
}>>;
|
|
384
|
+
|
|
385
|
+
/** Dependencies the test-charge handler factory needs. */
|
|
386
|
+
interface TestChargeHandlerDeps {
|
|
387
|
+
firebase: {
|
|
388
|
+
auth: Auth;
|
|
389
|
+
};
|
|
390
|
+
/** Default description shown in Nuvei when the request body omits one. Defaults to "Test charge". */
|
|
391
|
+
defaultDescription?: string;
|
|
392
|
+
logger?: Pick<Console, "log" | "error" | "warn">;
|
|
393
|
+
}
|
|
394
|
+
declare function createTestChargeHandler(deps: TestChargeHandlerDeps): (request: NextRequest) => Promise<NextResponse<{
|
|
395
|
+
error: string;
|
|
396
|
+
}> | NextResponse<{
|
|
397
|
+
success: boolean;
|
|
398
|
+
transaction: {
|
|
399
|
+
status: string;
|
|
400
|
+
current_status: string;
|
|
401
|
+
id: string;
|
|
402
|
+
message: string | null;
|
|
403
|
+
status_detail: number;
|
|
404
|
+
authorization_code: string | null;
|
|
405
|
+
};
|
|
406
|
+
card: {
|
|
407
|
+
bin: string;
|
|
408
|
+
type: string;
|
|
409
|
+
number: string;
|
|
410
|
+
} | undefined;
|
|
411
|
+
}>>;
|
|
412
|
+
|
|
413
|
+
export { type CardsHandlerDeps, type ChargeHandlerDeps, type CustomOrderValidationResult, type EmailService, type FirebaseDeps, type FirestoreData, type GetPriceDisplayFn, type InitCheckoutHandlerDeps, type MinimalOrder, type PaymentConfirmationArgs, type PaymentFailedArgs, type PaymentPendingArgs, type RateLimitFn, type RefundHandlerDeps, type TestChargeHandlerDeps, type ThreeDSCallbackHandlerDeps, type ThreeDSCompleteHandlerDeps, type ThreeDSTimeoutHandlerDeps, type TurnstileFn, type ValidateCustomOrderFn, type VerifyHandlerDeps, type WebhookHandlerDeps, create3dsCallbackHandler, create3dsCompleteHandler, create3dsTimeoutHandler, createCardsHandler, createChargeHandler, createInitCheckoutHandler, createRefundHandler, createTestChargeHandler, createVerifyHandler, createWebhookHandler };
|