@koomipay/react 2.0.4 → 2.1.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.
@@ -1,9 +1,14 @@
1
- import { DefaultPaymentMethodComponentProps } from "./CheckoutContainer";
2
- export type GooglePayMethodPayload = {
3
- type: string;
4
- googlePayToken: string;
1
+ import { CheckoutAmount, ConfirmPaymentOptions, KoomiPayClient, PaymentResultPayload } from "../lib/client";
2
+ export type AdyenGooglePayButtonType = "plain" | "buy" | "book" | "checkout" | "donate" | "order" | "pay" | "subscribe";
3
+ export type GooglePayComponentProps = {
4
+ onValid?: (isValid: boolean) => void;
5
+ client?: KoomiPayClient;
6
+ amount?: CheckoutAmount;
7
+ countryCode?: string;
8
+ onPaymentError?: (message?: string) => void;
9
+ onPaymentComplete?: (payload: PaymentResultPayload) => void;
10
+ paymentMethod: any;
11
+ showPayButton?: boolean;
12
+ onSubmit?: (confirm: (payload: ConfirmPaymentOptions) => Promise<void>) => void;
5
13
  };
6
- export type GooglePayComponentProps = DefaultPaymentMethodComponentProps & {
7
- onChange: (args: GooglePayMethodPayload) => void;
8
- };
9
- export default function GooglePayComponent({ client, paymentMethod, onValid, onChange, onAuthorise, countryCode, amount }: GooglePayComponentProps): import("react/jsx-runtime").JSX.Element;
14
+ export default function GooglePayComponent({ client, onValid, paymentMethod, onPaymentError, onPaymentComplete, countryCode, amount, showPayButton, onSubmit, }: GooglePayComponentProps): import("react/jsx-runtime").JSX.Element;
@@ -1,13 +1,27 @@
1
- import { DefaultPaymentMethodComponentProps, KoomiPaymentMethod } from "./CheckoutContainer";
2
- import { QrOptions } from "./CheckoutContainer";
1
+ /// <reference types="react" />
2
+ import { KoomiPaymentMethod } from "./CheckoutContainer";
3
+ import { CheckoutAmount, ConfirmPaymentOptions, KoomiPayClient, PaymentResultPayload } from "src/lib/client";
3
4
  export type KoomiQrPaymentMethod = KoomiPaymentMethod & {
4
5
  type: string;
6
+ options: QrPaymentOptions;
5
7
  };
6
- export type QrPayComponentProps = DefaultPaymentMethodComponentProps & {
7
- onComplete: (success: boolean, error?: any) => void;
8
- onFail: (error: any) => void;
9
- options: QrOptions;
10
- actionData?: any;
11
- loadingContext?: string;
8
+ export type QrPaymentOptions = {
9
+ qrCodeSize?: string;
10
+ countdownTime?: number;
12
11
  };
13
- export default function QrPayComponent({ client, paymentMethod, amount, countryCode, onComplete, onFail, options, loadingContext, actionData, }: QrPayComponentProps): import("react/jsx-runtime").JSX.Element;
12
+ export type QrPayComponentProps = {
13
+ onValid?: (isValid: boolean) => void;
14
+ client?: KoomiPayClient;
15
+ amount?: CheckoutAmount;
16
+ countryCode?: string;
17
+ onPaymentError?: (message?: string) => void;
18
+ onPaymentComplete?: (payload?: PaymentResultPayload) => void;
19
+ paymentMethod: any;
20
+ showPayButton?: boolean;
21
+ onSubmit?: (confirm: (payload: ConfirmPaymentOptions) => Promise<void>) => void;
22
+ };
23
+ export type QrPayComponentRef = {
24
+ submit: () => void;
25
+ };
26
+ export declare const QrPayComponent: import("react").ForwardRefExoticComponent<QrPayComponentProps & import("react").RefAttributes<QrPayComponentRef>>;
27
+ export default QrPayComponent;
@@ -0,0 +1,19 @@
1
+ /// <reference types="react" />
2
+ import { CheckoutAmount, ConfirmPaymentOptions, KoomiPayClient, PaymentResultPayload } from "src/lib/client";
3
+ export type RedirectPayComponentProps = {
4
+ onValid?: (isValid: boolean) => void;
5
+ client?: KoomiPayClient;
6
+ amount?: CheckoutAmount;
7
+ countryCode?: string;
8
+ onPaymentError?: (message?: string) => void;
9
+ onPaymentComplete?: (payload?: PaymentResultPayload) => void;
10
+ paymentMethod: any;
11
+ showPayButton?: boolean;
12
+ onSubmit?: (confirm: (payload: ConfirmPaymentOptions) => Promise<void>) => void;
13
+ onRedirect?: (url: string) => void;
14
+ };
15
+ export type RedirectPayComponentRef = {
16
+ submit: () => void;
17
+ };
18
+ export declare const RedirectPayComponent: import("react").ForwardRefExoticComponent<RedirectPayComponentProps & import("react").RefAttributes<RedirectPayComponentRef>>;
19
+ export default RedirectPayComponent;
@@ -0,0 +1,6 @@
1
+ export default function RedirectShopperInIframe({ url, onRedirectComplete, }: {
2
+ url: string;
3
+ onRedirectComplete: (data: {
4
+ redirectResult: any;
5
+ }) => Promise<void>;
6
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,12 @@
1
- export { CheckoutContainer } from "./components/CheckoutContainer";
2
1
  export { CardComponent } from "./components/CardComponent";
3
2
  export { PaymentMethod } from "./components/PaymentMethod";
4
3
  export { createClient } from "./lib/client";
4
+ export type { CardComponentRef, } from "./components/CardComponent";
5
+ export type { QrPayComponentRef } from "./components/QrPayComponent";
6
+ export type { KoomiPayClient } from "./lib/client";
7
+ import GooglePayComponent from "./components/GooglePayComponent";
8
+ import ApplePayComponent from "./components/ApplePayComponent";
9
+ import QrPayComponent from "./components/QrPayComponent";
10
+ import RedirectShopperInIframe from "./components/RedirectShopperInIframe";
11
+ import RedirectPayComponent from "./components/RedirectPayComponent";
12
+ export { GooglePayComponent, ApplePayComponent, QrPayComponent, RedirectShopperInIframe, RedirectPayComponent };
@@ -1,13 +1,13 @@
1
1
  import { KoomiPaymentMethod } from "src/components/CheckoutContainer";
2
2
  export type CheckoutPayload = {
3
3
  orderID: String;
4
- returnUrl: String;
4
+ returnUrl?: String;
5
5
  items?: CheckoutItem[];
6
6
  amount: NonNullable<CheckoutAmount>;
7
7
  paymentMethod: object;
8
8
  browserInfo: object;
9
9
  metadata?: object;
10
- RequestedTestAcquirerResponseCode?: number;
10
+ autoCapture?: boolean;
11
11
  };
12
12
  export type CheckoutAmount = {
13
13
  currency: NonNullable<string>;
@@ -19,7 +19,7 @@ export type CheckoutItem = {
19
19
  quantity: NonNullable<number>;
20
20
  price: NonNullable<number>;
21
21
  };
22
- export declare function createClient({ apiKey }: any): KoomiPayClient;
22
+ export declare function createClient({ apiKey, apiUrl, countryCode }: KoomipayClientOptions): KoomiPayClient;
23
23
  export type ClientConfiguration = {
24
24
  baseApiUri: string;
25
25
  assetHost: string;
@@ -27,7 +27,6 @@ export type ClientConfiguration = {
27
27
  clientKey: string;
28
28
  };
29
29
  export type GetPaymentMethodArgs = {
30
- amount?: CheckoutAmount;
31
30
  countryCode?: String;
32
31
  };
33
32
  export type PaymentMethodResponse = {
@@ -37,7 +36,7 @@ export type PaymentMethodResponse = {
37
36
  paymentMethods?: KoomiPaymentMethod[];
38
37
  };
39
38
  export type TokenizeCardPayload = {
40
- returnUrl: String;
39
+ returnUrl?: String;
41
40
  paymentMethod: object;
42
41
  RequestedTestAcquirerResponseCode?: number;
43
42
  };
@@ -45,23 +44,56 @@ export type GetTokensPayload = {
45
44
  shopperReference: string;
46
45
  };
47
46
  export type CreateTokenPayload = {
48
- returnUrl: string;
47
+ returnUrl?: string;
49
48
  paymentMethod: object;
50
49
  RequestedTestAcquirerResponseCode?: number;
51
50
  browserInfo: object;
52
51
  setupIntent: string;
53
52
  };
54
- export declare class KoomiPayClient {
55
- apiUrl: string;
53
+ export type KoomipayClientOptions = {
56
54
  apiKey: string;
55
+ countryCode?: string;
56
+ apiUrl?: string;
57
+ };
58
+ export type OrderItem = {
59
+ productID: string;
60
+ productName: string;
61
+ quantity: number;
62
+ price: number;
63
+ };
64
+ export type ConfirmPaymentOptions = {
65
+ amount?: {
66
+ value: number;
67
+ currency: string;
68
+ };
69
+ orderID?: string;
70
+ items?: OrderItem[];
71
+ autoCapture?: boolean;
72
+ metadata?: Record<string, any>;
73
+ returnUrl?: string;
74
+ };
75
+ export type PaymentResultPayload = {
76
+ resultCode: string;
77
+ action: any;
78
+ message?: string;
79
+ };
80
+ export declare class KoomiPayClient {
81
+ private apiUrl;
82
+ private apiKey;
83
+ private countryCode;
84
+ private fetchConfig;
85
+ private paymentMethods;
57
86
  config: any;
58
- constructor(opts: any);
59
- getConfig(): any;
87
+ constructor(opts: KoomipayClientOptions);
88
+ isAvailable(): Promise<void>;
89
+ getConfig(): Promise<any>;
90
+ private getBaseApiUri;
60
91
  getApiKey(): string;
61
- initConfig(): Promise<void>;
62
- getPaymentMethods(args: GetPaymentMethodArgs): Promise<PaymentMethodResponse>;
92
+ getPaymentMethods(): KoomiPaymentMethod[];
93
+ private initConfig;
94
+ private fetchPaymentConfig;
95
+ private fetchPaymentMethods;
63
96
  checkout(payload: CheckoutPayload): Promise<import("axios").AxiosResponse<any, any, {}>>;
64
- instantCheckout(payload: CheckoutPayload): Promise<import("axios").AxiosResponse<any, any, {}>>;
65
97
  submitAdditionalDetails(payload: any): Promise<import("axios").AxiosResponse<any, any, {}>>;
66
98
  tokenizeCard(payload: TokenizeCardPayload): Promise<import("axios").AxiosResponse<any, any, {}>>;
67
99
  getTokens(payload: GetTokensPayload): Promise<import("axios").AxiosResponse<any, any, {}>>;
@@ -1,2 +1,6 @@
1
1
  export declare function classNames(classNameHash: object): string;
2
2
  export declare function classNameObject(classNameString: string): {};
3
+ export declare function formatAmount({ amount, currency }: {
4
+ amount: number;
5
+ currency: string;
6
+ }): string;