@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.
@@ -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: string;
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
- if (this.name === 'address') {
34
- details.billingDetails.address = (details.billingDetails.address || {});
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 { IElementScopeCreatedCallbackParams } from "@benbraide/inlinejs";
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
- onready: string;
15
- oncomplete: string;
16
- onerrors: string;
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 HandleElementScopeCreated_({ scope, ...rest }: IElementScopeCreatedCallbackParams, postAttributesCallback?: () => void): void;
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.onready = '';
36
- this.oncomplete = '';
37
- this.onerrors = '';
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
- HandleElementScopeCreated_(_a, postAttributesCallback) {
66
- var { scope } = _a, rest = __rest(_a, ["scope"]);
67
- super.HandleElementScopeCreated_(Object.assign({ scope }, rest), postAttributesCallback);
68
- scope.AddPostProcessCallback(() => {
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
- (_a = this.GetStripe_()) === null || _a === void 0 ? void 0 : _a.WaitInstance().then((details) => {
71
- var _a;
72
- if (!(details === null || details === void 0 ? void 0 : details.stripe)) {
73
- return;
74
- }
75
- let type = '';
76
- if (['number', 'expiry', 'cvc'].includes(this.type)) {
77
- type = `card${this.type.substring(0, 1).toUpperCase()}${this.type.substring(1)}`;
78
- }
79
- else if (['card', 'cardNumber', 'cardExpiry', 'cardCvc', 'postalCode', 'paymentRequestButton', 'iban', 'idealBank'].includes(this.type)) {
80
- type = this.type;
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 (type && details.elements) {
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.onready && (0, inlinejs_1.EvaluateLater)({
87
- componentId: this.componentId_,
88
- contextElement: this,
89
- expression: this.onready,
90
- disableFunctionCall: false,
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
- scope.AddUninitCallback(() => {
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, "onready", void 0);
124
+ ], StripeFieldElement.prototype, "oncustomready", void 0);
136
125
  __decorate([
137
126
  (0, inlinejs_element_1.Property)({ type: 'string' })
138
- ], StripeFieldElement.prototype, "oncomplete", void 0);
127
+ ], StripeFieldElement.prototype, "oncustomcomplete", void 0);
139
128
  __decorate([
140
129
  (0, inlinejs_element_1.Property)({ type: 'string' })
141
- ], StripeFieldElement.prototype, "onerrors", void 0);
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 HandleElementScopeCreated_({ scope, ...rest }: IElementScopeCreatedCallbackParams, postAttributesCallback?: () => void): void;
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
- HandleElementScopeCreated_(_a, postAttributesCallback) {
40
- var { scope } = _a, rest = __rest(_a, ["scope"]);
41
- super.HandleElementScopeCreated_(Object.assign({ scope }, rest), () => {
42
- var _a;
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 { IElementScopeCreatedCallbackParams } from "@benbraide/inlinejs";
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
- onready: string;
21
- oncomplete: string;
22
- onerrors: string;
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 HandleElementScopeCreated_({ scope, ...rest }: IElementScopeCreatedCallbackParams, postAttributesCallback?: () => void): void;
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.onready = '';
41
- this.oncomplete = '';
42
- this.onerrors = '';
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.onready && (0, inlinejs_1.EvaluateLater)({
47
+ this.oncustomready && (0, inlinejs_1.EvaluateLater)({
59
48
  componentId: this.componentId_,
60
49
  contextElement: this,
61
- expression: this.onready,
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.oncomplete && (0, inlinejs_1.EvaluateLater)({
68
+ changed && this.oncustomcomplete && (0, inlinejs_1.EvaluateLater)({
80
69
  componentId: this.componentId_,
81
70
  contextElement: this,
82
- expression: this.oncomplete,
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.onerrors && (0, inlinejs_1.EvaluateLater)({
89
+ changed && this.oncustomerror && (0, inlinejs_1.EvaluateLater)({
101
90
  componentId: this.componentId_,
102
91
  contextElement: this,
103
- expression: this.onerrors,
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
- HandleElementScopeCreated_(_a, postAttributesCallback) {
161
- var { scope } = _a, rest = __rest(_a, ["scope"]);
162
- super.HandleElementScopeCreated_(Object.assign({ scope }, rest), postAttributesCallback);
163
- scope.AddPostProcessCallback(() => (!this.defer && this.Mount()));
164
- scope.AddUninitCallback(() => (this.stripe_ = null));
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 !== 'string') {
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, "onready", void 0);
203
+ ], StripeElement.prototype, "oncustomready", void 0);
213
204
  __decorate([
214
205
  (0, inlinejs_element_1.Property)({ type: 'string' })
215
- ], StripeElement.prototype, "oncomplete", void 0);
206
+ ], StripeElement.prototype, "oncustomcomplete", void 0);
216
207
  __decorate([
217
208
  (0, inlinejs_element_1.Property)({ type: 'string' })
218
- ], StripeElement.prototype, "onerrors", void 0);
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);
@@ -2,5 +2,4 @@ export * from './components/stripe';
2
2
  export * from './components/field';
3
3
  export * from './components/detail';
4
4
  export * from './components/payment-method';
5
- export * from './directive/stripe';
6
5
  export * from './entry';
@@ -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: string;
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
- if (this.name === 'address') {
31
- details.billingDetails.address = (details.billingDetails.address || {});
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 { IElementScopeCreatedCallbackParams } from "@benbraide/inlinejs";
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
- onready: string;
15
- oncomplete: string;
16
- onerrors: string;
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 HandleElementScopeCreated_({ scope, ...rest }: IElementScopeCreatedCallbackParams, postAttributesCallback?: () => void): void;
25
+ protected HandleElementScopeDestroyed_(scope: IElementScope): void;
26
+ protected HandlePostProcess_(): void;
26
27
  }
27
28
  export declare function StripeFieldElementCompact(): void;