@sikka/aps 0.0.1

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.
@@ -0,0 +1,932 @@
1
+ import React, { ReactNode } from 'react';
2
+
3
+ /**
4
+ * APS Provider - React Context for Amazon Payment Services
5
+ *
6
+ * Provides the APS client instance to all child components via React Context.
7
+ * This enables the useAPS, useCheckout, and usePayment hooks throughout your app.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * // app/layout.tsx or app/providers.tsx
12
+ * import { APSProvider } from '@sikka/aps/react';
13
+ * import APS from '@sikka/aps';
14
+ *
15
+ * const aps = new APS({
16
+ * merchantId: process.env.APS_MERCHANT_ID!,
17
+ * accessCode: process.env.APS_ACCESS_CODE!,
18
+ * requestSecret: process.env.APS_REQUEST_SECRET!,
19
+ * responseSecret: process.env.APS_RESPONSE_SECRET!,
20
+ * environment: 'sandbox'
21
+ * });
22
+ *
23
+ * export default function Providers({ children }: { children: React.ReactNode }) {
24
+ * return (
25
+ * <APSProvider client={aps}>
26
+ * {children}
27
+ * </APSProvider>
28
+ * );
29
+ * }
30
+ * ```
31
+ */
32
+
33
+ /**
34
+ * Interface describing the APS client instance
35
+ * This matches the shape of the APSClient class from the main package
36
+ */
37
+ interface APSClientInstance$1 {
38
+ /** Payment Links module */
39
+ readonly paymentLinks: any;
40
+ /** Hosted Checkout module */
41
+ readonly hostedCheckout: any;
42
+ /** Custom Payment Page module */
43
+ readonly customPaymentPage: any;
44
+ /** Tokenization module */
45
+ readonly tokens: any;
46
+ /** Payments module (capture, refund, void) */
47
+ readonly payments: any;
48
+ /** Webhooks module */
49
+ readonly webhooks: any;
50
+ /** Recurring payments module */
51
+ readonly recurring: any;
52
+ /** Configuration */
53
+ readonly config: any;
54
+ /** Client options */
55
+ readonly options: any;
56
+ }
57
+ /**
58
+ * Props for APSProvider
59
+ */
60
+ interface APSProviderProps {
61
+ /** The APS client instance - create with new APS(config) */
62
+ client: APSClientInstance$1;
63
+ /** Child components */
64
+ children: ReactNode;
65
+ }
66
+ /**
67
+ * APS Provider Component
68
+ *
69
+ * Wrap your app with this provider to make the APS client available
70
+ * to all child components via hooks.
71
+ */
72
+ declare const APSProvider: React.FC<APSProviderProps>;
73
+
74
+ /**
75
+ * useAPS Hook
76
+ *
77
+ * Access the APS client instance from anywhere in your React component tree.
78
+ * Must be used within an APSProvider.
79
+ *
80
+ * @example
81
+ * ```tsx
82
+ * import { useAPS } from '@sikka/aps/react';
83
+ *
84
+ * function PaymentComponent() {
85
+ * const aps = useAPS();
86
+ *
87
+ * const handleCreatePaymentLink = async () => {
88
+ * const link = await aps.paymentLinks.create({
89
+ * order: {
90
+ * id: 'order_123',
91
+ * amount: 10000,
92
+ * currency: 'SAR'
93
+ * }
94
+ * });
95
+ * console.log(link.url);
96
+ * };
97
+ *
98
+ * return <button onClick={handleCreatePaymentLink}>Create Link</button>;
99
+ * }
100
+ * ```
101
+ */
102
+ /**
103
+ * Interface describing the APS client instance
104
+ * This matches the shape of the APSClient class from the main package
105
+ */
106
+ interface APSClientInstance {
107
+ /** Payment Links module */
108
+ readonly paymentLinks: any;
109
+ /** Hosted Checkout module */
110
+ readonly hostedCheckout: any;
111
+ /** Custom Payment Page module */
112
+ readonly customPaymentPage: any;
113
+ /** Tokenization module */
114
+ readonly tokens: any;
115
+ /** Payments module (capture, refund, void) */
116
+ readonly payments: any;
117
+ /** Webhooks module */
118
+ readonly webhooks: any;
119
+ /** Recurring payments module */
120
+ readonly recurring: any;
121
+ /** Configuration */
122
+ readonly config: any;
123
+ /** Client options */
124
+ readonly options: any;
125
+ }
126
+ /**
127
+ * Hook to access the APS client instance
128
+ *
129
+ * @returns The APS client instance with all modules (paymentLinks, hostedCheckout, tokens, etc.)
130
+ * @throws Error if used outside of APSProvider
131
+ *
132
+ * @example
133
+ * ```tsx
134
+ * const aps = useAPS();
135
+ *
136
+ * // Access any module
137
+ * await aps.paymentLinks.create({ ... });
138
+ * await aps.hostedCheckout.create({ ... });
139
+ * await aps.tokens.create({ ... });
140
+ * await aps.payments.capture({ ... });
141
+ * ```
142
+ */
143
+ declare function useAPS(): APSClientInstance;
144
+
145
+ /**
146
+ * Payment method types supported by APS
147
+ */
148
+ type PaymentMethod = 'card' | 'apple_pay' | 'mada' | 'stc_pay' | 'knet' | 'naps' | 'fawry' | 'meeza' | 'sadad' | 'aman';
149
+ /**
150
+ * Transaction status
151
+ */
152
+ type TransactionStatus = 'pending' | 'authorized' | 'captured' | 'failed' | 'voided' | 'refunded' | 'cancelled';
153
+ /**
154
+ * Customer information
155
+ */
156
+ interface Customer {
157
+ /** Customer email */
158
+ email?: string;
159
+ /** Customer name */
160
+ name?: string;
161
+ /** Customer phone */
162
+ phone?: string;
163
+ /** Billing address */
164
+ billingAddress?: {
165
+ street?: string;
166
+ city?: string;
167
+ state?: string;
168
+ country?: string;
169
+ postalCode?: string;
170
+ };
171
+ }
172
+ /**
173
+ * Order/Transaction details
174
+ */
175
+ interface Order {
176
+ /** Unique order ID (merchant generated) */
177
+ id: string;
178
+ /** Amount in minor units (e.g., cents) */
179
+ amount: number;
180
+ /** Currency code */
181
+ currency: string;
182
+ /** Order description */
183
+ description?: string;
184
+ /** Customer information */
185
+ customer?: Customer;
186
+ /** Metadata for the order */
187
+ metadata?: Record<string, string>;
188
+ }
189
+ /**
190
+ * Payment link options
191
+ */
192
+ interface PaymentLinkOptions {
193
+ /** Order details */
194
+ order: Order;
195
+ /** Payment methods to allow */
196
+ allowedPaymentMethods?: PaymentMethod[];
197
+ /** URL to redirect after successful payment */
198
+ successUrl?: string;
199
+ /** URL to redirect after failed payment */
200
+ failureUrl?: string;
201
+ /** URL to redirect after user cancels */
202
+ cancelUrl?: string;
203
+ /** Enable recurring payments */
204
+ recurring?: boolean;
205
+ /** Token validity in hours */
206
+ tokenValidityHours?: number;
207
+ /** Additional parameters */
208
+ metadata?: Record<string, string>;
209
+ }
210
+ /**
211
+ * Hosted checkout options
212
+ */
213
+ interface HostedCheckoutOptions {
214
+ /** Order details */
215
+ order: Order;
216
+ /** Payment methods to allow */
217
+ allowedPaymentMethods?: PaymentMethod[];
218
+ /** URL to redirect after successful payment */
219
+ successUrl?: string;
220
+ /** URL to redirect after failed payment */
221
+ failureUrl?: string;
222
+ /** URL to redirect after user cancels */
223
+ cancelUrl?: string;
224
+ /** Hide shipping information */
225
+ hideShipping?: boolean;
226
+ /** Additional parameters */
227
+ metadata?: Record<string, string>;
228
+ }
229
+ /**
230
+ * Custom payment page options
231
+ */
232
+ interface CustomPaymentPageOptions {
233
+ /** Order details */
234
+ order: Order;
235
+ /** Payment method to use */
236
+ paymentMethod: PaymentMethod;
237
+ /** Card token (if using tokenization) */
238
+ cardToken?: string;
239
+ /** 3DS return URL */
240
+ returnUrl?: string;
241
+ /** Enable 3DS authentication */
242
+ enable3DS?: boolean;
243
+ /** Additional parameters */
244
+ metadata?: Record<string, string>;
245
+ }
246
+ /**
247
+ * Payment response
248
+ */
249
+ interface PaymentResponse {
250
+ /** Transaction ID */
251
+ transactionId: string;
252
+ /** Order ID */
253
+ orderId: string;
254
+ /** Transaction status */
255
+ status: TransactionStatus;
256
+ /** Amount */
257
+ amount: number;
258
+ /** Currency */
259
+ currency: string;
260
+ /** Payment method used */
261
+ paymentMethod?: string;
262
+ /** 3DS URL (if authentication required) */
263
+ authenticationUrl?: string;
264
+ /** Form data for redirect (if applicable) */
265
+ redirectForm?: {
266
+ url: string;
267
+ method: 'POST' | 'GET';
268
+ params: Record<string, string>;
269
+ };
270
+ /** Error message if failed */
271
+ message?: string;
272
+ /** Raw APS response */
273
+ rawResponse: Record<string, any>;
274
+ }
275
+ /**
276
+ * Payment link response
277
+ */
278
+ interface PaymentLinkResponse {
279
+ /** Payment link URL */
280
+ url: string;
281
+ /** Link ID */
282
+ linkId: string;
283
+ /** Order ID */
284
+ orderId: string;
285
+ /** Expiry date */
286
+ expiresAt?: Date;
287
+ /** Raw APS response */
288
+ rawResponse: Record<string, any>;
289
+ }
290
+ /**
291
+ * Query transaction options
292
+ */
293
+ interface QueryOptions {
294
+ /** Transaction ID to query */
295
+ transactionId: string;
296
+ /** Or order ID */
297
+ orderId?: string;
298
+ }
299
+ /**
300
+ * APS Error
301
+ */
302
+ interface APSError {
303
+ /** Error code */
304
+ code: string;
305
+ /** Error message */
306
+ message: string;
307
+ /** HTTP status code */
308
+ statusCode?: number;
309
+ /** Raw error response */
310
+ rawResponse?: Record<string, any>;
311
+ }
312
+ /**
313
+ * APS Exception class
314
+ */
315
+ declare class APSException extends Error {
316
+ code: string;
317
+ statusCode?: number;
318
+ rawResponse?: Record<string, any>;
319
+ constructor(error: APSError);
320
+ }
321
+
322
+ /**
323
+ * useCheckout Hook
324
+ *
325
+ * Manage hosted checkout state and flow in React components.
326
+ * Handles creating checkout sessions, redirecting to APS, and processing results.
327
+ *
328
+ * @example
329
+ * ```tsx
330
+ * import { useCheckout } from '@sikka/aps/react';
331
+ *
332
+ * function CheckoutPage() {
333
+ * const {
334
+ * checkout,
335
+ * isLoading,
336
+ * error,
337
+ * createCheckout,
338
+ * redirectToCheckout,
339
+ * reset
340
+ * } = useCheckout();
341
+ *
342
+ * const handleCheckout = async () => {
343
+ * await createCheckout({
344
+ * order: {
345
+ * id: 'order_123',
346
+ * amount: 10000,
347
+ * currency: 'SAR',
348
+ * customer: { email: 'customer@example.com' }
349
+ * },
350
+ * returnUrl: window.location.origin + '/payment-result'
351
+ * });
352
+ *
353
+ * // Auto-redirect to APS hosted checkout
354
+ * redirectToCheckout();
355
+ * };
356
+ *
357
+ * if (isLoading) return <div>Loading...</div>;
358
+ * if (error) return <div>Error: {error.message}</div>;
359
+ *
360
+ * return <button onClick={handleCheckout}>Pay Now</button>;
361
+ * }
362
+ * ```
363
+ */
364
+
365
+ /**
366
+ * Checkout state
367
+ */
368
+ interface CheckoutState {
369
+ /** The checkout session data */
370
+ checkout: PaymentResponse | null;
371
+ /** Whether a checkout operation is in progress */
372
+ isLoading: boolean;
373
+ /** Error from the last operation */
374
+ error: Error | null;
375
+ }
376
+ /**
377
+ * Return type for useCheckout hook
378
+ */
379
+ interface UseCheckoutReturn extends CheckoutState {
380
+ /**
381
+ * Create a new hosted checkout session
382
+ * @param options - Checkout configuration options
383
+ * @returns The checkout session data
384
+ */
385
+ createCheckout: (options: HostedCheckoutOptions) => Promise<PaymentResponse>;
386
+ /**
387
+ * Redirect the customer to the APS hosted checkout page
388
+ * Must be called after createCheckout succeeds
389
+ * @throws Error if no checkout session exists
390
+ */
391
+ redirectToCheckout: () => void;
392
+ /**
393
+ * Reset the checkout state
394
+ */
395
+ reset: () => void;
396
+ }
397
+ /**
398
+ * Hook to manage hosted checkout flow
399
+ *
400
+ * @returns Checkout state and control functions
401
+ *
402
+ * @example
403
+ * ```tsx
404
+ * const {
405
+ * checkout,
406
+ * isLoading,
407
+ * error,
408
+ * createCheckout,
409
+ * redirectToCheckout,
410
+ * reset
411
+ * } = useCheckout();
412
+ *
413
+ * // Create checkout session
414
+ * const handleCreate = async () => {
415
+ * try {
416
+ * await createCheckout({
417
+ * order: {
418
+ * id: 'order_123',
419
+ * amount: 10000,
420
+ * currency: 'SAR',
421
+ * customer: { email: 'customer@example.com' }
422
+ * },
423
+ * returnUrl: '/payment-result',
424
+ * tokenize: true
425
+ * });
426
+ * } catch (err) {
427
+ * console.error('Checkout creation failed:', err);
428
+ * }
429
+ * };
430
+ *
431
+ * // Redirect to APS
432
+ * const handleRedirect = () => {
433
+ * redirectToCheckout(); // Submits form to APS
434
+ * };
435
+ * ```
436
+ */
437
+ declare function useCheckout(): UseCheckoutReturn;
438
+
439
+ /**
440
+ * usePayment Hook
441
+ *
442
+ * Manage payment status, confirmation, and lifecycle in React components.
443
+ * Handles creating payments, checking status, and processing results.
444
+ *
445
+ * @example
446
+ * ```tsx
447
+ * import { usePayment } from '@sikka/aps/react';
448
+ *
449
+ * function PaymentPage() {
450
+ * const {
451
+ * payment,
452
+ * isLoading,
453
+ * error,
454
+ * createPaymentLink,
455
+ * confirmPayment,
456
+ * checkStatus,
457
+ * reset
458
+ * } = usePayment();
459
+ *
460
+ * const handlePayment = async () => {
461
+ * // Create a payment link
462
+ * const link = await createPaymentLink({
463
+ * order: {
464
+ * id: 'order_123',
465
+ * amount: 10000,
466
+ * currency: 'SAR'
467
+ * }
468
+ * });
469
+ *
470
+ * // Open payment link
471
+ * window.open(link.url, '_blank');
472
+ * };
473
+ *
474
+ * return (
475
+ * <button onClick={handlePayment} disabled={isLoading}>
476
+ * {isLoading ? 'Processing...' : 'Pay Now'}
477
+ * </button>
478
+ * );
479
+ * }
480
+ * ```
481
+ */
482
+
483
+ /**
484
+ * Payment state
485
+ */
486
+ interface PaymentState {
487
+ /** The current payment data */
488
+ payment: PaymentLinkResponse | PaymentResponse | null;
489
+ /** Current payment status */
490
+ status: TransactionStatus | null;
491
+ /** Whether a payment operation is in progress */
492
+ isLoading: boolean;
493
+ /** Error from the last operation */
494
+ error: Error | null;
495
+ }
496
+ /**
497
+ * Options for confirming a payment
498
+ */
499
+ interface ConfirmPaymentOptions {
500
+ /** The transaction ID to confirm */
501
+ transactionId: string;
502
+ /** Polling interval in milliseconds (default: 2000) */
503
+ pollInterval?: number;
504
+ /** Maximum polling attempts (default: 30) */
505
+ maxAttempts?: number;
506
+ }
507
+ /**
508
+ * Return type for usePayment hook
509
+ */
510
+ interface UsePaymentReturn extends PaymentState {
511
+ /**
512
+ * Create a payment link
513
+ * @param options - Payment link options
514
+ * @returns The created payment link
515
+ */
516
+ createPaymentLink: (options: PaymentLinkOptions) => Promise<PaymentLinkResponse>;
517
+ /**
518
+ * Create a custom payment (token-based)
519
+ * @param options - Custom payment options
520
+ * @returns The payment response
521
+ */
522
+ createCustomPayment: (options: CustomPaymentPageOptions) => Promise<PaymentResponse>;
523
+ /**
524
+ * Confirm a payment by polling for status
525
+ * Useful after redirect back from hosted checkout
526
+ * @param options - Confirmation options
527
+ * @returns Final payment status
528
+ */
529
+ confirmPayment: (options: ConfirmPaymentOptions) => Promise<TransactionStatus>;
530
+ /**
531
+ * Check the status of a transaction
532
+ * @param options - Query options (transactionId or orderId)
533
+ * @returns Transaction status
534
+ */
535
+ checkStatus: (options: QueryOptions) => Promise<TransactionStatus>;
536
+ /**
537
+ * Capture an authorized payment
538
+ * @param transactionId - The transaction to capture
539
+ * @param amount - Optional amount to capture (defaults to full)
540
+ */
541
+ capture: (transactionId: string, amount?: number) => Promise<void>;
542
+ /**
543
+ * Refund a payment
544
+ * @param transactionId - The transaction to refund
545
+ * @param amount - Optional amount to refund (defaults to full)
546
+ * @param reason - Optional refund reason
547
+ */
548
+ refund: (transactionId: string, amount?: number, reason?: string) => Promise<void>;
549
+ /**
550
+ * Void an authorized transaction
551
+ * @param transactionId - The transaction to void
552
+ * @param reason - Optional void reason
553
+ */
554
+ void: (transactionId: string, reason?: string) => Promise<void>;
555
+ /**
556
+ * Reset the payment state
557
+ */
558
+ reset: () => void;
559
+ }
560
+ /**
561
+ * Hook to manage payment lifecycle
562
+ *
563
+ * @returns Payment state and control functions
564
+ *
565
+ * @example
566
+ * ```tsx
567
+ * const {
568
+ * payment,
569
+ * status,
570
+ * isLoading,
571
+ * error,
572
+ * createPaymentLink,
573
+ * confirmPayment,
574
+ * checkStatus,
575
+ * capture,
576
+ * refund,
577
+ * reset
578
+ * } = usePayment();
579
+ *
580
+ * // Create payment
581
+ * const link = await createPaymentLink({
582
+ * order: { id: 'order_123', amount: 10000, currency: 'SAR' }
583
+ * });
584
+ *
585
+ * // After customer returns from payment
586
+ * const finalStatus = await confirmPayment({ transactionId: 'txn_123' });
587
+ * if (finalStatus === 'captured') {
588
+ * // Payment successful!
589
+ * }
590
+ * ```
591
+ */
592
+ declare function usePayment(): UsePaymentReturn;
593
+
594
+ /**
595
+ * Styles for the tokenization form
596
+ * Developers can override these with custom styles
597
+ */
598
+ interface TokenizationFormStyles {
599
+ container?: React.CSSProperties;
600
+ form?: React.CSSProperties;
601
+ inputGroup?: React.CSSProperties;
602
+ label?: React.CSSProperties;
603
+ input?: React.CSSProperties;
604
+ inputError?: React.CSSProperties;
605
+ row?: React.CSSProperties;
606
+ button?: React.CSSProperties;
607
+ buttonDisabled?: React.CSSProperties;
608
+ cardIcons?: React.CSSProperties;
609
+ securityNotice?: React.CSSProperties;
610
+ }
611
+ /**
612
+ * Card brand icons
613
+ */
614
+ interface CardIcons {
615
+ visa?: React.ReactNode;
616
+ mastercard?: React.ReactNode;
617
+ amex?: React.ReactNode;
618
+ discover?: React.ReactNode;
619
+ mada?: React.ReactNode;
620
+ unknown?: React.ReactNode;
621
+ }
622
+ /**
623
+ * Props for the TokenizationForm component
624
+ */
625
+ interface TokenizationFormProps {
626
+ /** APS tokenization form action URL */
627
+ actionUrl: string;
628
+ /** APS tokenization form parameters */
629
+ formParams: Record<string, string>;
630
+ /** Customer email for associating the saved card */
631
+ customerEmail?: string;
632
+ /** Callback when tokenization succeeds */
633
+ onSuccess?: (token: string, cardData: CardData) => void;
634
+ /** Callback when tokenization fails */
635
+ onError?: (error: string) => void;
636
+ /** Custom styles for the form */
637
+ styles?: TokenizationFormStyles;
638
+ /** Custom card brand icons */
639
+ icons?: CardIcons;
640
+ /** Custom labels */
641
+ labels?: {
642
+ cardNumber?: string;
643
+ cardHolder?: string;
644
+ customerEmail?: string;
645
+ expiryDate?: string;
646
+ cvv?: string;
647
+ submitButton?: string;
648
+ processing?: string;
649
+ };
650
+ /** Custom placeholders */
651
+ placeholders?: {
652
+ cardNumber?: string;
653
+ cardHolder?: string;
654
+ customerEmail?: string;
655
+ expiryDate?: string;
656
+ cvv?: string;
657
+ };
658
+ /** Disable card number formatting */
659
+ disableFormatting?: boolean;
660
+ /** Show card brand icons */
661
+ showCardIcons?: boolean;
662
+ /** Show security notice */
663
+ showSecurityNotice?: boolean;
664
+ /** Custom class names */
665
+ className?: {
666
+ container?: string;
667
+ form?: string;
668
+ inputGroup?: string;
669
+ input?: string;
670
+ label?: string;
671
+ button?: string;
672
+ };
673
+ }
674
+ /**
675
+ * Card data returned on successful tokenization
676
+ */
677
+ interface CardData {
678
+ last4: string;
679
+ brand: string;
680
+ expiryMonth: string;
681
+ expiryYear: string;
682
+ cardholderName: string;
683
+ }
684
+ /**
685
+ * TokenizationForm Component
686
+ *
687
+ * A customizable React component for collecting card details and tokenizing them via APS.
688
+ *
689
+ * @example
690
+ * ```tsx
691
+ * import { TokenizationForm } from 'amazon-payment-services/react';
692
+ *
693
+ * function PaymentPage() {
694
+ * const [formParams, setFormParams] = useState(null);
695
+ *
696
+ * // Fetch form params from your backend
697
+ * useEffect(() => {
698
+ * fetch('/api/get-tokenization-form')
699
+ * .then(res => res.json())
700
+ * .then(data => setFormParams(data.formParams));
701
+ * }, []);
702
+ *
703
+ * if (!formParams) return <div>Loading...</div>;
704
+ *
705
+ * return (
706
+ * <TokenizationForm
707
+ * actionUrl={formParams.url}
708
+ * formParams={formParams.params}
709
+ * customerEmail="customer@example.com"
710
+ * onSuccess={(token, card) => {
711
+ * console.log('Tokenized:', token, card);
712
+ * }}
713
+ * onError={(error) => {
714
+ * console.error('Error:', error);
715
+ * }}
716
+ * />
717
+ * );
718
+ * }
719
+ * ```
720
+ */
721
+ declare const TokenizationForm: React.FC<TokenizationFormProps>;
722
+
723
+ /**
724
+ * ErrorDisplay Component
725
+ *
726
+ * Display APS errors with helpful messages and suggested actions.
727
+ *
728
+ * @example
729
+ * ```tsx
730
+ * import { ErrorDisplay } from '@sikka/aps/react';
731
+ *
732
+ * function PaymentForm() {
733
+ * const [error, setError] = useState<APSException | null>(null);
734
+ *
735
+ * return (
736
+ * <div>
737
+ * {error && (
738
+ * <ErrorDisplay
739
+ * error={error}
740
+ * onRetry={() => handleRetry()}
741
+ * onDismiss={() => setError(null)}
742
+ * />
743
+ * )}
744
+ * </div>
745
+ * );
746
+ * }
747
+ * ```
748
+ */
749
+
750
+ /**
751
+ * Props for ErrorDisplay component
752
+ */
753
+ interface ErrorDisplayProps {
754
+ /** The APS error to display */
755
+ error: APSException | Error | string;
756
+ /** Callback when retry button is clicked */
757
+ onRetry?: () => void;
758
+ /** Callback when dismiss button is clicked */
759
+ onDismiss?: () => void;
760
+ /** Custom title override */
761
+ title?: string;
762
+ /** Show documentation link */
763
+ showDocumentation?: boolean;
764
+ /** Custom styles */
765
+ styles?: ErrorDisplayStyles;
766
+ /** Custom class names */
767
+ className?: string;
768
+ }
769
+ /**
770
+ * Styles for ErrorDisplay
771
+ */
772
+ interface ErrorDisplayStyles {
773
+ container?: React.CSSProperties;
774
+ header?: React.CSSProperties;
775
+ title?: React.CSSProperties;
776
+ code?: React.CSSProperties;
777
+ message?: React.CSSProperties;
778
+ action?: React.CSSProperties;
779
+ actions?: React.CSSProperties;
780
+ button?: React.CSSProperties;
781
+ buttonRetry?: React.CSSProperties;
782
+ buttonDismiss?: React.CSSProperties;
783
+ documentation?: React.CSSProperties;
784
+ }
785
+ /**
786
+ * ErrorDisplay Component
787
+ *
788
+ * Displays APS errors with helpful messages, suggested actions, and retry/dismiss buttons.
789
+ */
790
+ declare const ErrorDisplay: React.FC<ErrorDisplayProps>;
791
+
792
+ /**
793
+ * PaymentStatus Component
794
+ *
795
+ * Display payment status with appropriate icons and styling.
796
+ *
797
+ * @example
798
+ * ```tsx
799
+ * import { PaymentStatus } from '@sikka/aps/react';
800
+ *
801
+ * function PaymentResult() {
802
+ * return (
803
+ * <PaymentStatus
804
+ * status="captured"
805
+ * amount={10000}
806
+ * currency="SAR"
807
+ * transactionId="txn_123"
808
+ * />
809
+ * );
810
+ * }
811
+ * ```
812
+ */
813
+
814
+ /**
815
+ * Props for PaymentStatus component
816
+ */
817
+ interface PaymentStatusProps {
818
+ /** The transaction status */
819
+ status: TransactionStatus | string;
820
+ /** The transaction amount (in minor units) */
821
+ amount?: number;
822
+ /** The currency code */
823
+ currency?: string;
824
+ /** The transaction ID */
825
+ transactionId?: string;
826
+ /** The payment method used */
827
+ paymentMethod?: string;
828
+ /** Custom title override */
829
+ title?: string;
830
+ /** Show amount */
831
+ showAmount?: boolean;
832
+ /** Show transaction ID */
833
+ showTransactionId?: boolean;
834
+ /** Custom styles */
835
+ styles?: PaymentStatusStyles;
836
+ /** Custom class names */
837
+ className?: string;
838
+ /** Size variant */
839
+ size?: 'small' | 'medium' | 'large';
840
+ }
841
+ /**
842
+ * Styles for PaymentStatus
843
+ */
844
+ interface PaymentStatusStyles {
845
+ container?: React.CSSProperties;
846
+ icon?: React.CSSProperties;
847
+ content?: React.CSSProperties;
848
+ title?: React.CSSProperties;
849
+ amount?: React.CSSProperties;
850
+ details?: React.CSSProperties;
851
+ detail?: React.CSSProperties;
852
+ detailLabel?: React.CSSProperties;
853
+ detailValue?: React.CSSProperties;
854
+ }
855
+ /**
856
+ * PaymentStatus Component
857
+ */
858
+ declare const PaymentStatus: React.FC<PaymentStatusProps>;
859
+
860
+ /**
861
+ * HostedCheckoutButton Component
862
+ *
863
+ * A ready-to-use button that creates a hosted checkout session and redirects to APS.
864
+ *
865
+ * @example
866
+ * ```tsx
867
+ * import { HostedCheckoutButton } from '@sikka/aps/react';
868
+ *
869
+ * function CheckoutPage() {
870
+ * return (
871
+ * <HostedCheckoutButton
872
+ * order={{
873
+ * id: 'order_123',
874
+ * amount: 10000,
875
+ * currency: 'SAR',
876
+ * customer: { email: 'customer@example.com' }
877
+ * }}
878
+ * returnUrl="https://yoursite.com/payment-result"
879
+ * >
880
+ * Pay Now
881
+ * </HostedCheckoutButton>
882
+ * );
883
+ * }
884
+ * ```
885
+ */
886
+
887
+ /**
888
+ * Props for HostedCheckoutButton
889
+ */
890
+ interface HostedCheckoutButtonProps {
891
+ /** Order details */
892
+ order: Order;
893
+ /** URL to redirect after payment */
894
+ returnUrl: string;
895
+ /** Restrict payment methods */
896
+ allowedPaymentMethods?: string[];
897
+ /** Hide shipping fields */
898
+ hideShipping?: boolean;
899
+ /** Button content */
900
+ children: React.ReactNode;
901
+ /** Callback when checkout is created */
902
+ onCheckoutCreated?: (checkout: any) => void;
903
+ /** Callback on error */
904
+ onError?: (error: Error) => void;
905
+ /** Custom styles */
906
+ styles?: HostedCheckoutButtonStyles;
907
+ /** Custom class name */
908
+ className?: string;
909
+ /** Disable button */
910
+ disabled?: boolean;
911
+ /** Show error display */
912
+ showError?: boolean;
913
+ /** Loading component */
914
+ loadingComponent?: React.ReactNode;
915
+ }
916
+ /**
917
+ * Styles for HostedCheckoutButton
918
+ */
919
+ interface HostedCheckoutButtonStyles {
920
+ button?: React.CSSProperties;
921
+ buttonDisabled?: React.CSSProperties;
922
+ buttonLoading?: React.CSSProperties;
923
+ errorContainer?: React.CSSProperties;
924
+ }
925
+ /**
926
+ * HostedCheckoutButton Component
927
+ *
928
+ * A complete checkout button that handles the entire hosted checkout flow.
929
+ */
930
+ declare const HostedCheckoutButton: React.FC<HostedCheckoutButtonProps>;
931
+
932
+ export { APSProvider, type APSProviderProps, type CardData, type CardIcons, type ConfirmPaymentOptions, ErrorDisplay, type ErrorDisplayProps, type ErrorDisplayStyles, HostedCheckoutButton, type HostedCheckoutButtonProps, type HostedCheckoutButtonStyles, PaymentStatus, type PaymentStatusProps, type PaymentStatusStyles, TokenizationForm, type TokenizationFormProps, type TokenizationFormStyles, type UseCheckoutReturn, type UsePaymentReturn, useAPS, useCheckout, usePayment };