@benbraide/inlinejs-stripe 2.2.0 → 2.3.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/dist/inlinejs-stripe.js +2741 -954
- package/dist/inlinejs-stripe.min.js +2 -1
- package/dist/inlinejs-stripe.min.js.LICENSE.txt +1 -0
- package/lib/common/components/detail.d.ts +1 -2
- package/lib/common/components/detail.js +11 -7
- package/lib/common/components/field.d.ts +3 -3
- package/lib/common/components/field.js +43 -41
- package/lib/common/components/stripe.d.ts +3 -3
- package/lib/common/components/stripe.js +18 -18
- package/lib/common/index.d.ts +0 -1
- package/lib/common/index.js +0 -1
- package/lib/esm/components/detail.d.ts +1 -2
- package/lib/esm/components/detail.js +11 -7
- package/lib/esm/components/field.d.ts +3 -3
- package/lib/esm/components/field.js +44 -42
- package/lib/esm/components/stripe.d.ts +3 -3
- package/lib/esm/components/stripe.js +18 -18
- package/lib/esm/index.d.ts +0 -1
- package/lib/esm/index.js +0 -1
- package/package.json +3 -3
- package/lib/common/directive/stripe.d.ts +0 -24
- package/lib/common/directive/stripe.js +0 -453
- package/lib/esm/directive/stripe.d.ts +0 -24
- package/lib/esm/directive/stripe.js +0 -449
@@ -0,0 +1 @@
|
|
1
|
+
/*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */
|
@@ -3,8 +3,7 @@ import { StripeGenericField } from "./generic-field";
|
|
3
3
|
export declare class StripeDetailElement extends StripeGenericField {
|
4
4
|
input: HTMLInputElement | null;
|
5
5
|
name: string;
|
6
|
-
value:
|
7
|
-
constructor();
|
6
|
+
value: any;
|
8
7
|
ToggleFocus(focused: boolean): void;
|
9
8
|
Reset(): void;
|
10
9
|
AddDetails(details: IStripePaymentDetails): void;
|
@@ -11,7 +11,7 @@ const inlinejs_element_1 = require("@benbraide/inlinejs-element");
|
|
11
11
|
const generic_field_1 = require("./generic-field");
|
12
12
|
class StripeDetailElement extends generic_field_1.StripeGenericField {
|
13
13
|
constructor() {
|
14
|
-
super();
|
14
|
+
super(...arguments);
|
15
15
|
this.input = null;
|
16
16
|
this.name = '';
|
17
17
|
this.value = '';
|
@@ -30,13 +30,17 @@ class StripeDetailElement extends generic_field_1.StripeGenericField {
|
|
30
30
|
return;
|
31
31
|
}
|
32
32
|
details.billingDetails = (details.billingDetails || {});
|
33
|
-
|
34
|
-
|
35
|
-
details.billingDetails.address.line1 = ((input === null || input === void 0 ? void 0 : input.value) || this.value);
|
36
|
-
}
|
37
|
-
else {
|
33
|
+
const nameParts = this.name.split('.');
|
34
|
+
if (nameParts.length == 1) {
|
38
35
|
details.billingDetails[this.name] = ((input === null || input === void 0 ? void 0 : input.value) || this.value);
|
39
36
|
}
|
37
|
+
else { //Path
|
38
|
+
let current = details.billingDetails;
|
39
|
+
nameParts.slice(0, -1).forEach((part) => {
|
40
|
+
current = (current[part] = (current[part] || {}));
|
41
|
+
});
|
42
|
+
current[nameParts.slice(-1)[0]] = ((input === null || input === void 0 ? void 0 : input.value) || this.value);
|
43
|
+
}
|
40
44
|
}
|
41
45
|
GetInput_() {
|
42
46
|
return (this.input || this.querySelector('input'));
|
@@ -49,7 +53,7 @@ __decorate([
|
|
49
53
|
(0, inlinejs_element_1.Property)({ type: 'string' })
|
50
54
|
], StripeDetailElement.prototype, "name", void 0);
|
51
55
|
__decorate([
|
52
|
-
(0, inlinejs_element_1.Property)({ type: 'string' })
|
56
|
+
(0, inlinejs_element_1.Property)({ type: 'string', checkStoredObject: true })
|
53
57
|
], StripeDetailElement.prototype, "value", void 0);
|
54
58
|
exports.StripeDetailElement = StripeDetailElement;
|
55
59
|
function StripeDetailElementCompact() {
|
@@ -11,9 +11,9 @@ export declare class StripeFieldElement extends StripeGenericField {
|
|
11
11
|
protected changeListeners: StripeFieldChangeHandlerType[];
|
12
12
|
options: stripe.elements.ElementsOptions | null;
|
13
13
|
type: string;
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
oncustomready: string;
|
15
|
+
oncustomcomplete: string;
|
16
|
+
oncustomerror: string;
|
17
17
|
constructor();
|
18
18
|
IsInteractive(): boolean;
|
19
19
|
WaitReady(): Promise<void>;
|
@@ -32,9 +32,9 @@ class StripeFieldElement extends generic_field_1.StripeGenericField {
|
|
32
32
|
this.changeListeners = new Array();
|
33
33
|
this.options = null;
|
34
34
|
this.type = '';
|
35
|
-
this.
|
36
|
-
this.
|
37
|
-
this.
|
35
|
+
this.oncustomready = '';
|
36
|
+
this.oncustomcomplete = '';
|
37
|
+
this.oncustomerror = '';
|
38
38
|
}
|
39
39
|
IsInteractive() {
|
40
40
|
return true;
|
@@ -69,7 +69,7 @@ class StripeFieldElement extends generic_field_1.StripeGenericField {
|
|
69
69
|
var _a;
|
70
70
|
(_a = this.GetStripe_()) === null || _a === void 0 ? void 0 : _a.WaitInstance().then((details) => {
|
71
71
|
var _a;
|
72
|
-
if (!(details === null || details === void 0 ? void 0 : details.stripe)) {
|
72
|
+
if (!(details === null || details === void 0 ? void 0 : details.stripe) || !details.elements) {
|
73
73
|
return;
|
74
74
|
}
|
75
75
|
let type = '';
|
@@ -79,43 +79,45 @@ class StripeFieldElement extends generic_field_1.StripeGenericField {
|
|
79
79
|
else if (['card', 'cardNumber', 'cardExpiry', 'cardCvc', 'postalCode', 'paymentRequestButton', 'iban', 'idealBank'].includes(this.type)) {
|
80
80
|
type = this.type;
|
81
81
|
}
|
82
|
-
if (type
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
82
|
+
if (!type) {
|
83
|
+
(0, inlinejs_1.JournalWarn)('The element type provided is invalid.', 'StripeField.Mount', this);
|
84
|
+
return;
|
85
|
+
}
|
86
|
+
this.stripeField_ = details.elements.create(type, (this.options || ((_a = this.GetStripe_()) === null || _a === void 0 ? void 0 : _a.options) || undefined));
|
87
|
+
this.stripeField_.on('ready', () => {
|
88
|
+
this.isReady_ = true;
|
89
|
+
this.oncustomready && (0, inlinejs_1.EvaluateLater)({
|
90
|
+
componentId: this.componentId_,
|
91
|
+
contextElement: this,
|
92
|
+
expression: this.oncustomready,
|
93
|
+
disableFunctionCall: false,
|
94
|
+
})();
|
95
|
+
this.readyWaiters_.splice(0).forEach(waiter => (0, inlinejs_1.JournalTry)(waiter));
|
96
|
+
});
|
97
|
+
this.stripeField_.on('change', (event) => {
|
98
|
+
if (((event === null || event === void 0 ? void 0 : event.error) || null) !== this.lastError_) {
|
99
|
+
this.lastError_ = ((event === null || event === void 0 ? void 0 : event.error) || null);
|
100
|
+
this.oncustomerror && (0, inlinejs_1.EvaluateLater)({
|
87
101
|
componentId: this.componentId_,
|
88
102
|
contextElement: this,
|
89
|
-
expression: this.
|
103
|
+
expression: this.oncustomerror,
|
90
104
|
disableFunctionCall: false,
|
91
|
-
})();
|
92
|
-
this.
|
93
|
-
}
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
(0, inlinejs_1.EvaluateLater)({
|
108
|
-
componentId: this.componentId_,
|
109
|
-
contextElement: this,
|
110
|
-
expression: this.oncomplete,
|
111
|
-
disableFunctionCall: false,
|
112
|
-
})(undefined, [this.isComplete_], { complete: this.isComplete_ });
|
113
|
-
this.changeListeners.forEach(listener => (0, inlinejs_1.JournalTry)(() => listener('complete', this.isComplete_)));
|
114
|
-
}
|
115
|
-
});
|
116
|
-
this.stripeField_.mount(this);
|
117
|
-
}
|
118
|
-
});
|
105
|
+
})(undefined, [this.lastError_], { error: this.lastError_ });
|
106
|
+
this.changeListeners.forEach(listener => (0, inlinejs_1.JournalTry)(() => listener('error', this.lastError_)));
|
107
|
+
}
|
108
|
+
if (((event === null || event === void 0 ? void 0 : event.complete) || false) != this.isComplete_) {
|
109
|
+
this.isComplete_ = ((event === null || event === void 0 ? void 0 : event.complete) || false);
|
110
|
+
this.oncustomcomplete && (0, inlinejs_1.EvaluateLater)({
|
111
|
+
componentId: this.componentId_,
|
112
|
+
contextElement: this,
|
113
|
+
expression: this.oncustomcomplete,
|
114
|
+
disableFunctionCall: false,
|
115
|
+
})(undefined, [this.isComplete_], { complete: this.isComplete_ });
|
116
|
+
this.changeListeners.forEach(listener => (0, inlinejs_1.JournalTry)(() => listener('complete', this.isComplete_)));
|
117
|
+
}
|
118
|
+
});
|
119
|
+
this.stripeField_.mount(this);
|
120
|
+
}).catch(err => (0, inlinejs_1.JournalError)(err, 'StripeField.Mount', this));
|
119
121
|
});
|
120
122
|
scope.AddUninitCallback(() => {
|
121
123
|
var _a;
|
@@ -132,13 +134,13 @@ __decorate([
|
|
132
134
|
], StripeFieldElement.prototype, "type", void 0);
|
133
135
|
__decorate([
|
134
136
|
(0, inlinejs_element_1.Property)({ type: 'string' })
|
135
|
-
], StripeFieldElement.prototype, "
|
137
|
+
], StripeFieldElement.prototype, "oncustomready", void 0);
|
136
138
|
__decorate([
|
137
139
|
(0, inlinejs_element_1.Property)({ type: 'string' })
|
138
|
-
], StripeFieldElement.prototype, "
|
140
|
+
], StripeFieldElement.prototype, "oncustomcomplete", void 0);
|
139
141
|
__decorate([
|
140
142
|
(0, inlinejs_element_1.Property)({ type: 'string' })
|
141
|
-
], StripeFieldElement.prototype, "
|
143
|
+
], StripeFieldElement.prototype, "oncustomerror", void 0);
|
142
144
|
exports.StripeFieldElement = StripeFieldElement;
|
143
145
|
function StripeFieldElementCompact() {
|
144
146
|
(0, inlinejs_element_1.RegisterCustomElement)(StripeFieldElement, 'stripe-field');
|
@@ -17,9 +17,9 @@ export declare class StripeElement extends CustomElement implements IStripeEleme
|
|
17
17
|
protected errorFields_: Array<IStripeField> | null;
|
18
18
|
options: stripe.elements.ElementsOptions | null;
|
19
19
|
publicKey: string;
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
oncustomready: string;
|
21
|
+
oncustomcomplete: string;
|
22
|
+
oncustomerror: string;
|
23
23
|
defer: boolean;
|
24
24
|
focusnext: boolean;
|
25
25
|
constructor();
|
@@ -37,9 +37,9 @@ class StripeElement extends inlinejs_element_1.CustomElement {
|
|
37
37
|
this.errorFields_ = null;
|
38
38
|
this.options = null;
|
39
39
|
this.publicKey = '';
|
40
|
-
this.
|
41
|
-
this.
|
42
|
-
this.
|
40
|
+
this.oncustomready = '';
|
41
|
+
this.oncustomcomplete = '';
|
42
|
+
this.oncustomerror = '';
|
43
43
|
this.defer = false;
|
44
44
|
this.focusnext = false;
|
45
45
|
}
|
@@ -55,10 +55,10 @@ class StripeElement extends inlinejs_element_1.CustomElement {
|
|
55
55
|
}
|
56
56
|
(this.fields_ && this.readyFields_ && this.fields_.length <= this.readyFields_.length) && (0, inlinejs_1.JournalTry)(() => {
|
57
57
|
this.isReady_ = true;
|
58
|
-
this.
|
58
|
+
this.oncustomready && (0, inlinejs_1.EvaluateLater)({
|
59
59
|
componentId: this.componentId_,
|
60
60
|
contextElement: this,
|
61
|
-
expression: this.
|
61
|
+
expression: this.oncustomready,
|
62
62
|
disableFunctionCall: false,
|
63
63
|
})();
|
64
64
|
this.readyWaiters_.splice(0).forEach(waiter => (0, inlinejs_1.JournalTry)(waiter));
|
@@ -76,10 +76,10 @@ class StripeElement extends inlinejs_element_1.CustomElement {
|
|
76
76
|
this.completeFields_ = this.completeFields_.filter(x => x !== field);
|
77
77
|
changed = !!(this.interactiveFields_ && (this.completeFields_.length == (this.interactiveFields_.length - 1)));
|
78
78
|
}
|
79
|
-
changed && this.
|
79
|
+
changed && this.oncustomcomplete && (0, inlinejs_1.EvaluateLater)({
|
80
80
|
componentId: this.componentId_,
|
81
81
|
contextElement: this,
|
82
|
-
expression: this.
|
82
|
+
expression: this.oncustomcomplete,
|
83
83
|
disableFunctionCall: false,
|
84
84
|
})(undefined, [!!data], { complete: !!data });
|
85
85
|
!!data && this.focusnext && this.FocusNextField(field);
|
@@ -97,10 +97,10 @@ class StripeElement extends inlinejs_element_1.CustomElement {
|
|
97
97
|
this.errorFields_ = this.errorFields_.filter(x => x !== field);
|
98
98
|
changed = (this.errorFields_.length == 0);
|
99
99
|
}
|
100
|
-
changed && this.
|
100
|
+
changed && this.oncustomerror && (0, inlinejs_1.EvaluateLater)({
|
101
101
|
componentId: this.componentId_,
|
102
102
|
contextElement: this,
|
103
|
-
expression: this.
|
103
|
+
expression: this.oncustomerror,
|
104
104
|
disableFunctionCall: false,
|
105
105
|
})(undefined, [data], { error: data });
|
106
106
|
}
|
@@ -176,7 +176,12 @@ class StripeElement extends inlinejs_element_1.CustomElement {
|
|
176
176
|
return resolve(false);
|
177
177
|
}
|
178
178
|
let cardDetails;
|
179
|
-
if (typeof paymentDetails.method
|
179
|
+
if (typeof paymentDetails.method === 'string') { // Payment Method ID
|
180
|
+
cardDetails = {
|
181
|
+
payment_method: paymentDetails.method,
|
182
|
+
};
|
183
|
+
}
|
184
|
+
else { // Stripe Element (e.g., CardElement)
|
180
185
|
cardDetails = {
|
181
186
|
payment_method: {
|
182
187
|
card: paymentDetails.method,
|
@@ -184,11 +189,6 @@ class StripeElement extends inlinejs_element_1.CustomElement {
|
|
184
189
|
},
|
185
190
|
};
|
186
191
|
}
|
187
|
-
else {
|
188
|
-
cardDetails = {
|
189
|
-
payment_method: paymentDetails.method,
|
190
|
-
};
|
191
|
-
}
|
192
192
|
if (pay) {
|
193
193
|
((_b = paymentDetails.billingDetails) === null || _b === void 0 ? void 0 : _b.email) && (cardDetails.receipt_email = paymentDetails.billingDetails.email);
|
194
194
|
save && (cardDetails.setup_future_usage = 'off_session');
|
@@ -209,13 +209,13 @@ __decorate([
|
|
209
209
|
], StripeElement.prototype, "publicKey", void 0);
|
210
210
|
__decorate([
|
211
211
|
(0, inlinejs_element_1.Property)({ type: 'string' })
|
212
|
-
], StripeElement.prototype, "
|
212
|
+
], StripeElement.prototype, "oncustomready", void 0);
|
213
213
|
__decorate([
|
214
214
|
(0, inlinejs_element_1.Property)({ type: 'string' })
|
215
|
-
], StripeElement.prototype, "
|
215
|
+
], StripeElement.prototype, "oncustomcomplete", void 0);
|
216
216
|
__decorate([
|
217
217
|
(0, inlinejs_element_1.Property)({ type: 'string' })
|
218
|
-
], StripeElement.prototype, "
|
218
|
+
], StripeElement.prototype, "oncustomerror", void 0);
|
219
219
|
__decorate([
|
220
220
|
(0, inlinejs_element_1.Property)({ type: 'boolean' })
|
221
221
|
], StripeElement.prototype, "defer", void 0);
|
package/lib/common/index.d.ts
CHANGED
package/lib/common/index.js
CHANGED
@@ -18,5 +18,4 @@ __exportStar(require("./components/stripe"), exports);
|
|
18
18
|
__exportStar(require("./components/field"), exports);
|
19
19
|
__exportStar(require("./components/detail"), exports);
|
20
20
|
__exportStar(require("./components/payment-method"), exports);
|
21
|
-
__exportStar(require("./directive/stripe"), exports);
|
22
21
|
__exportStar(require("./entry"), exports);
|
@@ -3,8 +3,7 @@ import { StripeGenericField } from "./generic-field";
|
|
3
3
|
export declare class StripeDetailElement extends StripeGenericField {
|
4
4
|
input: HTMLInputElement | null;
|
5
5
|
name: string;
|
6
|
-
value:
|
7
|
-
constructor();
|
6
|
+
value: any;
|
8
7
|
ToggleFocus(focused: boolean): void;
|
9
8
|
Reset(): void;
|
10
9
|
AddDetails(details: IStripePaymentDetails): void;
|
@@ -8,7 +8,7 @@ import { Property, RegisterCustomElement } from "@benbraide/inlinejs-element";
|
|
8
8
|
import { StripeGenericField } from "./generic-field";
|
9
9
|
export class StripeDetailElement extends StripeGenericField {
|
10
10
|
constructor() {
|
11
|
-
super();
|
11
|
+
super(...arguments);
|
12
12
|
this.input = null;
|
13
13
|
this.name = '';
|
14
14
|
this.value = '';
|
@@ -27,13 +27,17 @@ export class StripeDetailElement extends StripeGenericField {
|
|
27
27
|
return;
|
28
28
|
}
|
29
29
|
details.billingDetails = (details.billingDetails || {});
|
30
|
-
|
31
|
-
|
32
|
-
details.billingDetails.address.line1 = ((input === null || input === void 0 ? void 0 : input.value) || this.value);
|
33
|
-
}
|
34
|
-
else {
|
30
|
+
const nameParts = this.name.split('.');
|
31
|
+
if (nameParts.length == 1) {
|
35
32
|
details.billingDetails[this.name] = ((input === null || input === void 0 ? void 0 : input.value) || this.value);
|
36
33
|
}
|
34
|
+
else { //Path
|
35
|
+
let current = details.billingDetails;
|
36
|
+
nameParts.slice(0, -1).forEach((part) => {
|
37
|
+
current = (current[part] = (current[part] || {}));
|
38
|
+
});
|
39
|
+
current[nameParts.slice(-1)[0]] = ((input === null || input === void 0 ? void 0 : input.value) || this.value);
|
40
|
+
}
|
37
41
|
}
|
38
42
|
GetInput_() {
|
39
43
|
return (this.input || this.querySelector('input'));
|
@@ -46,7 +50,7 @@ __decorate([
|
|
46
50
|
Property({ type: 'string' })
|
47
51
|
], StripeDetailElement.prototype, "name", void 0);
|
48
52
|
__decorate([
|
49
|
-
Property({ type: 'string' })
|
53
|
+
Property({ type: 'string', checkStoredObject: true })
|
50
54
|
], StripeDetailElement.prototype, "value", void 0);
|
51
55
|
export function StripeDetailElementCompact() {
|
52
56
|
RegisterCustomElement(StripeDetailElement, 'stripe-detail');
|
@@ -11,9 +11,9 @@ export declare class StripeFieldElement extends StripeGenericField {
|
|
11
11
|
protected changeListeners: StripeFieldChangeHandlerType[];
|
12
12
|
options: stripe.elements.ElementsOptions | null;
|
13
13
|
type: string;
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
oncustomready: string;
|
15
|
+
oncustomcomplete: string;
|
16
|
+
oncustomerror: string;
|
17
17
|
constructor();
|
18
18
|
IsInteractive(): boolean;
|
19
19
|
WaitReady(): Promise<void>;
|
@@ -15,7 +15,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
15
15
|
}
|
16
16
|
return t;
|
17
17
|
};
|
18
|
-
import { EvaluateLater, JournalTry } from "@benbraide/inlinejs";
|
18
|
+
import { EvaluateLater, JournalError, JournalTry, JournalWarn } from "@benbraide/inlinejs";
|
19
19
|
import { Property, RegisterCustomElement } from "@benbraide/inlinejs-element";
|
20
20
|
import { StripeGenericField } from "./generic-field";
|
21
21
|
export class StripeFieldElement extends StripeGenericField {
|
@@ -29,9 +29,9 @@ export class StripeFieldElement extends StripeGenericField {
|
|
29
29
|
this.changeListeners = new Array();
|
30
30
|
this.options = null;
|
31
31
|
this.type = '';
|
32
|
-
this.
|
33
|
-
this.
|
34
|
-
this.
|
32
|
+
this.oncustomready = '';
|
33
|
+
this.oncustomcomplete = '';
|
34
|
+
this.oncustomerror = '';
|
35
35
|
}
|
36
36
|
IsInteractive() {
|
37
37
|
return true;
|
@@ -66,7 +66,7 @@ export class StripeFieldElement extends StripeGenericField {
|
|
66
66
|
var _a;
|
67
67
|
(_a = this.GetStripe_()) === null || _a === void 0 ? void 0 : _a.WaitInstance().then((details) => {
|
68
68
|
var _a;
|
69
|
-
if (!(details === null || details === void 0 ? void 0 : details.stripe)) {
|
69
|
+
if (!(details === null || details === void 0 ? void 0 : details.stripe) || !details.elements) {
|
70
70
|
return;
|
71
71
|
}
|
72
72
|
let type = '';
|
@@ -76,43 +76,45 @@ export class StripeFieldElement extends StripeGenericField {
|
|
76
76
|
else if (['card', 'cardNumber', 'cardExpiry', 'cardCvc', 'postalCode', 'paymentRequestButton', 'iban', 'idealBank'].includes(this.type)) {
|
77
77
|
type = this.type;
|
78
78
|
}
|
79
|
-
if (type
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
79
|
+
if (!type) {
|
80
|
+
JournalWarn('The element type provided is invalid.', 'StripeField.Mount', this);
|
81
|
+
return;
|
82
|
+
}
|
83
|
+
this.stripeField_ = details.elements.create(type, (this.options || ((_a = this.GetStripe_()) === null || _a === void 0 ? void 0 : _a.options) || undefined));
|
84
|
+
this.stripeField_.on('ready', () => {
|
85
|
+
this.isReady_ = true;
|
86
|
+
this.oncustomready && EvaluateLater({
|
87
|
+
componentId: this.componentId_,
|
88
|
+
contextElement: this,
|
89
|
+
expression: this.oncustomready,
|
90
|
+
disableFunctionCall: false,
|
91
|
+
})();
|
92
|
+
this.readyWaiters_.splice(0).forEach(waiter => JournalTry(waiter));
|
93
|
+
});
|
94
|
+
this.stripeField_.on('change', (event) => {
|
95
|
+
if (((event === null || event === void 0 ? void 0 : event.error) || null) !== this.lastError_) {
|
96
|
+
this.lastError_ = ((event === null || event === void 0 ? void 0 : event.error) || null);
|
97
|
+
this.oncustomerror && EvaluateLater({
|
84
98
|
componentId: this.componentId_,
|
85
99
|
contextElement: this,
|
86
|
-
expression: this.
|
100
|
+
expression: this.oncustomerror,
|
87
101
|
disableFunctionCall: false,
|
88
|
-
})();
|
89
|
-
this.
|
90
|
-
}
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
EvaluateLater({
|
105
|
-
componentId: this.componentId_,
|
106
|
-
contextElement: this,
|
107
|
-
expression: this.oncomplete,
|
108
|
-
disableFunctionCall: false,
|
109
|
-
})(undefined, [this.isComplete_], { complete: this.isComplete_ });
|
110
|
-
this.changeListeners.forEach(listener => JournalTry(() => listener('complete', this.isComplete_)));
|
111
|
-
}
|
112
|
-
});
|
113
|
-
this.stripeField_.mount(this);
|
114
|
-
}
|
115
|
-
});
|
102
|
+
})(undefined, [this.lastError_], { error: this.lastError_ });
|
103
|
+
this.changeListeners.forEach(listener => JournalTry(() => listener('error', this.lastError_)));
|
104
|
+
}
|
105
|
+
if (((event === null || event === void 0 ? void 0 : event.complete) || false) != this.isComplete_) {
|
106
|
+
this.isComplete_ = ((event === null || event === void 0 ? void 0 : event.complete) || false);
|
107
|
+
this.oncustomcomplete && EvaluateLater({
|
108
|
+
componentId: this.componentId_,
|
109
|
+
contextElement: this,
|
110
|
+
expression: this.oncustomcomplete,
|
111
|
+
disableFunctionCall: false,
|
112
|
+
})(undefined, [this.isComplete_], { complete: this.isComplete_ });
|
113
|
+
this.changeListeners.forEach(listener => JournalTry(() => listener('complete', this.isComplete_)));
|
114
|
+
}
|
115
|
+
});
|
116
|
+
this.stripeField_.mount(this);
|
117
|
+
}).catch(err => JournalError(err, 'StripeField.Mount', this));
|
116
118
|
});
|
117
119
|
scope.AddUninitCallback(() => {
|
118
120
|
var _a;
|
@@ -129,13 +131,13 @@ __decorate([
|
|
129
131
|
], StripeFieldElement.prototype, "type", void 0);
|
130
132
|
__decorate([
|
131
133
|
Property({ type: 'string' })
|
132
|
-
], StripeFieldElement.prototype, "
|
134
|
+
], StripeFieldElement.prototype, "oncustomready", void 0);
|
133
135
|
__decorate([
|
134
136
|
Property({ type: 'string' })
|
135
|
-
], StripeFieldElement.prototype, "
|
137
|
+
], StripeFieldElement.prototype, "oncustomcomplete", void 0);
|
136
138
|
__decorate([
|
137
139
|
Property({ type: 'string' })
|
138
|
-
], StripeFieldElement.prototype, "
|
140
|
+
], StripeFieldElement.prototype, "oncustomerror", void 0);
|
139
141
|
export function StripeFieldElementCompact() {
|
140
142
|
RegisterCustomElement(StripeFieldElement, 'stripe-field');
|
141
143
|
}
|
@@ -17,9 +17,9 @@ export declare class StripeElement extends CustomElement implements IStripeEleme
|
|
17
17
|
protected errorFields_: Array<IStripeField> | null;
|
18
18
|
options: stripe.elements.ElementsOptions | null;
|
19
19
|
publicKey: string;
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
oncustomready: string;
|
21
|
+
oncustomcomplete: string;
|
22
|
+
oncustomerror: string;
|
23
23
|
defer: boolean;
|
24
24
|
focusnext: boolean;
|
25
25
|
constructor();
|
@@ -34,9 +34,9 @@ export class StripeElement extends CustomElement {
|
|
34
34
|
this.errorFields_ = null;
|
35
35
|
this.options = null;
|
36
36
|
this.publicKey = '';
|
37
|
-
this.
|
38
|
-
this.
|
39
|
-
this.
|
37
|
+
this.oncustomready = '';
|
38
|
+
this.oncustomcomplete = '';
|
39
|
+
this.oncustomerror = '';
|
40
40
|
this.defer = false;
|
41
41
|
this.focusnext = false;
|
42
42
|
}
|
@@ -52,10 +52,10 @@ export class StripeElement extends CustomElement {
|
|
52
52
|
}
|
53
53
|
(this.fields_ && this.readyFields_ && this.fields_.length <= this.readyFields_.length) && JournalTry(() => {
|
54
54
|
this.isReady_ = true;
|
55
|
-
this.
|
55
|
+
this.oncustomready && EvaluateLater({
|
56
56
|
componentId: this.componentId_,
|
57
57
|
contextElement: this,
|
58
|
-
expression: this.
|
58
|
+
expression: this.oncustomready,
|
59
59
|
disableFunctionCall: false,
|
60
60
|
})();
|
61
61
|
this.readyWaiters_.splice(0).forEach(waiter => JournalTry(waiter));
|
@@ -73,10 +73,10 @@ export class StripeElement extends CustomElement {
|
|
73
73
|
this.completeFields_ = this.completeFields_.filter(x => x !== field);
|
74
74
|
changed = !!(this.interactiveFields_ && (this.completeFields_.length == (this.interactiveFields_.length - 1)));
|
75
75
|
}
|
76
|
-
changed && this.
|
76
|
+
changed && this.oncustomcomplete && EvaluateLater({
|
77
77
|
componentId: this.componentId_,
|
78
78
|
contextElement: this,
|
79
|
-
expression: this.
|
79
|
+
expression: this.oncustomcomplete,
|
80
80
|
disableFunctionCall: false,
|
81
81
|
})(undefined, [!!data], { complete: !!data });
|
82
82
|
!!data && this.focusnext && this.FocusNextField(field);
|
@@ -94,10 +94,10 @@ export class StripeElement extends CustomElement {
|
|
94
94
|
this.errorFields_ = this.errorFields_.filter(x => x !== field);
|
95
95
|
changed = (this.errorFields_.length == 0);
|
96
96
|
}
|
97
|
-
changed && this.
|
97
|
+
changed && this.oncustomerror && EvaluateLater({
|
98
98
|
componentId: this.componentId_,
|
99
99
|
contextElement: this,
|
100
|
-
expression: this.
|
100
|
+
expression: this.oncustomerror,
|
101
101
|
disableFunctionCall: false,
|
102
102
|
})(undefined, [data], { error: data });
|
103
103
|
}
|
@@ -173,7 +173,12 @@ export class StripeElement extends CustomElement {
|
|
173
173
|
return resolve(false);
|
174
174
|
}
|
175
175
|
let cardDetails;
|
176
|
-
if (typeof paymentDetails.method
|
176
|
+
if (typeof paymentDetails.method === 'string') { // Payment Method ID
|
177
|
+
cardDetails = {
|
178
|
+
payment_method: paymentDetails.method,
|
179
|
+
};
|
180
|
+
}
|
181
|
+
else { // Stripe Element (e.g., CardElement)
|
177
182
|
cardDetails = {
|
178
183
|
payment_method: {
|
179
184
|
card: paymentDetails.method,
|
@@ -181,11 +186,6 @@ export class StripeElement extends CustomElement {
|
|
181
186
|
},
|
182
187
|
};
|
183
188
|
}
|
184
|
-
else {
|
185
|
-
cardDetails = {
|
186
|
-
payment_method: paymentDetails.method,
|
187
|
-
};
|
188
|
-
}
|
189
189
|
if (pay) {
|
190
190
|
((_b = paymentDetails.billingDetails) === null || _b === void 0 ? void 0 : _b.email) && (cardDetails.receipt_email = paymentDetails.billingDetails.email);
|
191
191
|
save && (cardDetails.setup_future_usage = 'off_session');
|
@@ -206,13 +206,13 @@ __decorate([
|
|
206
206
|
], StripeElement.prototype, "publicKey", void 0);
|
207
207
|
__decorate([
|
208
208
|
Property({ type: 'string' })
|
209
|
-
], StripeElement.prototype, "
|
209
|
+
], StripeElement.prototype, "oncustomready", void 0);
|
210
210
|
__decorate([
|
211
211
|
Property({ type: 'string' })
|
212
|
-
], StripeElement.prototype, "
|
212
|
+
], StripeElement.prototype, "oncustomcomplete", void 0);
|
213
213
|
__decorate([
|
214
214
|
Property({ type: 'string' })
|
215
|
-
], StripeElement.prototype, "
|
215
|
+
], StripeElement.prototype, "oncustomerror", void 0);
|
216
216
|
__decorate([
|
217
217
|
Property({ type: 'boolean' })
|
218
218
|
], StripeElement.prototype, "defer", void 0);
|
package/lib/esm/index.d.ts
CHANGED