@spot-flow/checkout-inline-js 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.
- package/README.md +51 -0
- package/dist/api.d.ts +7 -0
- package/dist/checkout-inline.js +847 -0
- package/dist/data.d.ts +13 -0
- package/dist/index.d.ts +30 -0
- package/dist/modules/Card.d.ts +35 -0
- package/dist/modules/Transfer.d.ts +34 -0
- package/dist/modules/Ussd.d.ts +15 -0
- package/dist/types/types.d.ts +72 -0
- package/dist/utils.d.ts +9 -0
- package/package.json +30 -0
package/dist/data.d.ts
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { default as Card } from './modules/Card';
|
|
2
|
+
import { default as Transfer } from './modules/Transfer';
|
|
3
|
+
import { default as Ussd } from './modules/Ussd';
|
|
4
|
+
|
|
5
|
+
declare class CheckoutForm {
|
|
6
|
+
modalContainer: HTMLDivElement;
|
|
7
|
+
currentPaymentMethod: number;
|
|
8
|
+
currentStep: number;
|
|
9
|
+
container: HTMLDivElement;
|
|
10
|
+
card: Card;
|
|
11
|
+
transfer: Transfer;
|
|
12
|
+
ussd: Ussd;
|
|
13
|
+
merchantKey: string;
|
|
14
|
+
email: string;
|
|
15
|
+
amount: number;
|
|
16
|
+
isMobile: boolean;
|
|
17
|
+
constructor(merchantKey: string, email: string, amount: number);
|
|
18
|
+
attachInputListeners(): void;
|
|
19
|
+
displayTabLayout(): void;
|
|
20
|
+
private updatePaymentMethodView;
|
|
21
|
+
renderPaymentMethodContent(): void | "";
|
|
22
|
+
setCurrentPaymentMethod(index: number): void;
|
|
23
|
+
private cleanup;
|
|
24
|
+
closeModal(): void;
|
|
25
|
+
setup(): void;
|
|
26
|
+
private mobileContainerContent;
|
|
27
|
+
private viewMobileOptions;
|
|
28
|
+
private displayPaymentWarningText;
|
|
29
|
+
}
|
|
30
|
+
export default CheckoutForm;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { PaymentResponseData } from '../types/types';
|
|
2
|
+
|
|
3
|
+
declare class Card {
|
|
4
|
+
private cardDetailsValues;
|
|
5
|
+
private cardPin;
|
|
6
|
+
private cardOtp;
|
|
7
|
+
private contents;
|
|
8
|
+
private container;
|
|
9
|
+
private closeModal;
|
|
10
|
+
private email;
|
|
11
|
+
private token;
|
|
12
|
+
private amount;
|
|
13
|
+
private _currentStep;
|
|
14
|
+
private activeRef;
|
|
15
|
+
private creditCardTypes;
|
|
16
|
+
constructor(container: HTMLElement, closeModal: () => void, token: string, email: string, amount: number);
|
|
17
|
+
private displayCardTypes;
|
|
18
|
+
get currentStep(): number;
|
|
19
|
+
set currentStep(step: number);
|
|
20
|
+
attachInputListeners(): void;
|
|
21
|
+
handleInputChange(event: Event, button: HTMLButtonElement | null): void;
|
|
22
|
+
private handlePinRequest;
|
|
23
|
+
handlePinInputChange(event: Event, index: number, pinInputs: HTMLInputElement[]): void;
|
|
24
|
+
showLoader(): void;
|
|
25
|
+
handlePinPaste(event: ClipboardEvent, pinInputs: HTMLInputElement[]): void;
|
|
26
|
+
handleOtpInput(event: Event, button: HTMLButtonElement | null): void;
|
|
27
|
+
submitOtp(e: Event): void;
|
|
28
|
+
handleSubmit(e: Event): Promise<void>;
|
|
29
|
+
private redirectTo3DS;
|
|
30
|
+
verifyPayment(onSuccess: (data: PaymentResponseData) => void, onError: (error: Error) => void): Promise<void>;
|
|
31
|
+
private getCardStepContent;
|
|
32
|
+
private filterCreditCardType;
|
|
33
|
+
renderCardContent(): void;
|
|
34
|
+
}
|
|
35
|
+
export default Card;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { PaymentResponseData } from '../types/types';
|
|
2
|
+
|
|
3
|
+
declare class Transfer {
|
|
4
|
+
private container;
|
|
5
|
+
private contents;
|
|
6
|
+
private closeModal;
|
|
7
|
+
private email;
|
|
8
|
+
private token;
|
|
9
|
+
private amount;
|
|
10
|
+
private _currentStep;
|
|
11
|
+
private activeRef;
|
|
12
|
+
private paymentResponse;
|
|
13
|
+
private initialTime;
|
|
14
|
+
private timeLeft;
|
|
15
|
+
private timerId;
|
|
16
|
+
private abortController;
|
|
17
|
+
constructor(container: HTMLElement, closeModal: () => void, token: string, email: string, amount: number);
|
|
18
|
+
get currentStep(): number;
|
|
19
|
+
set currentStep(step: number);
|
|
20
|
+
attachInputListeners(): void;
|
|
21
|
+
createTransfer(): Promise<void>;
|
|
22
|
+
verifyTransfer(token: string, initialInterval: number, onSuccess: (data: PaymentResponseData) => void, onError: (error: Error) => void): Promise<void>;
|
|
23
|
+
private getTransferStepContent;
|
|
24
|
+
private updateTransferDetailsContent;
|
|
25
|
+
renderTransferContent(): void;
|
|
26
|
+
private startTimer;
|
|
27
|
+
private updateProgressTimerContent;
|
|
28
|
+
private stopTimer;
|
|
29
|
+
stopProgressBar(): void;
|
|
30
|
+
copyToClipboard(text: string, element: Element): void;
|
|
31
|
+
destroyTimer(): void;
|
|
32
|
+
stopPolling(): void;
|
|
33
|
+
}
|
|
34
|
+
export default Transfer;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare class Ussd {
|
|
2
|
+
private contents;
|
|
3
|
+
private banks;
|
|
4
|
+
private _currentStep;
|
|
5
|
+
constructor();
|
|
6
|
+
get currentStep(): number;
|
|
7
|
+
set currentStep(step: number);
|
|
8
|
+
private getUssdStepContent;
|
|
9
|
+
renderUssdContent(): void;
|
|
10
|
+
private renderSearchOptions;
|
|
11
|
+
searchBanksOnInput(searchInput: HTMLInputElement, optionsContainer: HTMLElement): void;
|
|
12
|
+
openSearchOnFocus(searchInput: HTMLInputElement, optionsContainer: HTMLElement): void;
|
|
13
|
+
closeSearchOptionsOutsideFocus(event: Event, searchInput: HTMLInputElement, optionsContainer: HTMLElement): void;
|
|
14
|
+
}
|
|
15
|
+
export default Ussd;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export type PaymentRequestPayload = {
|
|
2
|
+
merchantId?: string;
|
|
3
|
+
amount: number;
|
|
4
|
+
channel: string;
|
|
5
|
+
currency: string;
|
|
6
|
+
customer: {
|
|
7
|
+
email: string;
|
|
8
|
+
};
|
|
9
|
+
reference: string;
|
|
10
|
+
planId?: string;
|
|
11
|
+
};
|
|
12
|
+
export type CardDetails = {
|
|
13
|
+
pan: string;
|
|
14
|
+
cvv: string;
|
|
15
|
+
expiryMonth: string;
|
|
16
|
+
expiryYear: string;
|
|
17
|
+
};
|
|
18
|
+
export type CardPaymentRequestPayload = PaymentRequestPayload & {
|
|
19
|
+
card: CardDetails;
|
|
20
|
+
};
|
|
21
|
+
export type AuthorizeCardPaymentRequestPayload = {
|
|
22
|
+
authorization: {
|
|
23
|
+
pin: string;
|
|
24
|
+
};
|
|
25
|
+
reference: string;
|
|
26
|
+
};
|
|
27
|
+
export type ValidateCardPaymentRequestPayload = {
|
|
28
|
+
authorization: {
|
|
29
|
+
otp: string;
|
|
30
|
+
};
|
|
31
|
+
reference: string;
|
|
32
|
+
};
|
|
33
|
+
export type PaymentResponseData = {
|
|
34
|
+
id: string;
|
|
35
|
+
reference: string;
|
|
36
|
+
spotflowReference: string;
|
|
37
|
+
amount: number;
|
|
38
|
+
currency: string;
|
|
39
|
+
channel: string;
|
|
40
|
+
status: string;
|
|
41
|
+
bankDetails?: BankDetails;
|
|
42
|
+
customer: Customer;
|
|
43
|
+
provider: string;
|
|
44
|
+
providerMessage: string;
|
|
45
|
+
rate: Rate;
|
|
46
|
+
authorization: Authorization;
|
|
47
|
+
createdAt: Date;
|
|
48
|
+
};
|
|
49
|
+
export interface Authorization {
|
|
50
|
+
mode: string;
|
|
51
|
+
redirectUrl: string | null;
|
|
52
|
+
}
|
|
53
|
+
export interface BankDetails {
|
|
54
|
+
accountName: string;
|
|
55
|
+
accountNumber: string;
|
|
56
|
+
bankName: string;
|
|
57
|
+
}
|
|
58
|
+
export interface Customer {
|
|
59
|
+
id: string;
|
|
60
|
+
name: string;
|
|
61
|
+
email: string;
|
|
62
|
+
phoneNumber: string;
|
|
63
|
+
}
|
|
64
|
+
export interface Rate {
|
|
65
|
+
from: string;
|
|
66
|
+
to: string;
|
|
67
|
+
rate: number;
|
|
68
|
+
}
|
|
69
|
+
export type BankOption = {
|
|
70
|
+
name: string;
|
|
71
|
+
code: string;
|
|
72
|
+
};
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const generatePaymentReference: () => string;
|
|
2
|
+
export declare const clearNumber: (value?: string) => string;
|
|
3
|
+
export declare const formatCreditCardNumber: (value: string) => string;
|
|
4
|
+
export declare const formatCVC: (value: string) => string;
|
|
5
|
+
export declare const formatExpirationDate: (value: string) => string;
|
|
6
|
+
export declare const unFormatCreditCardNumber: (value: string) => string;
|
|
7
|
+
export declare const formatTime: (seconds: number) => string;
|
|
8
|
+
export declare const getCardType: (cardNumber: string) => string;
|
|
9
|
+
export declare const showToast: (message: string, theme: "success" | "error" | "info" | "warning", duration?: number) => void;
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@spot-flow/checkout-inline-js",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./dist/checkout-inline.js",
|
|
6
|
+
"source": "./src/index.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
|
+
"dev": "vite",
|
|
10
|
+
"build": "vite build"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"keywords": [],
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"author": "",
|
|
19
|
+
"license": "ISC",
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/node": "^20.14.9",
|
|
22
|
+
"autoprefixer": "^10.4.19",
|
|
23
|
+
"postcss": "^8.4.39",
|
|
24
|
+
"tailwindcss": "^3.4.4",
|
|
25
|
+
"typescript": "^5.5.3",
|
|
26
|
+
"vite": "^5.3.2",
|
|
27
|
+
"vite-plugin-css-injected-by-js": "^3.5.1",
|
|
28
|
+
"vite-plugin-dts": "^3.9.1"
|
|
29
|
+
}
|
|
30
|
+
}
|