@juspay-tech/react-hyper-js 1.0.1 → 1.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/CHANGELOG.md +9 -0
- package/README.md +3 -0
- package/build.js +18 -9
- package/index.js +1 -1
- package/index.mjs +1 -0
- package/package.json +16 -22
- package/rescript.json +23 -0
- package/src/Context.bs.js +63 -24
- package/src/Context.res +116 -61
- package/src/Index.bs.js +52 -272
- package/src/Index.res +20 -173
- package/src/Index.resi +153 -119
- package/src/OrcaJs.bs.js +6 -6
- package/src/OrcaJs.res +14 -15
- package/src/Window.res +3 -3
- package/src/components/ApplePayElement.bs.js +24 -0
- package/src/components/ApplePayElement.res +6 -0
- package/src/components/CardCVC.bs.js +24 -0
- package/src/components/CardCVC.res +6 -0
- package/src/components/CardElement.bs.js +24 -0
- package/src/components/CardElement.res +4 -0
- package/src/components/CardExpiry.bs.js +24 -0
- package/src/components/CardExpiry.res +6 -0
- package/src/components/CardNumber.bs.js +24 -0
- package/src/components/CardNumber.res +6 -0
- package/src/components/Elements.bs.js +71 -0
- package/src/components/Elements.res +39 -0
- package/src/components/ExpressCheckoutElement.bs.js +24 -0
- package/src/components/ExpressCheckoutElement.res +6 -0
- package/src/components/GooglePayElement.bs.js +24 -0
- package/src/components/GooglePayElement.res +6 -0
- package/src/components/HyperElements.bs.js +71 -0
- package/src/components/HyperElements.res +39 -0
- package/src/components/HyperManagementElements.bs.js +65 -0
- package/src/components/HyperManagementElements.res +41 -0
- package/src/components/PayPalElement.bs.js +24 -0
- package/src/components/PayPalElement.res +6 -0
- package/src/components/PaymentElement.bs.js +24 -0
- package/src/components/PaymentElement.res +6 -0
- package/src/components/PaymentElementsWrapper.bs.js +50 -0
- package/src/components/PaymentElementsWrapper.res +34 -0
- package/src/components/PaymentMethodsManagementElement.bs.js +58 -0
- package/src/components/PaymentMethodsManagementElement.res +45 -0
- package/bsconfig.json +0 -19
package/src/Index.resi
CHANGED
|
@@ -7,124 +7,158 @@ type eventData = {
|
|
|
7
7
|
classChange: bool,
|
|
8
8
|
newClassType: string,
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
let \"Elements": {
|
|
12
|
-
"children": React.element,
|
|
13
|
-
"options": Js.Json.t,
|
|
14
|
-
"stripe": Js.Promise.t<OrcaJs.switchInstance>,
|
|
15
|
-
} => React.element
|
|
16
|
-
|
|
17
|
-
let \"HyperElements": {
|
|
18
|
-
"children": React.element,
|
|
19
|
-
"options": Js.Json.t,
|
|
20
|
-
"hyper": Js.Promise.t<OrcaJs.switchInstance>,
|
|
21
|
-
} => React.element
|
|
22
|
-
|
|
23
|
-
let \"PaymentElement": {
|
|
24
|
-
"id": string,
|
|
25
|
-
"onBlur": option<option<Js.Json.t> => unit>,
|
|
26
|
-
"onChange": option<option<Js.Json.t> => unit>,
|
|
27
|
-
"onClick": option<option<Js.Json.t> => unit>,
|
|
28
|
-
"onFocus": option<option<Js.Json.t> => unit>,
|
|
29
|
-
"onReady": option<option<Js.Json.t> => unit>,
|
|
30
|
-
"options": Js.Json.t,
|
|
31
|
-
} => React.element
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
let \"UnifiedCheckout": {
|
|
35
|
-
"id": string,
|
|
36
|
-
"onBlur": option<option<Js.Json.t> => unit>,
|
|
37
|
-
"onChange": option<option<Js.Json.t> => unit>,
|
|
38
|
-
"onClick": option<option<Js.Json.t> => unit>,
|
|
39
|
-
"onFocus": option<option<Js.Json.t> => unit>,
|
|
40
|
-
"onReady": option<option<Js.Json.t> => unit>,
|
|
41
|
-
"options": Js.Json.t,
|
|
42
|
-
} => React.element
|
|
43
|
-
|
|
44
|
-
let \"CardElement": {
|
|
45
|
-
"id": string,
|
|
46
|
-
"onBlur": option<option<Js.Json.t> => unit>,
|
|
47
|
-
"onChange": option<option<Js.Json.t> => unit>,
|
|
48
|
-
"onClick": option<option<Js.Json.t> => unit>,
|
|
49
|
-
"onFocus": option<option<Js.Json.t> => unit>,
|
|
50
|
-
"onReady": option<option<Js.Json.t> => unit>,
|
|
51
|
-
"options": Js.Json.t,
|
|
52
|
-
} => React.element
|
|
53
|
-
|
|
54
|
-
let \"CardWidget": {
|
|
55
|
-
"id": string,
|
|
56
|
-
"onBlur": option<option<Js.Json.t> => unit>,
|
|
57
|
-
"onChange": option<option<Js.Json.t> => unit>,
|
|
58
|
-
"onClick": option<option<Js.Json.t> => unit>,
|
|
59
|
-
"onFocus": option<option<Js.Json.t> => unit>,
|
|
60
|
-
"onReady": option<option<Js.Json.t> => unit>,
|
|
61
|
-
"options": Js.Json.t,
|
|
62
|
-
} => React.element
|
|
63
|
-
|
|
64
|
-
let \"CardNumberElement": {
|
|
65
|
-
"id": string,
|
|
66
|
-
"onBlur": option<option<Js.Json.t> => unit>,
|
|
67
|
-
"onChange": option<option<Js.Json.t> => unit>,
|
|
68
|
-
"onClick": option<option<Js.Json.t> => unit>,
|
|
69
|
-
"onFocus": option<option<Js.Json.t> => unit>,
|
|
70
|
-
"onReady": option<option<Js.Json.t> => unit>,
|
|
71
|
-
"options": Js.Json.t,
|
|
72
|
-
} => React.element
|
|
73
|
-
|
|
74
|
-
let \"CardNumberWidget": {
|
|
75
|
-
"id": string,
|
|
76
|
-
"onBlur": option<option<Js.Json.t> => unit>,
|
|
77
|
-
"onChange": option<option<Js.Json.t> => unit>,
|
|
78
|
-
"onClick": option<option<Js.Json.t> => unit>,
|
|
79
|
-
"onFocus": option<option<Js.Json.t> => unit>,
|
|
80
|
-
"onReady": option<option<Js.Json.t> => unit>,
|
|
81
|
-
"options": Js.Json.t,
|
|
82
|
-
} => React.element
|
|
83
|
-
|
|
84
|
-
let \"CardExpiryElement": {
|
|
85
|
-
"id": string,
|
|
86
|
-
"onBlur": option<option<Js.Json.t> => unit>,
|
|
87
|
-
"onChange": option<option<Js.Json.t> => unit>,
|
|
88
|
-
"onClick": option<option<Js.Json.t> => unit>,
|
|
89
|
-
"onFocus": option<option<Js.Json.t> => unit>,
|
|
90
|
-
"onReady": option<option<Js.Json.t> => unit>,
|
|
91
|
-
"options": Js.Json.t,
|
|
92
|
-
} => React.element
|
|
93
|
-
|
|
94
|
-
let \"CardExpiryWidget": {
|
|
95
|
-
"id": string,
|
|
96
|
-
"onBlur": option<option<Js.Json.t> => unit>,
|
|
97
|
-
"onChange": option<option<Js.Json.t> => unit>,
|
|
98
|
-
"onClick": option<option<Js.Json.t> => unit>,
|
|
99
|
-
"onFocus": option<option<Js.Json.t> => unit>,
|
|
100
|
-
"onReady": option<option<Js.Json.t> => unit>,
|
|
101
|
-
"options": Js.Json.t,
|
|
102
|
-
} => React.element
|
|
103
|
-
|
|
104
|
-
let \"CardCVCElement": {
|
|
105
|
-
"id": string,
|
|
106
|
-
"onBlur": option<option<Js.Json.t> => unit>,
|
|
107
|
-
"onChange": option<option<Js.Json.t> => unit>,
|
|
108
|
-
"onClick": option<option<Js.Json.t> => unit>,
|
|
109
|
-
"onFocus": option<option<Js.Json.t> => unit>,
|
|
110
|
-
"onReady": option<option<Js.Json.t> => unit>,
|
|
111
|
-
"options": Js.Json.t,
|
|
112
|
-
} => React.element
|
|
113
|
-
|
|
114
|
-
let \"CardCVCWidget": {
|
|
115
|
-
"id": string,
|
|
116
|
-
"onBlur": option<option<Js.Json.t> => unit>,
|
|
117
|
-
"onChange": option<option<Js.Json.t> => unit>,
|
|
118
|
-
"onClick": option<option<Js.Json.t> => unit>,
|
|
119
|
-
"onFocus": option<option<Js.Json.t> => unit>,
|
|
120
|
-
"onReady": option<option<Js.Json.t> => unit>,
|
|
121
|
-
"options": Js.Json.t,
|
|
122
|
-
} => React.element
|
|
123
|
-
|
|
124
|
-
let useStripe: unit => Context.switchContextType
|
|
125
|
-
|
|
126
10
|
let useHyper: unit => Context.switchContextType
|
|
127
|
-
|
|
128
|
-
let useElements: unit => Context.elementsType
|
|
129
|
-
|
|
11
|
+
let useStripe: unit => Context.switchContextType
|
|
130
12
|
let useWidgets: unit => Context.elementsType
|
|
13
|
+
let useElements: unit => Context.elementsType
|
|
14
|
+
let \"Elements": Elements.props<
|
|
15
|
+
React.element,
|
|
16
|
+
RescriptCore.Promise.t<OrcaJs.switchInstance>,
|
|
17
|
+
RescriptCore.JSON.t,
|
|
18
|
+
> => React.element
|
|
19
|
+
let \"HyperElements": HyperElements.props<
|
|
20
|
+
React.element,
|
|
21
|
+
RescriptCore.Promise.t<OrcaJs.switchInstance>,
|
|
22
|
+
RescriptCore.JSON.t,
|
|
23
|
+
> => React.element
|
|
24
|
+
let \"PaymentElement": PaymentElement.props<
|
|
25
|
+
string,
|
|
26
|
+
RescriptCore.JSON.t,
|
|
27
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
28
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
29
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
30
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
31
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
32
|
+
> => React.element
|
|
33
|
+
let \"UnifiedCheckout": PaymentElement.props<
|
|
34
|
+
string,
|
|
35
|
+
RescriptCore.JSON.t,
|
|
36
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
37
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
38
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
39
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
40
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
41
|
+
> => React.element
|
|
42
|
+
let \"CardElement": CardElement.props<
|
|
43
|
+
string,
|
|
44
|
+
RescriptCore.JSON.t,
|
|
45
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
46
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
47
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
48
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
49
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
50
|
+
> => React.element
|
|
51
|
+
let \"CardWidget": CardElement.props<
|
|
52
|
+
string,
|
|
53
|
+
RescriptCore.JSON.t,
|
|
54
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
55
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
56
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
57
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
58
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
59
|
+
> => React.element
|
|
60
|
+
let \"CardNumberElement": CardNumber.props<
|
|
61
|
+
string,
|
|
62
|
+
RescriptCore.JSON.t,
|
|
63
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
64
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
65
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
66
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
67
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
68
|
+
> => React.element
|
|
69
|
+
let \"CardNumberWidget": CardNumber.props<
|
|
70
|
+
string,
|
|
71
|
+
RescriptCore.JSON.t,
|
|
72
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
73
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
74
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
75
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
76
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
77
|
+
> => React.element
|
|
78
|
+
let \"CardCVCElement": CardCVC.props<
|
|
79
|
+
string,
|
|
80
|
+
RescriptCore.JSON.t,
|
|
81
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
82
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
83
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
84
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
85
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
86
|
+
> => React.element
|
|
87
|
+
let \"CardCVCWidget": CardCVC.props<
|
|
88
|
+
string,
|
|
89
|
+
RescriptCore.JSON.t,
|
|
90
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
91
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
92
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
93
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
94
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
95
|
+
> => React.element
|
|
96
|
+
let \"CardExpiryElement": CardExpiry.props<
|
|
97
|
+
string,
|
|
98
|
+
RescriptCore.JSON.t,
|
|
99
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
100
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
101
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
102
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
103
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
104
|
+
> => React.element
|
|
105
|
+
let \"CardExpiryWidget": CardExpiry.props<
|
|
106
|
+
string,
|
|
107
|
+
RescriptCore.JSON.t,
|
|
108
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
109
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
110
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
111
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
112
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
113
|
+
> => React.element
|
|
114
|
+
let \"GooglePayElement": GooglePayElement.props<
|
|
115
|
+
string,
|
|
116
|
+
RescriptCore.JSON.t,
|
|
117
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
118
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
119
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
120
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
121
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
122
|
+
> => React.element
|
|
123
|
+
let \"ApplePayElement": ApplePayElement.props<
|
|
124
|
+
string,
|
|
125
|
+
RescriptCore.JSON.t,
|
|
126
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
127
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
128
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
129
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
130
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
131
|
+
> => React.element
|
|
132
|
+
let \"PayPalElement": PayPalElement.props<
|
|
133
|
+
string,
|
|
134
|
+
RescriptCore.JSON.t,
|
|
135
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
136
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
137
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
138
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
139
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
140
|
+
> => React.element
|
|
141
|
+
let \"ExpressCheckoutElement": ExpressCheckoutElement.props<
|
|
142
|
+
string,
|
|
143
|
+
RescriptCore.JSON.t,
|
|
144
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
145
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
146
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
147
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
148
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
149
|
+
> => React.element
|
|
150
|
+
let \"HyperManagementElements": HyperManagementElements.props<
|
|
151
|
+
React.element,
|
|
152
|
+
RescriptCore.Promise.t<OrcaJs.switchInstance>,
|
|
153
|
+
RescriptCore.JSON.t,
|
|
154
|
+
> => React.element
|
|
155
|
+
let \"PaymentMethodsManagementElement": PaymentMethodsManagementElement.props<
|
|
156
|
+
string,
|
|
157
|
+
RescriptCore.JSON.t,
|
|
158
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
159
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
160
|
+
string,
|
|
161
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
162
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
163
|
+
option<option<RescriptCore.JSON.t> => unit>,
|
|
164
|
+
> => Jsx.element
|
package/src/OrcaJs.bs.js
CHANGED
|
@@ -7,11 +7,11 @@ function defaultPaymentElement_on(_str, _func) {
|
|
|
7
7
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
function defaultPaymentElement_collapse(
|
|
10
|
+
function defaultPaymentElement_collapse() {
|
|
11
11
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
function defaultPaymentElement_blur(
|
|
14
|
+
function defaultPaymentElement_blur() {
|
|
15
15
|
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -19,11 +19,11 @@ function defaultPaymentElement_update(_x) {
|
|
|
19
19
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
function defaultPaymentElement_destroy(
|
|
22
|
+
function defaultPaymentElement_destroy() {
|
|
23
23
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
function defaultPaymentElement_unmount(
|
|
26
|
+
function defaultPaymentElement_unmount() {
|
|
27
27
|
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -31,11 +31,11 @@ function defaultPaymentElement_mount(_string) {
|
|
|
31
31
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
function defaultPaymentElement_focus(
|
|
34
|
+
function defaultPaymentElement_focus() {
|
|
35
35
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
function defaultPaymentElement_clear(
|
|
38
|
+
function defaultPaymentElement_clear() {
|
|
39
39
|
|
|
40
40
|
}
|
|
41
41
|
|
package/src/OrcaJs.res
CHANGED
|
@@ -18,10 +18,10 @@ module This = {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
type paymentElement = {
|
|
21
|
-
on: (string, option<option<
|
|
21
|
+
on: (string, option<option<JSON.t> => unit>) => unit,
|
|
22
22
|
collapse: unit => unit,
|
|
23
23
|
blur: unit => unit,
|
|
24
|
-
update:
|
|
24
|
+
update: JSON.t => unit,
|
|
25
25
|
destroy: unit => unit,
|
|
26
26
|
unmount: unit => unit,
|
|
27
27
|
mount: string => unit,
|
|
@@ -42,25 +42,24 @@ let defaultPaymentElement = {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
type element = {
|
|
45
|
-
getElement:
|
|
46
|
-
update:
|
|
47
|
-
fetchUpdates: unit =>
|
|
48
|
-
create: (
|
|
45
|
+
getElement: string => option<paymentElement>,
|
|
46
|
+
update: JSON.t => unit,
|
|
47
|
+
fetchUpdates: unit => Promise.t<JSON.t>,
|
|
48
|
+
create: (string, JSON.t) => paymentElement,
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
type confirmParams = {return_url: string}
|
|
52
52
|
|
|
53
53
|
type confirmPaymentParams = {
|
|
54
|
-
elements:
|
|
55
|
-
confirmParams:
|
|
54
|
+
elements: JSON.t,
|
|
55
|
+
confirmParams: Nullable.t<confirmParams>,
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
type switchInstance = {
|
|
59
|
-
confirmPayment:
|
|
60
|
-
elements:
|
|
61
|
-
confirmCardPayment:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
paymentRequest: Js.Json.t => Js.Json.t,
|
|
59
|
+
confirmPayment: JSON.t => Promise.t<JSON.t>,
|
|
60
|
+
elements: JSON.t => element,
|
|
61
|
+
confirmCardPayment: (string, option<JSON.t>, option<JSON.t>) => Promise.t<JSON.t>,
|
|
62
|
+
retrievePaymentIntent: string => Promise.t<JSON.t>,
|
|
63
|
+
paymentRequest: JSON.t => JSON.t,
|
|
64
|
+
paymentMethodsManagementElements: JSON.t => element,
|
|
66
65
|
}
|
package/src/Window.res
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
type window
|
|
2
2
|
type parent
|
|
3
3
|
|
|
4
|
-
type event = {data:
|
|
4
|
+
type event = {data: JSON.t}
|
|
5
5
|
@val @scope("window")
|
|
6
6
|
external addEventListener: (string, _ => unit) => unit = "addEventListener"
|
|
7
7
|
@val @scope("window")
|
|
@@ -10,7 +10,7 @@ external removeEventListener: (string, 'ev => unit) => unit = "removeEventListen
|
|
|
10
10
|
@val external window: window = "window"
|
|
11
11
|
@val @scope("window") external iframeParent: parent = "parent"
|
|
12
12
|
|
|
13
|
-
external eventToJson: event =>
|
|
13
|
+
external eventToJson: event => JSON.t = "%identity"
|
|
14
14
|
|
|
15
15
|
@val @scope(("window", "location"))
|
|
16
16
|
external replace: string => unit = "replace"
|
|
@@ -22,5 +22,5 @@ type domElement
|
|
|
22
22
|
external contentWindow: Js.nullable<Dom.element> => domElement = "contentWindow"
|
|
23
23
|
|
|
24
24
|
let iframePostMessage = (iframeRef: React.ref<Js.nullable<Dom.element>>, message) => {
|
|
25
|
-
iframeRef.current->contentWindow->postMessage(message->
|
|
25
|
+
iframeRef.current->contentWindow->postMessage(message->JSON.stringify, "*")
|
|
26
26
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as JsxRuntime from "react/jsx-runtime";
|
|
4
|
+
import * as PaymentElementsWrapper from "./PaymentElementsWrapper.bs.js";
|
|
5
|
+
|
|
6
|
+
function ApplePayElement(props) {
|
|
7
|
+
return JsxRuntime.jsx(PaymentElementsWrapper.make, {
|
|
8
|
+
id: props.id,
|
|
9
|
+
options: props.options,
|
|
10
|
+
onChange: props.onChange,
|
|
11
|
+
onReady: props.onReady,
|
|
12
|
+
componentType: "applePay",
|
|
13
|
+
onFocus: props.onFocus,
|
|
14
|
+
onBlur: props.onBlur,
|
|
15
|
+
onClick: props.onClick
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var make = ApplePayElement;
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
make ,
|
|
23
|
+
}
|
|
24
|
+
/* react/jsx-runtime Not a pure module */
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as JsxRuntime from "react/jsx-runtime";
|
|
4
|
+
import * as PaymentElementsWrapper from "./PaymentElementsWrapper.bs.js";
|
|
5
|
+
|
|
6
|
+
function CardCVC(props) {
|
|
7
|
+
return JsxRuntime.jsx(PaymentElementsWrapper.make, {
|
|
8
|
+
id: props.id,
|
|
9
|
+
options: props.options,
|
|
10
|
+
onChange: props.onChange,
|
|
11
|
+
onReady: props.onReady,
|
|
12
|
+
componentType: "cardCvc",
|
|
13
|
+
onFocus: props.onFocus,
|
|
14
|
+
onBlur: props.onBlur,
|
|
15
|
+
onClick: props.onClick
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var make = CardCVC;
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
make ,
|
|
23
|
+
}
|
|
24
|
+
/* react/jsx-runtime Not a pure module */
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as JsxRuntime from "react/jsx-runtime";
|
|
4
|
+
import * as PaymentElementsWrapper from "./PaymentElementsWrapper.bs.js";
|
|
5
|
+
|
|
6
|
+
function CardElement(props) {
|
|
7
|
+
return JsxRuntime.jsx(PaymentElementsWrapper.make, {
|
|
8
|
+
id: props.id,
|
|
9
|
+
options: props.options,
|
|
10
|
+
onChange: props.onChange,
|
|
11
|
+
onReady: props.onReady,
|
|
12
|
+
componentType: "card",
|
|
13
|
+
onFocus: props.onFocus,
|
|
14
|
+
onBlur: props.onBlur,
|
|
15
|
+
onClick: props.onClick
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var make = CardElement;
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
make ,
|
|
23
|
+
}
|
|
24
|
+
/* react/jsx-runtime Not a pure module */
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as JsxRuntime from "react/jsx-runtime";
|
|
4
|
+
import * as PaymentElementsWrapper from "./PaymentElementsWrapper.bs.js";
|
|
5
|
+
|
|
6
|
+
function CardExpiry(props) {
|
|
7
|
+
return JsxRuntime.jsx(PaymentElementsWrapper.make, {
|
|
8
|
+
id: props.id,
|
|
9
|
+
options: props.options,
|
|
10
|
+
onChange: props.onChange,
|
|
11
|
+
onReady: props.onReady,
|
|
12
|
+
componentType: "cardExpiry",
|
|
13
|
+
onFocus: props.onFocus,
|
|
14
|
+
onBlur: props.onBlur,
|
|
15
|
+
onClick: props.onClick
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var make = CardExpiry;
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
make ,
|
|
23
|
+
}
|
|
24
|
+
/* react/jsx-runtime Not a pure module */
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as JsxRuntime from "react/jsx-runtime";
|
|
4
|
+
import * as PaymentElementsWrapper from "./PaymentElementsWrapper.bs.js";
|
|
5
|
+
|
|
6
|
+
function CardNumber(props) {
|
|
7
|
+
return JsxRuntime.jsx(PaymentElementsWrapper.make, {
|
|
8
|
+
id: props.id,
|
|
9
|
+
options: props.options,
|
|
10
|
+
onChange: props.onChange,
|
|
11
|
+
onReady: props.onReady,
|
|
12
|
+
componentType: "cardNumber",
|
|
13
|
+
onFocus: props.onFocus,
|
|
14
|
+
onBlur: props.onBlur,
|
|
15
|
+
onClick: props.onClick
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var make = CardNumber;
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
make ,
|
|
23
|
+
}
|
|
24
|
+
/* react/jsx-runtime Not a pure module */
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as Context from "../Context.bs.js";
|
|
5
|
+
import * as Js_promise from "rescript/lib/es6/js_promise.js";
|
|
6
|
+
import * as JsxRuntime from "react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
function Elements(props) {
|
|
9
|
+
var options = props.options;
|
|
10
|
+
var stripe = props.stripe;
|
|
11
|
+
var elementOptions = Context.elementsOptionObjMapper(options);
|
|
12
|
+
var match = React.useState(function () {
|
|
13
|
+
return Context.defaultSwitchContext;
|
|
14
|
+
});
|
|
15
|
+
var setSwitchState = match[1];
|
|
16
|
+
var match$1 = React.useState(function () {
|
|
17
|
+
return Context.defaultElementsContext;
|
|
18
|
+
});
|
|
19
|
+
var setElementsState = match$1[1];
|
|
20
|
+
React.useEffect((function () {
|
|
21
|
+
((function (__x) {
|
|
22
|
+
return Js_promise.then_((function (switchInstance) {
|
|
23
|
+
var orcaElementsConfig = switchInstance.elements(options);
|
|
24
|
+
var newElemValues_update = orcaElementsConfig.update;
|
|
25
|
+
var newElemValues_getElement = orcaElementsConfig.getElement;
|
|
26
|
+
var newElemValues_fetchUpdates = orcaElementsConfig.fetchUpdates;
|
|
27
|
+
var newElemValues_create = orcaElementsConfig.create;
|
|
28
|
+
var newElemValues = {
|
|
29
|
+
options: elementOptions,
|
|
30
|
+
update: newElemValues_update,
|
|
31
|
+
getElement: newElemValues_getElement,
|
|
32
|
+
fetchUpdates: newElemValues_fetchUpdates,
|
|
33
|
+
create: newElemValues_create
|
|
34
|
+
};
|
|
35
|
+
var switchValClone_clientSecret = elementOptions.clientSecret;
|
|
36
|
+
var switchValClone_confirmPayment = switchInstance.confirmPayment;
|
|
37
|
+
var switchValClone_confirmCardPayment = switchInstance.confirmCardPayment;
|
|
38
|
+
var switchValClone_retrievePaymentIntent = switchInstance.retrievePaymentIntent;
|
|
39
|
+
var switchValClone_paymentRequest = switchInstance.paymentRequest;
|
|
40
|
+
var switchValClone = {
|
|
41
|
+
clientSecret: switchValClone_clientSecret,
|
|
42
|
+
confirmPayment: switchValClone_confirmPayment,
|
|
43
|
+
confirmCardPayment: switchValClone_confirmCardPayment,
|
|
44
|
+
retrievePaymentIntent: switchValClone_retrievePaymentIntent,
|
|
45
|
+
paymentRequest: switchValClone_paymentRequest
|
|
46
|
+
};
|
|
47
|
+
setSwitchState(function (param) {
|
|
48
|
+
return switchValClone;
|
|
49
|
+
});
|
|
50
|
+
setElementsState(function (param) {
|
|
51
|
+
return newElemValues;
|
|
52
|
+
});
|
|
53
|
+
return Promise.resolve(switchValClone);
|
|
54
|
+
}), __x);
|
|
55
|
+
})(stripe));
|
|
56
|
+
}), []);
|
|
57
|
+
return JsxRuntime.jsx(Context.SwitchContextProvider.make, {
|
|
58
|
+
value: match[0],
|
|
59
|
+
children: JsxRuntime.jsx(Context.ElementsContextProvider.make, {
|
|
60
|
+
value: match$1[0],
|
|
61
|
+
children: props.children
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
var make = Elements;
|
|
67
|
+
|
|
68
|
+
export {
|
|
69
|
+
make ,
|
|
70
|
+
}
|
|
71
|
+
/* react Not a pure module */
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
@react.component
|
|
2
|
+
let make = (~children, ~stripe: Promise.t<OrcaJs.switchInstance>, ~options: JSON.t) => {
|
|
3
|
+
let elementOptions = options->Context.elementsOptionObjMapper
|
|
4
|
+
let (switchState, setSwitchState) = React.useState(() => Context.defaultSwitchContext)
|
|
5
|
+
let (elementsState, setElementsState) = React.useState(() => Context.defaultElementsContext)
|
|
6
|
+
|
|
7
|
+
React.useEffect0(() => {
|
|
8
|
+
stripe
|
|
9
|
+
->(Js.Promise.then_((switchInstance: OrcaJs.switchInstance) => {
|
|
10
|
+
let orcaElementsConfig = switchInstance.elements(options)
|
|
11
|
+
let newElemValues: Context.elementsType = {
|
|
12
|
+
options: elementOptions,
|
|
13
|
+
update: orcaElementsConfig.update,
|
|
14
|
+
getElement: orcaElementsConfig.getElement,
|
|
15
|
+
fetchUpdates: orcaElementsConfig.fetchUpdates,
|
|
16
|
+
create: orcaElementsConfig.create,
|
|
17
|
+
}
|
|
18
|
+
let switchValClone: Context.switchContextType = {
|
|
19
|
+
confirmPayment: switchInstance.confirmPayment,
|
|
20
|
+
confirmCardPayment: switchInstance.confirmCardPayment,
|
|
21
|
+
retrievePaymentIntent: switchInstance.retrievePaymentIntent,
|
|
22
|
+
clientSecret: elementOptions.clientSecret,
|
|
23
|
+
paymentRequest: switchInstance.paymentRequest,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
setSwitchState(_ => switchValClone)
|
|
27
|
+
setElementsState(_ => newElemValues)
|
|
28
|
+
Promise.resolve(switchValClone)
|
|
29
|
+
}, _))
|
|
30
|
+
->ignore
|
|
31
|
+
None
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
<Context.SwitchContextProvider value={switchState}>
|
|
35
|
+
<Context.ElementsContextProvider value={elementsState}>
|
|
36
|
+
{children}
|
|
37
|
+
</Context.ElementsContextProvider>
|
|
38
|
+
</Context.SwitchContextProvider>
|
|
39
|
+
}
|