@foxy.io/sdk 1.11.2 → 1.12.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.
@@ -121,9 +121,8 @@ class Rumour {
121
121
  if (!Rumour.__isResource(value) || Rumour.__isCollection(value))
122
122
  return patch;
123
123
  const props = traverse_1.default(value).map(function () {
124
- var _a;
125
- if ((_a = this.key) === null || _a === void 0 ? void 0 : _a.startsWith('_'))
126
- this.delete(true);
124
+ if (this.key === '_embedded')
125
+ return this.delete(true);
127
126
  });
128
127
  patch.set(value._links.self.href, props);
129
128
  return patch;
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.PaymentCardEmbed = void 0;
15
+ /**
16
+ * A convenience wrapper for the payment card embed iframe. You don't have to use
17
+ * this class to embed the payment card iframe, but it provides a more convenient
18
+ * way to interact with the iframe and listen to its events.
19
+ *
20
+ * @example
21
+ * const embed = new PaymentCardEmbed({
22
+ * url: 'https://embed.foxy.io/v1.html?template_set_id=123'
23
+ * });
24
+ *
25
+ * await embed.mount(document.body);
26
+ * console.log('Token:', await embed.tokenize());
27
+ */
28
+ class PaymentCardEmbed {
29
+ constructor(_a) {
30
+ var { url } = _a, config = __rest(_a, ["url"]);
31
+ /**
32
+ * An event handler that is triggered when Enter is pressed in the card form.
33
+ * This feature is not available for template sets configured with the `stripe_connect`
34
+ * hosted payment gateway due to the limitations of Stripe.js.
35
+ */
36
+ this.onsubmit = null;
37
+ this.__tokenizationRequests = [];
38
+ this.__iframeMessageHandler = (evt) => {
39
+ var _a, _b;
40
+ const data = JSON.parse(evt.data);
41
+ switch (data.type) {
42
+ case 'tokenization_response': {
43
+ const request = this.__tokenizationRequests.find(r => r.id === data.id);
44
+ data.token ? request === null || request === void 0 ? void 0 : request.resolve(data.token) : request === null || request === void 0 ? void 0 : request.reject();
45
+ this.__tokenizationRequests = this.__tokenizationRequests.filter(r => r.id !== data.id);
46
+ break;
47
+ }
48
+ case 'submit': {
49
+ (_a = this.onsubmit) === null || _a === void 0 ? void 0 : _a.call(this);
50
+ break;
51
+ }
52
+ case 'resize': {
53
+ if (this.__iframe)
54
+ this.__iframe.style.height = data.height;
55
+ break;
56
+ }
57
+ case 'ready': {
58
+ this.configure(this.__config);
59
+ (_b = this.__mountingTask) === null || _b === void 0 ? void 0 : _b.resolve();
60
+ break;
61
+ }
62
+ }
63
+ };
64
+ this.__iframeLoadHandler = (evt) => {
65
+ if (this.__channel) {
66
+ const contentWindow = evt.currentTarget.contentWindow;
67
+ if (!contentWindow)
68
+ throw new Error('Content window is not available.');
69
+ contentWindow.postMessage('connect', '*', [this.__channel.port2]);
70
+ }
71
+ };
72
+ this.__mountingTask = null;
73
+ this.__channel = null;
74
+ this.__iframe = null;
75
+ this.__config = config;
76
+ this.__url = url;
77
+ }
78
+ /**
79
+ * Updates the configuration of the payment card embed.
80
+ * You can change style, translations, language and interactivity settings.
81
+ * To change the URL of the payment card embed, you need to create a new instance.
82
+ * You are not required to provide the full configuration object, only the properties you want to change.
83
+ *
84
+ * @param config - The new configuration.
85
+ */
86
+ configure(config) {
87
+ var _a;
88
+ this.__config = config;
89
+ const message = Object.assign({ type: 'config' }, config);
90
+ (_a = this.__channel) === null || _a === void 0 ? void 0 : _a.port1.postMessage(JSON.stringify(message));
91
+ }
92
+ /**
93
+ * Requests the tokenization of the card data.
94
+ *
95
+ * @returns A promise that resolves with the tokenized card data.
96
+ */
97
+ tokenize() {
98
+ return new Promise((resolve, reject) => {
99
+ if (this.__channel) {
100
+ const id = this._createId();
101
+ this.__tokenizationRequests.push({ id, reject, resolve });
102
+ this.__channel.port1.postMessage(JSON.stringify({ id, type: 'tokenization_request' }));
103
+ }
104
+ else {
105
+ reject();
106
+ }
107
+ });
108
+ }
109
+ /**
110
+ * Safely removes the embed iframe from the parent node,
111
+ * closing the message channel and cleaning up event listeners.
112
+ */
113
+ unmount() {
114
+ var _a, _b, _c, _d, _e, _f;
115
+ (_a = this.__channel) === null || _a === void 0 ? void 0 : _a.port1.removeEventListener('message', this.__iframeMessageHandler);
116
+ (_b = this.__channel) === null || _b === void 0 ? void 0 : _b.port1.close();
117
+ (_c = this.__channel) === null || _c === void 0 ? void 0 : _c.port2.close();
118
+ this.__channel = null;
119
+ (_d = this.__iframe) === null || _d === void 0 ? void 0 : _d.removeEventListener('load', this.__iframeLoadHandler);
120
+ (_e = this.__iframe) === null || _e === void 0 ? void 0 : _e.remove();
121
+ this.__iframe = null;
122
+ (_f = this.__mountingTask) === null || _f === void 0 ? void 0 : _f.reject();
123
+ this.__mountingTask = null;
124
+ }
125
+ /**
126
+ * Mounts the payment card embed in the given root element. If the embed is already mounted,
127
+ * it will be unmounted first.
128
+ *
129
+ * @param root - The root element to mount the embed in.
130
+ * @returns A promise that resolves when the embed is mounted.
131
+ */
132
+ mount(root) {
133
+ this.unmount();
134
+ this.__channel = this._createMessageChannel();
135
+ this.__channel.port1.addEventListener('message', this.__iframeMessageHandler);
136
+ this.__channel.port1.start();
137
+ this.__iframe = this._createIframe(root);
138
+ this.__iframe.addEventListener('load', this.__iframeLoadHandler);
139
+ this.__iframe.style.transition = 'height 0.15s ease';
140
+ this.__iframe.style.margin = '-2px';
141
+ this.__iframe.style.height = '100px';
142
+ this.__iframe.style.width = 'calc(100% + 4px)';
143
+ this.__iframe.src = this.__url;
144
+ root.append(this.__iframe);
145
+ return new Promise((resolve, reject) => {
146
+ this.__mountingTask = { reject, resolve };
147
+ });
148
+ }
149
+ /**
150
+ * Clears the card data from the embed.
151
+ * No-op if the embed is not mounted.
152
+ */
153
+ clear() {
154
+ var _a;
155
+ (_a = this.__channel) === null || _a === void 0 ? void 0 : _a.port1.postMessage(JSON.stringify({ type: 'clear' }));
156
+ }
157
+ /* v8 ignore next */
158
+ _createMessageChannel() {
159
+ return new MessageChannel();
160
+ }
161
+ /* v8 ignore next */
162
+ _createIframe(root) {
163
+ return root.ownerDocument.createElement('iframe');
164
+ }
165
+ /* v8 ignore next */
166
+ _createId() {
167
+ return `${Date.now()}${Math.random().toFixed(6).slice(2)}`;
168
+ }
169
+ }
170
+ exports.PaymentCardEmbed = PaymentCardEmbed;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isNextTransactionDate = exports.getTimeFromFrequency = exports.getNextTransactionDateConstraints = exports.getAllowedFrequencies = exports.API = void 0;
3
+ exports.PaymentCardEmbed = exports.isNextTransactionDate = exports.getTimeFromFrequency = exports.getNextTransactionDateConstraints = exports.getAllowedFrequencies = exports.API = void 0;
4
4
  var API_js_1 = require("./API.js");
5
5
  Object.defineProperty(exports, "API", { enumerable: true, get: function () { return API_js_1.API; } });
6
6
  var getAllowedFrequencies_js_1 = require("./getAllowedFrequencies.js");
@@ -11,3 +11,5 @@ var getTimeFromFrequency_js_1 = require("../backend/getTimeFromFrequency.js");
11
11
  Object.defineProperty(exports, "getTimeFromFrequency", { enumerable: true, get: function () { return getTimeFromFrequency_js_1.getTimeFromFrequency; } });
12
12
  var isNextTransactionDate_js_1 = require("./isNextTransactionDate.js");
13
13
  Object.defineProperty(exports, "isNextTransactionDate", { enumerable: true, get: function () { return isNextTransactionDate_js_1.isNextTransactionDate; } });
14
+ var PaymentCardEmbed_js_1 = require("./PaymentCardEmbed.js");
15
+ Object.defineProperty(exports, "PaymentCardEmbed", { enumerable: true, get: function () { return PaymentCardEmbed_js_1.PaymentCardEmbed; } });
@@ -115,9 +115,8 @@ export class Rumour {
115
115
  if (!Rumour.__isResource(value) || Rumour.__isCollection(value))
116
116
  return patch;
117
117
  const props = traverse(value).map(function () {
118
- var _a;
119
- if ((_a = this.key) === null || _a === void 0 ? void 0 : _a.startsWith('_'))
120
- this.delete(true);
118
+ if (this.key === '_embedded')
119
+ return this.delete(true);
121
120
  });
122
121
  patch.set(value._links.self.href, props);
123
122
  return patch;
@@ -0,0 +1,166 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ /**
13
+ * A convenience wrapper for the payment card embed iframe. You don't have to use
14
+ * this class to embed the payment card iframe, but it provides a more convenient
15
+ * way to interact with the iframe and listen to its events.
16
+ *
17
+ * @example
18
+ * const embed = new PaymentCardEmbed({
19
+ * url: 'https://embed.foxy.io/v1.html?template_set_id=123'
20
+ * });
21
+ *
22
+ * await embed.mount(document.body);
23
+ * console.log('Token:', await embed.tokenize());
24
+ */
25
+ export class PaymentCardEmbed {
26
+ constructor(_a) {
27
+ var { url } = _a, config = __rest(_a, ["url"]);
28
+ /**
29
+ * An event handler that is triggered when Enter is pressed in the card form.
30
+ * This feature is not available for template sets configured with the `stripe_connect`
31
+ * hosted payment gateway due to the limitations of Stripe.js.
32
+ */
33
+ this.onsubmit = null;
34
+ this.__tokenizationRequests = [];
35
+ this.__iframeMessageHandler = (evt) => {
36
+ var _a, _b;
37
+ const data = JSON.parse(evt.data);
38
+ switch (data.type) {
39
+ case 'tokenization_response': {
40
+ const request = this.__tokenizationRequests.find(r => r.id === data.id);
41
+ data.token ? request === null || request === void 0 ? void 0 : request.resolve(data.token) : request === null || request === void 0 ? void 0 : request.reject();
42
+ this.__tokenizationRequests = this.__tokenizationRequests.filter(r => r.id !== data.id);
43
+ break;
44
+ }
45
+ case 'submit': {
46
+ (_a = this.onsubmit) === null || _a === void 0 ? void 0 : _a.call(this);
47
+ break;
48
+ }
49
+ case 'resize': {
50
+ if (this.__iframe)
51
+ this.__iframe.style.height = data.height;
52
+ break;
53
+ }
54
+ case 'ready': {
55
+ this.configure(this.__config);
56
+ (_b = this.__mountingTask) === null || _b === void 0 ? void 0 : _b.resolve();
57
+ break;
58
+ }
59
+ }
60
+ };
61
+ this.__iframeLoadHandler = (evt) => {
62
+ if (this.__channel) {
63
+ const contentWindow = evt.currentTarget.contentWindow;
64
+ if (!contentWindow)
65
+ throw new Error('Content window is not available.');
66
+ contentWindow.postMessage('connect', '*', [this.__channel.port2]);
67
+ }
68
+ };
69
+ this.__mountingTask = null;
70
+ this.__channel = null;
71
+ this.__iframe = null;
72
+ this.__config = config;
73
+ this.__url = url;
74
+ }
75
+ /**
76
+ * Updates the configuration of the payment card embed.
77
+ * You can change style, translations, language and interactivity settings.
78
+ * To change the URL of the payment card embed, you need to create a new instance.
79
+ * You are not required to provide the full configuration object, only the properties you want to change.
80
+ *
81
+ * @param config - The new configuration.
82
+ */
83
+ configure(config) {
84
+ var _a;
85
+ this.__config = config;
86
+ const message = Object.assign({ type: 'config' }, config);
87
+ (_a = this.__channel) === null || _a === void 0 ? void 0 : _a.port1.postMessage(JSON.stringify(message));
88
+ }
89
+ /**
90
+ * Requests the tokenization of the card data.
91
+ *
92
+ * @returns A promise that resolves with the tokenized card data.
93
+ */
94
+ tokenize() {
95
+ return new Promise((resolve, reject) => {
96
+ if (this.__channel) {
97
+ const id = this._createId();
98
+ this.__tokenizationRequests.push({ id, reject, resolve });
99
+ this.__channel.port1.postMessage(JSON.stringify({ id, type: 'tokenization_request' }));
100
+ }
101
+ else {
102
+ reject();
103
+ }
104
+ });
105
+ }
106
+ /**
107
+ * Safely removes the embed iframe from the parent node,
108
+ * closing the message channel and cleaning up event listeners.
109
+ */
110
+ unmount() {
111
+ var _a, _b, _c, _d, _e, _f;
112
+ (_a = this.__channel) === null || _a === void 0 ? void 0 : _a.port1.removeEventListener('message', this.__iframeMessageHandler);
113
+ (_b = this.__channel) === null || _b === void 0 ? void 0 : _b.port1.close();
114
+ (_c = this.__channel) === null || _c === void 0 ? void 0 : _c.port2.close();
115
+ this.__channel = null;
116
+ (_d = this.__iframe) === null || _d === void 0 ? void 0 : _d.removeEventListener('load', this.__iframeLoadHandler);
117
+ (_e = this.__iframe) === null || _e === void 0 ? void 0 : _e.remove();
118
+ this.__iframe = null;
119
+ (_f = this.__mountingTask) === null || _f === void 0 ? void 0 : _f.reject();
120
+ this.__mountingTask = null;
121
+ }
122
+ /**
123
+ * Mounts the payment card embed in the given root element. If the embed is already mounted,
124
+ * it will be unmounted first.
125
+ *
126
+ * @param root - The root element to mount the embed in.
127
+ * @returns A promise that resolves when the embed is mounted.
128
+ */
129
+ mount(root) {
130
+ this.unmount();
131
+ this.__channel = this._createMessageChannel();
132
+ this.__channel.port1.addEventListener('message', this.__iframeMessageHandler);
133
+ this.__channel.port1.start();
134
+ this.__iframe = this._createIframe(root);
135
+ this.__iframe.addEventListener('load', this.__iframeLoadHandler);
136
+ this.__iframe.style.transition = 'height 0.15s ease';
137
+ this.__iframe.style.margin = '-2px';
138
+ this.__iframe.style.height = '100px';
139
+ this.__iframe.style.width = 'calc(100% + 4px)';
140
+ this.__iframe.src = this.__url;
141
+ root.append(this.__iframe);
142
+ return new Promise((resolve, reject) => {
143
+ this.__mountingTask = { reject, resolve };
144
+ });
145
+ }
146
+ /**
147
+ * Clears the card data from the embed.
148
+ * No-op if the embed is not mounted.
149
+ */
150
+ clear() {
151
+ var _a;
152
+ (_a = this.__channel) === null || _a === void 0 ? void 0 : _a.port1.postMessage(JSON.stringify({ type: 'clear' }));
153
+ }
154
+ /* v8 ignore next */
155
+ _createMessageChannel() {
156
+ return new MessageChannel();
157
+ }
158
+ /* v8 ignore next */
159
+ _createIframe(root) {
160
+ return root.ownerDocument.createElement('iframe');
161
+ }
162
+ /* v8 ignore next */
163
+ _createId() {
164
+ return `${Date.now()}${Math.random().toFixed(6).slice(2)}`;
165
+ }
166
+ }
@@ -3,3 +3,4 @@ export { getAllowedFrequencies } from './getAllowedFrequencies.js';
3
3
  export { getNextTransactionDateConstraints } from './getNextTransactionDateConstraints.js';
4
4
  export { getTimeFromFrequency } from '../backend/getTimeFromFrequency.js';
5
5
  export { isNextTransactionDate } from './isNextTransactionDate.js';
6
+ export { PaymentCardEmbed } from './PaymentCardEmbed.js';
@@ -1,3 +1,4 @@
1
+ import type { Attributes } from './attributes';
1
2
  import type { CouponCodes } from './coupon_codes';
2
3
  import type { CouponItemCategories } from './coupon_item_categories';
3
4
  import type { GenerateCodes } from './generate_codes';
@@ -12,6 +13,8 @@ export interface Coupon extends Graph {
12
13
  'self': Coupon;
13
14
  /** Store this coupon belongs to. */
14
15
  'fx:store': Store;
16
+ /** Attributes linked to this coupon. */
17
+ 'fx:attributes': Attributes;
15
18
  /** Codes linked to this coupon. */
16
19
  'fx:coupon_codes': CouponCodes;
17
20
  /** POST here to generate random coupon codes. */
@@ -57,6 +60,12 @@ export interface Coupon extends Graph {
57
60
  customer_attribute_restrictions: string;
58
61
  /** Auto-apply coupons only. This coupon will be automatically applied when a subscription includes a product with one of the codes in the list. Wildcards are allowed just like in product code restrictions. Example: `code_1,code_2,sku_*,abc`. */
59
62
  customer_subscription_restrictions: string;
63
+ /** This restricts the usage of a coupon code based on an item's `item_option` key and value. Valid input is a json object with the keys matching the `item_option.name`, and the value an array of comma-separated matching or partially matching strings, using `*` as a wild card at the beginning, end, or middle of the string. So `{"author": ["Agatha*", "*brown"]}` will match the item where item option "author" is "Agatha Christie" or "Dan Brown". It would not match an item with no "author" option, or with an "author" of "John Doe". Optional. 6000 characters or less. */
64
+ item_option_restrictions: null | Record<string, string[]>;
65
+ /** Enables sharing coupon codes between coupons. */
66
+ shared_codes_allowed: boolean;
67
+ /** This param is using for coupon calculation amount for tax inclusive mode. Optional. [0..1]. */
68
+ inclusive_tax_rate: number;
60
69
  /** The date this resource was created. */
61
70
  date_created: string | null;
62
71
  /** The date this resource was last modified. */
@@ -76,14 +76,9 @@ export interface CustomerPortalSettings extends Graph {
76
76
  date_created: string | null;
77
77
  /** The date this resource was last modified. */
78
78
  date_modified: string | null;
79
- } & (
80
- | {
81
- /** Shared secret key. */
82
- jwtSharedSecret: string;
83
- }
84
- | {
85
- /** Private key for JWT signing. */
86
- jwtPrivateKey: string;
87
- }
88
- );
79
+ /** Shared secret key. */
80
+ jwtSharedSecret: string;
81
+ /** Private key for JWT signing, read-only. */
82
+ jwtPrivateKey?: string;
83
+ };
89
84
  }
@@ -19,6 +19,8 @@ export interface DefaultPaymentMethod extends Graph {
19
19
  save_cc: boolean;
20
20
  /** The credit card or debit card type. This will be determined automatically once the payment card is saved. */
21
21
  cc_type: string | null;
22
+ /** Token returned by our Tokenization Embed. Send this field with PATCH to update customer's payment method. */
23
+ cc_token?: string;
22
24
  /** The payment card number. This property will not be displayed as part of this resource, but can be used to modify this payment method. */
23
25
  cc_number?: number;
24
26
  /** A masked version of this payment card showing only the last 4 digits. */
@@ -1,3 +1,4 @@
1
+ import type { Attributes } from './attributes';
1
2
  import type { GenerateCodes } from './generate_codes';
2
3
  import type { GiftCardCodes } from './gift_card_codes';
3
4
  import type { GiftCardItemCategories } from './gift_card_item_categories';
@@ -12,6 +13,8 @@ export interface GiftCard extends Graph {
12
13
  'self': GiftCard;
13
14
  /** Store this gift card is assigned to. */
14
15
  'fx:store': Store;
16
+ /** Attributes linked to this gift card. */
17
+ 'fx:attributes': Attributes;
15
18
  /** POST here to generate random gift card codes. */
16
19
  'fx:generate_codes': GenerateCodes;
17
20
  /** Collection of codes for this gift card. */
@@ -30,6 +30,8 @@ export interface GiftCardCode extends Graph {
30
30
  end_date: string | null;
31
31
  /** Current balance on the gift card. Decimal. Required. */
32
32
  current_balance: number;
33
+ /** PATCH-only: use this field to link this gift card code to a customer. */
34
+ customer_id?: number | string;
33
35
  /** The date this resource was created. Readonly. */
34
36
  date_created: string | null;
35
37
  /** The date this resource was last modified. Readonly. */
@@ -15,8 +15,8 @@ export interface DefaultPaymentMethod extends Graph {
15
15
  save_cc: boolean;
16
16
  /** The credit card or debit card type. This will be determined automatically once the payment card is saved. */
17
17
  cc_type: string | null;
18
- /** The payment card number. This property will not be displayed as part of this resource, but can be used to modify this payment method. */
19
- cc_number?: number;
18
+ /** Token returned by our Tokenization Embed. Send this field with PATCH to update customer's payment method. */
19
+ cc_token?: string;
20
20
  /** A masked version of this payment card showing only the last 4 digits. */
21
21
  cc_number_masked: string | null;
22
22
  /** The payment card expiration month in the MM format. */
@@ -0,0 +1,69 @@
1
+ import type { PaymentCardEmbedConfig } from './types';
2
+ /**
3
+ * A convenience wrapper for the payment card embed iframe. You don't have to use
4
+ * this class to embed the payment card iframe, but it provides a more convenient
5
+ * way to interact with the iframe and listen to its events.
6
+ *
7
+ * @example
8
+ * const embed = new PaymentCardEmbed({
9
+ * url: 'https://embed.foxy.io/v1.html?template_set_id=123'
10
+ * });
11
+ *
12
+ * await embed.mount(document.body);
13
+ * console.log('Token:', await embed.tokenize());
14
+ */
15
+ export declare class PaymentCardEmbed {
16
+ /**
17
+ * An event handler that is triggered when Enter is pressed in the card form.
18
+ * This feature is not available for template sets configured with the `stripe_connect`
19
+ * hosted payment gateway due to the limitations of Stripe.js.
20
+ */
21
+ onsubmit: (() => void) | null;
22
+ private __tokenizationRequests;
23
+ private __iframeMessageHandler;
24
+ private __iframeLoadHandler;
25
+ private __mountingTask;
26
+ private __channel;
27
+ private __iframe;
28
+ private __config;
29
+ private __url;
30
+ constructor({ url, ...config }: {
31
+ url: string;
32
+ } & PaymentCardEmbedConfig);
33
+ /**
34
+ * Updates the configuration of the payment card embed.
35
+ * You can change style, translations, language and interactivity settings.
36
+ * To change the URL of the payment card embed, you need to create a new instance.
37
+ * You are not required to provide the full configuration object, only the properties you want to change.
38
+ *
39
+ * @param config - The new configuration.
40
+ */
41
+ configure(config: PaymentCardEmbedConfig): void;
42
+ /**
43
+ * Requests the tokenization of the card data.
44
+ *
45
+ * @returns A promise that resolves with the tokenized card data.
46
+ */
47
+ tokenize(): Promise<string>;
48
+ /**
49
+ * Safely removes the embed iframe from the parent node,
50
+ * closing the message channel and cleaning up event listeners.
51
+ */
52
+ unmount(): void;
53
+ /**
54
+ * Mounts the payment card embed in the given root element. If the embed is already mounted,
55
+ * it will be unmounted first.
56
+ *
57
+ * @param root - The root element to mount the embed in.
58
+ * @returns A promise that resolves when the embed is mounted.
59
+ */
60
+ mount(root: Element): Promise<void>;
61
+ /**
62
+ * Clears the card data from the embed.
63
+ * No-op if the embed is not mounted.
64
+ */
65
+ clear(): void;
66
+ protected _createMessageChannel(): MessageChannel;
67
+ protected _createIframe(root: Element): HTMLIFrameElement;
68
+ protected _createId(): string;
69
+ }
@@ -3,6 +3,7 @@ export { getAllowedFrequencies } from './getAllowedFrequencies.js';
3
3
  export { getNextTransactionDateConstraints } from './getNextTransactionDateConstraints.js';
4
4
  export { getTimeFromFrequency } from '../backend/getTimeFromFrequency.js';
5
5
  export { isNextTransactionDate } from './isNextTransactionDate.js';
6
+ export { PaymentCardEmbed } from './PaymentCardEmbed.js';
6
7
  import type * as Rels from './Rels';
7
8
  export type { Graph } from './Graph';
8
9
  export type { Rels };
@@ -1,3 +1,87 @@
1
+ /** Tokenization embed configuration that can be updated any time after mount. */
2
+ export type PaymentCardEmbedConfig = Partial<{
3
+ /** Translations. Note that Stripe and Square provide their own translations that can't be customized. */
4
+ translations: {
5
+ stripe?: {
6
+ label?: string;
7
+ status?: {
8
+ idle?: string;
9
+ busy?: string;
10
+ fail?: string;
11
+ };
12
+ };
13
+ square?: {
14
+ label?: string;
15
+ status?: {
16
+ idle?: string;
17
+ busy?: string;
18
+ fail?: string;
19
+ };
20
+ };
21
+ default?: {
22
+ 'cc-number'?: {
23
+ label?: string;
24
+ placeholder?: string;
25
+ v8n_required?: string;
26
+ v8n_invalid?: string;
27
+ v8n_unsupported?: string;
28
+ };
29
+ 'cc-exp'?: {
30
+ label?: string;
31
+ placeholder?: string;
32
+ v8n_required?: string;
33
+ v8n_invalid?: string;
34
+ v8n_expired?: string;
35
+ };
36
+ 'cc-csc'?: {
37
+ label?: string;
38
+ placeholder?: string;
39
+ v8n_required?: string;
40
+ v8n_invalid?: string;
41
+ };
42
+ 'status'?: {
43
+ idle?: string;
44
+ busy?: string;
45
+ fail?: string;
46
+ misconfigured?: string;
47
+ };
48
+ };
49
+ };
50
+ /** If true, all fields inside the embed will be disabled. */
51
+ disabled: boolean;
52
+ /** If true, all fields inside the embed will be set to be read-only. For Stripe and Square the fields will be disabled and styled as readonly. */
53
+ readonly: boolean;
54
+ /** Appearance settings. */
55
+ style: Partial<{
56
+ '--lumo-space-m': string;
57
+ '--lumo-space-s': string;
58
+ '--lumo-contrast-5pct': string;
59
+ '--lumo-contrast-10pct': string;
60
+ '--lumo-contrast-50pct': string;
61
+ '--lumo-size-m': string;
62
+ '--lumo-size-xs': string;
63
+ '--lumo-border-radius-m': string;
64
+ '--lumo-border-radius-s': string;
65
+ '--lumo-font-family': string;
66
+ '--lumo-font-size-m': string;
67
+ '--lumo-font-size-s': string;
68
+ '--lumo-font-size-xs': string;
69
+ '--lumo-primary-color': string;
70
+ '--lumo-primary-text-color': string;
71
+ '--lumo-primary-color-50pct': string;
72
+ '--lumo-secondary-text-color': string;
73
+ '--lumo-disabled-text-color': string;
74
+ '--lumo-body-text-color': string;
75
+ '--lumo-error-text-color': string;
76
+ '--lumo-error-color-10pct': string;
77
+ '--lumo-error-color-50pct': string;
78
+ '--lumo-line-height-xs': string;
79
+ '--lumo-base-color': string;
80
+ }>;
81
+ /** Locale to use with Stripe or Square. Has no effect on the default UI. */
82
+ lang: string;
83
+ }>;
84
+
1
85
  /** User credentials for authentication. */
2
86
  export interface Credentials {
3
87
  /** Email address associated with an account. */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@foxy.io/sdk",
3
3
  "type": "commonjs",
4
- "version": "1.11.2",
4
+ "version": "1.12.0",
5
5
  "description": "Universal SDK for a full server-side and a limited in-browser access to Foxy hAPI.",
6
6
  "main": "dist/cjs/index.js",
7
7
  "module": "dist/esm/index.js",