@getopenpay/openpay-js 0.1.1-alpha.1 → 0.1.1-alpha.2
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/dist/index.d.ts +96 -7
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,38 @@
|
|
|
1
|
-
import { CdeConnection } from '@getopenpay/utils';
|
|
2
|
-
import { CheckoutPaymentMethod } from '@getopenpay/utils';
|
|
3
|
-
import { ElementProps } from '@getopenpay/utils';
|
|
4
|
-
import { ElementsFormProps } from '@getopenpay/utils';
|
|
5
|
-
import { FieldName } from '@getopenpay/utils';
|
|
6
1
|
import { PaymentRequestPaymentMethodEvent } from '@stripe/stripe-js';
|
|
7
|
-
import {
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
declare const AllFieldNames = z.union([FieldNameEnum, PrivateFieldNameEnum]);
|
|
5
|
+
|
|
6
|
+
declare type AllFieldNames = z.infer<typeof AllFieldNames>;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Payment requests
|
|
10
|
+
*/
|
|
11
|
+
declare const Amount = z.object({
|
|
12
|
+
amountAtom: z.number(),
|
|
13
|
+
currency: RequiredString,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
declare type Amount = z.infer<typeof Amount>;
|
|
17
|
+
|
|
18
|
+
declare type CdeConnection = {
|
|
19
|
+
send: (data: CdeMessage) => Promise<unknown>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
declare type CdeMessage = {
|
|
23
|
+
type: string;
|
|
24
|
+
} & Record<string, unknown>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Core models
|
|
28
|
+
*/
|
|
29
|
+
declare const CheckoutPaymentMethod = z.object({
|
|
30
|
+
provider: z.string(),
|
|
31
|
+
processor_name: nullOrUndefOr(z.string()),
|
|
32
|
+
metadata: nullOrUndefOr(z.record(z.string(), z.any())),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
declare type CheckoutPaymentMethod = z.infer<typeof CheckoutPaymentMethod>;
|
|
8
36
|
|
|
9
37
|
export declare type Config = Omit<ElementsFormProps, 'children'> & {
|
|
10
38
|
formTarget?: string;
|
|
@@ -18,9 +46,60 @@ declare class ConnectionManager {
|
|
|
18
46
|
getConnection(): CdeConnection;
|
|
19
47
|
}
|
|
20
48
|
|
|
49
|
+
declare type ElementProps<PlaceholderType extends z.ZodTypeAny = z.ZodString> = {
|
|
50
|
+
styles?: ElementsStyle<z.ZodOptional<PlaceholderType>>;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
declare type ElementsFormChildrenProps = {
|
|
54
|
+
submit: () => void;
|
|
55
|
+
applePay: PaymentRequestStatus;
|
|
56
|
+
googlePay: PaymentRequestStatus;
|
|
57
|
+
loaded: boolean;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
declare type ElementsFormProps = {
|
|
61
|
+
className?: string;
|
|
62
|
+
checkoutSecureToken: string;
|
|
63
|
+
children: (props: ElementsFormChildrenProps) => JSX.Element;
|
|
64
|
+
onFocus?: (elementId: string) => void;
|
|
65
|
+
onBlur?: (elementId: string) => void;
|
|
66
|
+
onChange?: (elementId: string) => void;
|
|
67
|
+
onLoad?: (totalAmountAtoms?: number, currency?: string) => void;
|
|
68
|
+
onLoadError?: (message: string) => void;
|
|
69
|
+
onValidationError?: (field: AllFieldNames, errors: string[], elementId?: string) => void;
|
|
70
|
+
onCheckoutStarted?: () => void;
|
|
71
|
+
onCheckoutSuccess?: (invoiceUrls: string[], subscriptionIds: string[], customerId: string) => void;
|
|
72
|
+
onSetupPaymentMethodSuccess?: (paymentMethodId: string) => void;
|
|
73
|
+
onCheckoutError?: (message: string) => void;
|
|
74
|
+
baseUrl?: string;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
declare const ElementsStyle = <T extends z.ZodTypeAny>(placeholderType: T) =>
|
|
78
|
+
BaseElementsStyle.extend({
|
|
79
|
+
placeholder: placeholderType,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
declare type ElementsStyle<T extends z.ZodTypeAny> = z.infer<ReturnType<typeof ElementsStyle<T>>>;
|
|
83
|
+
|
|
21
84
|
export declare type ElementType = 'card' | 'card-number' | 'card-expiry' | 'card-cvc';
|
|
22
85
|
|
|
23
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Expected input fields
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
// Supplied by the user
|
|
91
|
+
export declare enum FieldName {
|
|
92
|
+
FIRST_NAME = 'firstName',
|
|
93
|
+
LAST_NAME = 'lastName',
|
|
94
|
+
EMAIL = 'email',
|
|
95
|
+
ZIP_CODE = 'zipCode',
|
|
96
|
+
CITY = 'city',
|
|
97
|
+
STATE = 'state',
|
|
98
|
+
COUNTRY = 'country',
|
|
99
|
+
ADDRESS = 'address',
|
|
100
|
+
PHONE = 'phone',
|
|
101
|
+
PROMOTION_CODE = 'promotionCode',
|
|
102
|
+
}
|
|
24
103
|
|
|
25
104
|
export declare class OpenPayForm {
|
|
26
105
|
config: Config;
|
|
@@ -55,4 +134,14 @@ export declare class OpenPayForm {
|
|
|
55
134
|
destroy(): void;
|
|
56
135
|
}
|
|
57
136
|
|
|
137
|
+
declare type PaymentRequestStartParams = {
|
|
138
|
+
amountToDisplayForSetupMode?: Amount;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
declare type PaymentRequestStatus = {
|
|
142
|
+
isLoading: boolean;
|
|
143
|
+
isAvailable: boolean;
|
|
144
|
+
startFlow: (params?: PaymentRequestStartParams) => Promise<void>;
|
|
145
|
+
};
|
|
146
|
+
|
|
58
147
|
export { }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getopenpay/openpay-js",
|
|
3
|
-
"version": "0.1.1-alpha.
|
|
3
|
+
"version": "0.1.1-alpha.2",
|
|
4
4
|
"description": "Accept payments through OpenPay, right on your site",
|
|
5
5
|
"author": "OpenPay <info@getopenpay.com> (https://getopenpay.com)",
|
|
6
6
|
"license": "ISC",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"dev": "tsc -p tsconfig.build.json && NODE_ENV=development vite build --mode development --watch"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"penpal": "^6.2.2"
|
|
34
|
+
"penpal": "^6.2.2",
|
|
35
|
+
"@stripe/stripe-js": "^4.3.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"@getopenpay/utils": "*",
|
|
38
38
|
"@getopenpay/eslint-config": "*",
|
|
39
39
|
"@getopenpay/typescript-config": "*",
|
|
40
|
-
"@
|
|
40
|
+
"@getopenpay/utils": "*",
|
|
41
41
|
"@types/node": "^22.0.2",
|
|
42
42
|
"@types/react": "^18.2.0",
|
|
43
43
|
"@types/react-dom": "^18.2.0",
|