@benbraide/inlinejs-stripe 2.3.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 +678 -577
- package/dist/inlinejs-stripe.min.js +1 -1
- package/lib/common/components/field.d.ts +3 -2
- package/lib/common/components/field.js +55 -68
- 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 +3 -2
- package/lib/common/components/stripe.js +7 -16
- package/lib/esm/components/field.d.ts +3 -2
- package/lib/esm/components/field.js +55 -68
- 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 +3 -2
- package/lib/esm/components/stripe.js +7 -16
- package/package.json +3 -3
@@ -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 {
|
@@ -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");
|
@@ -62,68 +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
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
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_)));
|
85
100
|
}
|
86
|
-
|
87
|
-
|
88
|
-
this.
|
89
|
-
this.oncustomready && (0, inlinejs_1.EvaluateLater)({
|
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)({
|
90
104
|
componentId: this.componentId_,
|
91
105
|
contextElement: this,
|
92
|
-
expression: this.
|
106
|
+
expression: this.oncustomcomplete,
|
93
107
|
disableFunctionCall: false,
|
94
|
-
})();
|
95
|
-
this.
|
96
|
-
}
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
this.oncustomerror && (0, inlinejs_1.EvaluateLater)({
|
101
|
-
componentId: this.componentId_,
|
102
|
-
contextElement: this,
|
103
|
-
expression: this.oncustomerror,
|
104
|
-
disableFunctionCall: false,
|
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));
|
121
|
-
});
|
122
|
-
scope.AddUninitCallback(() => {
|
123
|
-
var _a;
|
124
|
-
(_a = this.GetStripe_()) === null || _a === void 0 ? void 0 : _a.RemoveStripeField(this);
|
125
|
-
this.stripeField_ = null;
|
126
|
-
});
|
108
|
+
})(undefined, [this.isComplete_], { complete: this.isComplete_ });
|
109
|
+
this.changeListeners.forEach(listener => (0, inlinejs_1.JournalTry)(() => listener('complete', this.isComplete_)));
|
110
|
+
}
|
111
|
+
});
|
112
|
+
this.stripeField_.mount(this);
|
113
|
+
}).catch(err => (0, inlinejs_1.JournalError)(err, 'StripeField.Mount', this));
|
127
114
|
}
|
128
115
|
}
|
129
116
|
__decorate([
|
@@ -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 {
|
@@ -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");
|
@@ -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) => {
|
@@ -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 {
|
@@ -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;
|
@@ -4,17 +4,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
4
4
|
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;
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
6
|
};
|
7
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
8
|
-
var t = {};
|
9
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
10
|
-
t[p] = s[p];
|
11
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
12
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
13
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
14
|
-
t[p[i]] = s[p[i]];
|
15
|
-
}
|
16
|
-
return t;
|
17
|
-
};
|
18
7
|
import { EvaluateLater, JournalError, JournalTry, JournalWarn } from "@benbraide/inlinejs";
|
19
8
|
import { Property, RegisterCustomElement } from "@benbraide/inlinejs-element";
|
20
9
|
import { StripeGenericField } from "./generic-field";
|
@@ -59,68 +48,66 @@ export class StripeFieldElement extends StripeGenericField {
|
|
59
48
|
AddDetails(details) {
|
60
49
|
(this.stripeField_ && (this.type === 'card' || this.type === 'number' || this.type === 'cardNumber')) && (details.method = this.stripeField_);
|
61
50
|
}
|
62
|
-
|
63
|
-
var
|
64
|
-
super.
|
65
|
-
|
51
|
+
HandleElementScopeDestroyed_(scope) {
|
52
|
+
var _a;
|
53
|
+
super.HandleElementScopeDestroyed_(scope);
|
54
|
+
(_a = this.GetStripe_()) === null || _a === void 0 ? void 0 : _a.RemoveStripeField(this);
|
55
|
+
this.stripeField_ = null;
|
56
|
+
}
|
57
|
+
HandlePostProcess_() {
|
58
|
+
var _a;
|
59
|
+
super.HandlePostProcess_();
|
60
|
+
(_a = this.GetStripe_()) === null || _a === void 0 ? void 0 : _a.WaitInstance().then((details) => {
|
66
61
|
var _a;
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
62
|
+
if (!(details === null || details === void 0 ? void 0 : details.stripe) || !details.elements) {
|
63
|
+
return;
|
64
|
+
}
|
65
|
+
let type = '';
|
66
|
+
if (['number', 'expiry', 'cvc'].includes(this.type)) {
|
67
|
+
type = `card${this.type.substring(0, 1).toUpperCase()}${this.type.substring(1)}`;
|
68
|
+
}
|
69
|
+
else if (['card', 'cardNumber', 'cardExpiry', 'cardCvc', 'postalCode', 'paymentRequestButton', 'iban', 'idealBank'].includes(this.type)) {
|
70
|
+
type = this.type;
|
71
|
+
}
|
72
|
+
if (!type) {
|
73
|
+
JournalWarn('The element type provided is invalid.', 'StripeField.Mount', this);
|
74
|
+
return;
|
75
|
+
}
|
76
|
+
this.stripeField_ = details.elements.create(type, (this.options || ((_a = this.GetStripe_()) === null || _a === void 0 ? void 0 : _a.options) || undefined));
|
77
|
+
this.stripeField_.on('ready', () => {
|
78
|
+
this.isReady_ = true;
|
79
|
+
this.oncustomready && EvaluateLater({
|
80
|
+
componentId: this.componentId_,
|
81
|
+
contextElement: this,
|
82
|
+
expression: this.oncustomready,
|
83
|
+
disableFunctionCall: false,
|
84
|
+
})();
|
85
|
+
this.readyWaiters_.splice(0).forEach(waiter => JournalTry(waiter));
|
86
|
+
});
|
87
|
+
this.stripeField_.on('change', (event) => {
|
88
|
+
if (((event === null || event === void 0 ? void 0 : event.error) || null) !== this.lastError_) {
|
89
|
+
this.lastError_ = ((event === null || event === void 0 ? void 0 : event.error) || null);
|
90
|
+
this.oncustomerror && EvaluateLater({
|
91
|
+
componentId: this.componentId_,
|
92
|
+
contextElement: this,
|
93
|
+
expression: this.oncustomerror,
|
94
|
+
disableFunctionCall: false,
|
95
|
+
})(undefined, [this.lastError_], { error: this.lastError_ });
|
96
|
+
this.changeListeners.forEach(listener => JournalTry(() => listener('error', this.lastError_)));
|
82
97
|
}
|
83
|
-
|
84
|
-
|
85
|
-
this.
|
86
|
-
this.oncustomready && EvaluateLater({
|
98
|
+
if (((event === null || event === void 0 ? void 0 : event.complete) || false) != this.isComplete_) {
|
99
|
+
this.isComplete_ = ((event === null || event === void 0 ? void 0 : event.complete) || false);
|
100
|
+
this.oncustomcomplete && EvaluateLater({
|
87
101
|
componentId: this.componentId_,
|
88
102
|
contextElement: this,
|
89
|
-
expression: this.
|
103
|
+
expression: this.oncustomcomplete,
|
90
104
|
disableFunctionCall: false,
|
91
|
-
})();
|
92
|
-
this.
|
93
|
-
}
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
this.oncustomerror && EvaluateLater({
|
98
|
-
componentId: this.componentId_,
|
99
|
-
contextElement: this,
|
100
|
-
expression: this.oncustomerror,
|
101
|
-
disableFunctionCall: false,
|
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));
|
118
|
-
});
|
119
|
-
scope.AddUninitCallback(() => {
|
120
|
-
var _a;
|
121
|
-
(_a = this.GetStripe_()) === null || _a === void 0 ? void 0 : _a.RemoveStripeField(this);
|
122
|
-
this.stripeField_ = null;
|
123
|
-
});
|
105
|
+
})(undefined, [this.isComplete_], { complete: this.isComplete_ });
|
106
|
+
this.changeListeners.forEach(listener => JournalTry(() => listener('complete', this.isComplete_)));
|
107
|
+
}
|
108
|
+
});
|
109
|
+
this.stripeField_.mount(this);
|
110
|
+
}).catch(err => JournalError(err, 'StripeField.Mount', this));
|
124
111
|
}
|
125
112
|
}
|
126
113
|
__decorate([
|
@@ -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
|
}
|
@@ -4,17 +4,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
4
4
|
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;
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
6
|
};
|
7
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
8
|
-
var t = {};
|
9
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
10
|
-
t[p] = s[p];
|
11
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
12
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
13
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
14
|
-
t[p[i]] = s[p[i]];
|
15
|
-
}
|
16
|
-
return t;
|
17
|
-
};
|
18
7
|
import { FindAncestor } from "@benbraide/inlinejs";
|
19
8
|
import { CustomElement, Property } from "@benbraide/inlinejs-element";
|
20
9
|
export class StripeGenericField extends CustomElement {
|
@@ -33,13 +22,10 @@ export class StripeGenericField extends CustomElement {
|
|
33
22
|
ToggleFocus(focused) { }
|
34
23
|
Reset() { }
|
35
24
|
AddDetails(details) { }
|
36
|
-
|
37
|
-
var
|
38
|
-
super.
|
39
|
-
|
40
|
-
(_a = this.GetStripe_()) === null || _a === void 0 ? void 0 : _a.AddStripeField(this);
|
41
|
-
postAttributesCallback && postAttributesCallback();
|
42
|
-
});
|
25
|
+
HandlePostAttributesProcessPostfix_() {
|
26
|
+
var _a;
|
27
|
+
super.HandlePostAttributesProcessPostfix_();
|
28
|
+
(_a = this.GetStripe_()) === null || _a === void 0 ? void 0 : _a.AddStripeField(this);
|
43
29
|
}
|
44
30
|
GetStripe_() {
|
45
31
|
return (this.stripe || 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 {
|
@@ -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;
|
@@ -4,17 +4,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
4
4
|
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;
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
6
|
};
|
7
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
8
|
-
var t = {};
|
9
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
10
|
-
t[p] = s[p];
|
11
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
12
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
13
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
14
|
-
t[p[i]] = s[p[i]];
|
15
|
-
}
|
16
|
-
return t;
|
17
|
-
};
|
18
7
|
import { EvaluateLater, JournalTry } from "@benbraide/inlinejs";
|
19
8
|
import { CustomElement, Property, RegisterCustomElement } from "@benbraide/inlinejs-element";
|
20
9
|
export class StripeElement extends CustomElement {
|
@@ -154,11 +143,13 @@ export class StripeElement extends CustomElement {
|
|
154
143
|
this.isReady_ ? resolve() : this.readyWaiters_.push(() => resolve());
|
155
144
|
});
|
156
145
|
}
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
146
|
+
HandleElementScopeDestroyed_(scope) {
|
147
|
+
super.HandleElementScopeDestroyed_(scope);
|
148
|
+
this.stripe_ = null;
|
149
|
+
}
|
150
|
+
HandlePostProcess_() {
|
151
|
+
super.HandlePostProcess_();
|
152
|
+
!this.defer && this.Mount();
|
162
153
|
}
|
163
154
|
PayOrSetup_(pay, clientSecret, save = false) {
|
164
155
|
return new Promise((resolve, reject) => {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@benbraide/inlinejs-stripe",
|
3
|
-
"version": "2.3.
|
3
|
+
"version": "2.3.1",
|
4
4
|
"description": "Run javascript code by embedding them in your HTML using the element as context.",
|
5
5
|
"main": "./lib/common/index.js",
|
6
6
|
"module": "./lib/esm/index.js",
|
@@ -54,8 +54,8 @@
|
|
54
54
|
"webpack": "^5.41.0"
|
55
55
|
},
|
56
56
|
"dependencies": {
|
57
|
-
"@benbraide/inlinejs": "^1.4.
|
58
|
-
"@benbraide/inlinejs-element": "^2.2.
|
57
|
+
"@benbraide/inlinejs": "^1.4.7",
|
58
|
+
"@benbraide/inlinejs-element": "^2.2.3",
|
59
59
|
"webpack-cli": "^4.7.2"
|
60
60
|
}
|
61
61
|
}
|