@benbraide/inlinejs-stripe 2.2.0 → 2.3.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/dist/inlinejs-stripe.js +3063 -1175
- 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 +6 -5
- package/lib/common/components/field.js +62 -73
- package/lib/common/components/generic-field.d.ts +1 -2
- package/lib/common/components/generic-field.js +4 -18
- package/lib/common/components/stripe.d.ts +6 -5
- package/lib/common/components/stripe.js +25 -34
- 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 +6 -5
- package/lib/esm/components/field.js +63 -74
- package/lib/esm/components/generic-field.d.ts +1 -2
- package/lib/esm/components/generic-field.js +4 -18
- package/lib/esm/components/stripe.d.ts +6 -5
- package/lib/esm/components/stripe.js +25 -34
- 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() {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/// <reference types="stripe-v3" />
|
2
|
-
import {
|
2
|
+
import { IElementScope } from "@benbraide/inlinejs";
|
3
3
|
import { IStripePaymentDetails, StripeFieldChangeHandlerType } from "../types";
|
4
4
|
import { StripeGenericField } from "./generic-field";
|
5
5
|
export declare class StripeFieldElement extends StripeGenericField {
|
@@ -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>;
|
@@ -22,6 +22,7 @@ export declare class StripeFieldElement extends StripeGenericField {
|
|
22
22
|
ToggleFocus(focused: boolean): void;
|
23
23
|
Reset(): void;
|
24
24
|
AddDetails(details: IStripePaymentDetails): void;
|
25
|
-
protected
|
25
|
+
protected HandleElementScopeDestroyed_(scope: IElementScope): void;
|
26
|
+
protected HandlePostProcess_(): void;
|
26
27
|
}
|
27
28
|
export declare function StripeFieldElementCompact(): void;
|
@@ -5,17 +5,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
7
|
};
|
8
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
9
|
-
var t = {};
|
10
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
11
|
-
t[p] = s[p];
|
12
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
13
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
14
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
15
|
-
t[p[i]] = s[p[i]];
|
16
|
-
}
|
17
|
-
return t;
|
18
|
-
};
|
19
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
20
9
|
exports.StripeFieldElementCompact = exports.StripeFieldElement = void 0;
|
21
10
|
const inlinejs_1 = require("@benbraide/inlinejs");
|
@@ -32,9 +21,9 @@ class StripeFieldElement extends generic_field_1.StripeGenericField {
|
|
32
21
|
this.changeListeners = new Array();
|
33
22
|
this.options = null;
|
34
23
|
this.type = '';
|
35
|
-
this.
|
36
|
-
this.
|
37
|
-
this.
|
24
|
+
this.oncustomready = '';
|
25
|
+
this.oncustomcomplete = '';
|
26
|
+
this.oncustomerror = '';
|
38
27
|
}
|
39
28
|
IsInteractive() {
|
40
29
|
return true;
|
@@ -62,66 +51,66 @@ class StripeFieldElement extends generic_field_1.StripeGenericField {
|
|
62
51
|
AddDetails(details) {
|
63
52
|
(this.stripeField_ && (this.type === 'card' || this.type === 'number' || this.type === 'cardNumber')) && (details.method = this.stripeField_);
|
64
53
|
}
|
65
|
-
|
66
|
-
var
|
67
|
-
super.
|
68
|
-
|
54
|
+
HandleElementScopeDestroyed_(scope) {
|
55
|
+
var _a;
|
56
|
+
super.HandleElementScopeDestroyed_(scope);
|
57
|
+
(_a = this.GetStripe_()) === null || _a === void 0 ? void 0 : _a.RemoveStripeField(this);
|
58
|
+
this.stripeField_ = null;
|
59
|
+
}
|
60
|
+
HandlePostProcess_() {
|
61
|
+
var _a;
|
62
|
+
super.HandlePostProcess_();
|
63
|
+
(_a = this.GetStripe_()) === null || _a === void 0 ? void 0 : _a.WaitInstance().then((details) => {
|
69
64
|
var _a;
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
65
|
+
if (!(details === null || details === void 0 ? void 0 : details.stripe) || !details.elements) {
|
66
|
+
return;
|
67
|
+
}
|
68
|
+
let type = '';
|
69
|
+
if (['number', 'expiry', 'cvc'].includes(this.type)) {
|
70
|
+
type = `card${this.type.substring(0, 1).toUpperCase()}${this.type.substring(1)}`;
|
71
|
+
}
|
72
|
+
else if (['card', 'cardNumber', 'cardExpiry', 'cardCvc', 'postalCode', 'paymentRequestButton', 'iban', 'idealBank'].includes(this.type)) {
|
73
|
+
type = this.type;
|
74
|
+
}
|
75
|
+
if (!type) {
|
76
|
+
(0, inlinejs_1.JournalWarn)('The element type provided is invalid.', 'StripeField.Mount', this);
|
77
|
+
return;
|
78
|
+
}
|
79
|
+
this.stripeField_ = details.elements.create(type, (this.options || ((_a = this.GetStripe_()) === null || _a === void 0 ? void 0 : _a.options) || undefined));
|
80
|
+
this.stripeField_.on('ready', () => {
|
81
|
+
this.isReady_ = true;
|
82
|
+
this.oncustomready && (0, inlinejs_1.EvaluateLater)({
|
83
|
+
componentId: this.componentId_,
|
84
|
+
contextElement: this,
|
85
|
+
expression: this.oncustomready,
|
86
|
+
disableFunctionCall: false,
|
87
|
+
})();
|
88
|
+
this.readyWaiters_.splice(0).forEach(waiter => (0, inlinejs_1.JournalTry)(waiter));
|
89
|
+
});
|
90
|
+
this.stripeField_.on('change', (event) => {
|
91
|
+
if (((event === null || event === void 0 ? void 0 : event.error) || null) !== this.lastError_) {
|
92
|
+
this.lastError_ = ((event === null || event === void 0 ? void 0 : event.error) || null);
|
93
|
+
this.oncustomerror && (0, inlinejs_1.EvaluateLater)({
|
94
|
+
componentId: this.componentId_,
|
95
|
+
contextElement: this,
|
96
|
+
expression: this.oncustomerror,
|
97
|
+
disableFunctionCall: false,
|
98
|
+
})(undefined, [this.lastError_], { error: this.lastError_ });
|
99
|
+
this.changeListeners.forEach(listener => (0, inlinejs_1.JournalTry)(() => listener('error', this.lastError_)));
|
81
100
|
}
|
82
|
-
if (
|
83
|
-
this.
|
84
|
-
this.
|
85
|
-
this.
|
86
|
-
this
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
})();
|
92
|
-
this.readyWaiters_.splice(0).forEach(waiter => (0, inlinejs_1.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
|
-
(0, inlinejs_1.EvaluateLater)({
|
98
|
-
componentId: this.componentId_,
|
99
|
-
contextElement: this,
|
100
|
-
expression: this.onerrors,
|
101
|
-
disableFunctionCall: false,
|
102
|
-
})(undefined, [this.lastError_], { error: this.lastError_ });
|
103
|
-
this.changeListeners.forEach(listener => (0, inlinejs_1.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
|
-
(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);
|
101
|
+
if (((event === null || event === void 0 ? void 0 : event.complete) || false) != this.isComplete_) {
|
102
|
+
this.isComplete_ = ((event === null || event === void 0 ? void 0 : event.complete) || false);
|
103
|
+
this.oncustomcomplete && (0, inlinejs_1.EvaluateLater)({
|
104
|
+
componentId: this.componentId_,
|
105
|
+
contextElement: this,
|
106
|
+
expression: this.oncustomcomplete,
|
107
|
+
disableFunctionCall: false,
|
108
|
+
})(undefined, [this.isComplete_], { complete: this.isComplete_ });
|
109
|
+
this.changeListeners.forEach(listener => (0, inlinejs_1.JournalTry)(() => listener('complete', this.isComplete_)));
|
117
110
|
}
|
118
111
|
});
|
119
|
-
|
120
|
-
|
121
|
-
var _a;
|
122
|
-
(_a = this.GetStripe_()) === null || _a === void 0 ? void 0 : _a.RemoveStripeField(this);
|
123
|
-
this.stripeField_ = null;
|
124
|
-
});
|
112
|
+
this.stripeField_.mount(this);
|
113
|
+
}).catch(err => (0, inlinejs_1.JournalError)(err, 'StripeField.Mount', this));
|
125
114
|
}
|
126
115
|
}
|
127
116
|
__decorate([
|
@@ -132,13 +121,13 @@ __decorate([
|
|
132
121
|
], StripeFieldElement.prototype, "type", void 0);
|
133
122
|
__decorate([
|
134
123
|
(0, inlinejs_element_1.Property)({ type: 'string' })
|
135
|
-
], StripeFieldElement.prototype, "
|
124
|
+
], StripeFieldElement.prototype, "oncustomready", void 0);
|
136
125
|
__decorate([
|
137
126
|
(0, inlinejs_element_1.Property)({ type: 'string' })
|
138
|
-
], StripeFieldElement.prototype, "
|
127
|
+
], StripeFieldElement.prototype, "oncustomcomplete", void 0);
|
139
128
|
__decorate([
|
140
129
|
(0, inlinejs_element_1.Property)({ type: 'string' })
|
141
|
-
], StripeFieldElement.prototype, "
|
130
|
+
], StripeFieldElement.prototype, "oncustomerror", void 0);
|
142
131
|
exports.StripeFieldElement = StripeFieldElement;
|
143
132
|
function StripeFieldElementCompact() {
|
144
133
|
(0, inlinejs_element_1.RegisterCustomElement)(StripeFieldElement, 'stripe-field');
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { IElementScopeCreatedCallbackParams } from "@benbraide/inlinejs";
|
2
1
|
import { CustomElement } from "@benbraide/inlinejs-element";
|
3
2
|
import { IStripeElement, IStripeField, IStripePaymentDetails, StripeFieldChangeHandlerType } from "../types";
|
4
3
|
export declare class StripeGenericField extends CustomElement implements IStripeField {
|
@@ -10,6 +9,6 @@ export declare class StripeGenericField extends CustomElement implements IStripe
|
|
10
9
|
ToggleFocus(focused: boolean): void;
|
11
10
|
Reset(): void;
|
12
11
|
AddDetails(details: IStripePaymentDetails): void;
|
13
|
-
protected
|
12
|
+
protected HandlePostAttributesProcessPostfix_(): void;
|
14
13
|
protected GetStripe_(): IStripeElement | null;
|
15
14
|
}
|
@@ -5,17 +5,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
7
|
};
|
8
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
9
|
-
var t = {};
|
10
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
11
|
-
t[p] = s[p];
|
12
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
13
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
14
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
15
|
-
t[p[i]] = s[p[i]];
|
16
|
-
}
|
17
|
-
return t;
|
18
|
-
};
|
19
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
20
9
|
exports.StripeGenericField = void 0;
|
21
10
|
const inlinejs_1 = require("@benbraide/inlinejs");
|
@@ -36,13 +25,10 @@ class StripeGenericField extends inlinejs_element_1.CustomElement {
|
|
36
25
|
ToggleFocus(focused) { }
|
37
26
|
Reset() { }
|
38
27
|
AddDetails(details) { }
|
39
|
-
|
40
|
-
var
|
41
|
-
super.
|
42
|
-
|
43
|
-
(_a = this.GetStripe_()) === null || _a === void 0 ? void 0 : _a.AddStripeField(this);
|
44
|
-
postAttributesCallback && postAttributesCallback();
|
45
|
-
});
|
28
|
+
HandlePostAttributesProcessPostfix_() {
|
29
|
+
var _a;
|
30
|
+
super.HandlePostAttributesProcessPostfix_();
|
31
|
+
(_a = this.GetStripe_()) === null || _a === void 0 ? void 0 : _a.AddStripeField(this);
|
46
32
|
}
|
47
33
|
GetStripe_() {
|
48
34
|
return (this.stripe || (0, inlinejs_1.FindAncestor)(this, ancestor => ('AddStripeField' in ancestor)));
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/// <reference types="stripe-v3" />
|
2
|
-
import {
|
2
|
+
import { IElementScope } from "@benbraide/inlinejs";
|
3
3
|
import { CustomElement } from "@benbraide/inlinejs-element";
|
4
4
|
import { IStripeDetails, IStripeElement, IStripeField } from "../types";
|
5
5
|
export declare class StripeElement extends CustomElement implements IStripeElement {
|
@@ -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();
|
@@ -33,7 +33,8 @@ export declare class StripeElement extends CustomElement implements IStripeEleme
|
|
33
33
|
Pay(clientSecret: string, save?: boolean): Promise<false | stripe.PaymentIntentResponse>;
|
34
34
|
Setup(clientSecret: string): Promise<false | stripe.PaymentIntentResponse>;
|
35
35
|
WaitReady(): Promise<void>;
|
36
|
-
protected
|
36
|
+
protected HandleElementScopeDestroyed_(scope: IElementScope): void;
|
37
|
+
protected HandlePostProcess_(): void;
|
37
38
|
protected PayOrSetup_(pay: boolean, clientSecret: string, save?: boolean): Promise<false | stripe.PaymentIntentResponse>;
|
38
39
|
}
|
39
40
|
export declare function StripeElementCompact(): void;
|
@@ -5,17 +5,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
7
|
};
|
8
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
9
|
-
var t = {};
|
10
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
11
|
-
t[p] = s[p];
|
12
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
13
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
14
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
15
|
-
t[p[i]] = s[p[i]];
|
16
|
-
}
|
17
|
-
return t;
|
18
|
-
};
|
19
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
20
9
|
exports.StripeElementCompact = exports.StripeElement = void 0;
|
21
10
|
const inlinejs_1 = require("@benbraide/inlinejs");
|
@@ -37,9 +26,9 @@ class StripeElement extends inlinejs_element_1.CustomElement {
|
|
37
26
|
this.errorFields_ = null;
|
38
27
|
this.options = null;
|
39
28
|
this.publicKey = '';
|
40
|
-
this.
|
41
|
-
this.
|
42
|
-
this.
|
29
|
+
this.oncustomready = '';
|
30
|
+
this.oncustomcomplete = '';
|
31
|
+
this.oncustomerror = '';
|
43
32
|
this.defer = false;
|
44
33
|
this.focusnext = false;
|
45
34
|
}
|
@@ -55,10 +44,10 @@ class StripeElement extends inlinejs_element_1.CustomElement {
|
|
55
44
|
}
|
56
45
|
(this.fields_ && this.readyFields_ && this.fields_.length <= this.readyFields_.length) && (0, inlinejs_1.JournalTry)(() => {
|
57
46
|
this.isReady_ = true;
|
58
|
-
this.
|
47
|
+
this.oncustomready && (0, inlinejs_1.EvaluateLater)({
|
59
48
|
componentId: this.componentId_,
|
60
49
|
contextElement: this,
|
61
|
-
expression: this.
|
50
|
+
expression: this.oncustomready,
|
62
51
|
disableFunctionCall: false,
|
63
52
|
})();
|
64
53
|
this.readyWaiters_.splice(0).forEach(waiter => (0, inlinejs_1.JournalTry)(waiter));
|
@@ -76,10 +65,10 @@ class StripeElement extends inlinejs_element_1.CustomElement {
|
|
76
65
|
this.completeFields_ = this.completeFields_.filter(x => x !== field);
|
77
66
|
changed = !!(this.interactiveFields_ && (this.completeFields_.length == (this.interactiveFields_.length - 1)));
|
78
67
|
}
|
79
|
-
changed && this.
|
68
|
+
changed && this.oncustomcomplete && (0, inlinejs_1.EvaluateLater)({
|
80
69
|
componentId: this.componentId_,
|
81
70
|
contextElement: this,
|
82
|
-
expression: this.
|
71
|
+
expression: this.oncustomcomplete,
|
83
72
|
disableFunctionCall: false,
|
84
73
|
})(undefined, [!!data], { complete: !!data });
|
85
74
|
!!data && this.focusnext && this.FocusNextField(field);
|
@@ -97,10 +86,10 @@ class StripeElement extends inlinejs_element_1.CustomElement {
|
|
97
86
|
this.errorFields_ = this.errorFields_.filter(x => x !== field);
|
98
87
|
changed = (this.errorFields_.length == 0);
|
99
88
|
}
|
100
|
-
changed && this.
|
89
|
+
changed && this.oncustomerror && (0, inlinejs_1.EvaluateLater)({
|
101
90
|
componentId: this.componentId_,
|
102
91
|
contextElement: this,
|
103
|
-
expression: this.
|
92
|
+
expression: this.oncustomerror,
|
104
93
|
disableFunctionCall: false,
|
105
94
|
})(undefined, [data], { error: data });
|
106
95
|
}
|
@@ -157,11 +146,13 @@ class StripeElement extends inlinejs_element_1.CustomElement {
|
|
157
146
|
this.isReady_ ? resolve() : this.readyWaiters_.push(() => resolve());
|
158
147
|
});
|
159
148
|
}
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
149
|
+
HandleElementScopeDestroyed_(scope) {
|
150
|
+
super.HandleElementScopeDestroyed_(scope);
|
151
|
+
this.stripe_ = null;
|
152
|
+
}
|
153
|
+
HandlePostProcess_() {
|
154
|
+
super.HandlePostProcess_();
|
155
|
+
!this.defer && this.Mount();
|
165
156
|
}
|
166
157
|
PayOrSetup_(pay, clientSecret, save = false) {
|
167
158
|
return new Promise((resolve, reject) => {
|
@@ -176,7 +167,12 @@ class StripeElement extends inlinejs_element_1.CustomElement {
|
|
176
167
|
return resolve(false);
|
177
168
|
}
|
178
169
|
let cardDetails;
|
179
|
-
if (typeof paymentDetails.method
|
170
|
+
if (typeof paymentDetails.method === 'string') { // Payment Method ID
|
171
|
+
cardDetails = {
|
172
|
+
payment_method: paymentDetails.method,
|
173
|
+
};
|
174
|
+
}
|
175
|
+
else { // Stripe Element (e.g., CardElement)
|
180
176
|
cardDetails = {
|
181
177
|
payment_method: {
|
182
178
|
card: paymentDetails.method,
|
@@ -184,11 +180,6 @@ class StripeElement extends inlinejs_element_1.CustomElement {
|
|
184
180
|
},
|
185
181
|
};
|
186
182
|
}
|
187
|
-
else {
|
188
|
-
cardDetails = {
|
189
|
-
payment_method: paymentDetails.method,
|
190
|
-
};
|
191
|
-
}
|
192
183
|
if (pay) {
|
193
184
|
((_b = paymentDetails.billingDetails) === null || _b === void 0 ? void 0 : _b.email) && (cardDetails.receipt_email = paymentDetails.billingDetails.email);
|
194
185
|
save && (cardDetails.setup_future_usage = 'off_session');
|
@@ -209,13 +200,13 @@ __decorate([
|
|
209
200
|
], StripeElement.prototype, "publicKey", void 0);
|
210
201
|
__decorate([
|
211
202
|
(0, inlinejs_element_1.Property)({ type: 'string' })
|
212
|
-
], StripeElement.prototype, "
|
203
|
+
], StripeElement.prototype, "oncustomready", void 0);
|
213
204
|
__decorate([
|
214
205
|
(0, inlinejs_element_1.Property)({ type: 'string' })
|
215
|
-
], StripeElement.prototype, "
|
206
|
+
], StripeElement.prototype, "oncustomcomplete", void 0);
|
216
207
|
__decorate([
|
217
208
|
(0, inlinejs_element_1.Property)({ type: 'string' })
|
218
|
-
], StripeElement.prototype, "
|
209
|
+
], StripeElement.prototype, "oncustomerror", void 0);
|
219
210
|
__decorate([
|
220
211
|
(0, inlinejs_element_1.Property)({ type: 'boolean' })
|
221
212
|
], 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');
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/// <reference types="stripe-v3" />
|
2
|
-
import {
|
2
|
+
import { IElementScope } from "@benbraide/inlinejs";
|
3
3
|
import { IStripePaymentDetails, StripeFieldChangeHandlerType } from "../types";
|
4
4
|
import { StripeGenericField } from "./generic-field";
|
5
5
|
export declare class StripeFieldElement extends StripeGenericField {
|
@@ -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>;
|
@@ -22,6 +22,7 @@ export declare class StripeFieldElement extends StripeGenericField {
|
|
22
22
|
ToggleFocus(focused: boolean): void;
|
23
23
|
Reset(): void;
|
24
24
|
AddDetails(details: IStripePaymentDetails): void;
|
25
|
-
protected
|
25
|
+
protected HandleElementScopeDestroyed_(scope: IElementScope): void;
|
26
|
+
protected HandlePostProcess_(): void;
|
26
27
|
}
|
27
28
|
export declare function StripeFieldElementCompact(): void;
|