@sunbay/checkout-sdk-js 0.1.0 → 0.1.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/index.cjs +11 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -2
- package/dist/index.d.ts +23 -2
- package/dist/index.global.js +11 -3
- package/dist/index.global.js.map +1 -1
- package/dist/index.mjs +11 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -73,6 +73,13 @@ interface CheckoutElementOptions {
|
|
|
73
73
|
* `&colorScheme=`. Runtime switching goes through the updateCheckout command, not here.
|
|
74
74
|
*/
|
|
75
75
|
appearance?: Appearance;
|
|
76
|
+
/**
|
|
77
|
+
* Initial locale (from createCheckout's `locale`). When provided and non-empty it is appended
|
|
78
|
+
* to the iframe src as `&locale=<value>`, so the hosted iframe renders in that language on the
|
|
79
|
+
* first frame (no flash). The hosted side resolves it to a supported language and ignores
|
|
80
|
+
* unknown values. Runtime switching goes through the updateCheckout command, not here.
|
|
81
|
+
*/
|
|
82
|
+
locale?: string;
|
|
76
83
|
}
|
|
77
84
|
/** Options for {@link CheckoutElement.mount}. */
|
|
78
85
|
interface MountOptions {
|
|
@@ -98,6 +105,8 @@ declare class CheckoutElement {
|
|
|
98
105
|
private readonly colorScheme;
|
|
99
106
|
/** Initial appearance customization (appended to the iframe src when it contains variables/rules; not appended when absent or colorScheme-only). */
|
|
100
107
|
private readonly appearance;
|
|
108
|
+
/** Initial locale (appended to the iframe src; not appended when absent or empty). */
|
|
109
|
+
private readonly locale;
|
|
101
110
|
/** Destruction callback (injected by the instance): called at the end of destroy() so the instance removes itself from the mutual-exclusion registry to free the slot. */
|
|
102
111
|
private readonly onDestroy;
|
|
103
112
|
private status;
|
|
@@ -221,7 +230,8 @@ declare class CheckoutElement {
|
|
|
221
230
|
* (no flash on the first frame); if the initial appearance contains variables or rules, append
|
|
222
231
|
* `&appearance=<encodeURIComponent(JSON.stringify(appearance))>` (takes effect on the first
|
|
223
232
|
* frame, no flash). An appearance containing only colorScheme (no variables/rules) is not
|
|
224
|
-
* appended, to avoid an empty appearance string.
|
|
233
|
+
* appended, to avoid an empty appearance string. If an initial locale is provided, append
|
|
234
|
+
* `&locale=<value>` (first frame renders in that language). For expressCheckout, additionally append the
|
|
225
235
|
* wallet toggles / per-wallet buttonType / global buttonHeight (see {@link resolveExpressQuery}).
|
|
226
236
|
*
|
|
227
237
|
* elementId is sent with the src so the hosted child echoes it verbatim in iframe-resize
|
|
@@ -332,6 +342,11 @@ interface CheckoutInstanceOptions {
|
|
|
332
342
|
* Not appended when absent. Runtime switching goes through the updateCheckout command.
|
|
333
343
|
*/
|
|
334
344
|
appearance?: Appearance;
|
|
345
|
+
/**
|
|
346
|
+
* Initial locale (from createCheckout's `locale`). Passed through to every created Element and
|
|
347
|
+
* appended to its iframe src as `&locale=`, so the first frame renders in that language.
|
|
348
|
+
*/
|
|
349
|
+
locale?: string;
|
|
335
350
|
}
|
|
336
351
|
/**
|
|
337
352
|
* Optional confirm parameters (aligned with ConfirmReq, minus the instance-generated operationId,
|
|
@@ -362,6 +377,8 @@ declare class CheckoutInstance {
|
|
|
362
377
|
private session;
|
|
363
378
|
/** Initial appearance customization (passed through to each created Element's iframe src). */
|
|
364
379
|
private readonly appearance;
|
|
380
|
+
/** Initial locale (passed through to each created Element's iframe src). */
|
|
381
|
+
private readonly locale;
|
|
365
382
|
/** Created Elements (indexed by elementId). */
|
|
366
383
|
/**
|
|
367
384
|
* The **single source of truth** for the mutual-exclusion registry: elementId → the created
|
|
@@ -546,7 +563,11 @@ interface CreateCheckoutOptions {
|
|
|
546
563
|
env?: Env;
|
|
547
564
|
/** Override the hosted origin (takes precedence over env). */
|
|
548
565
|
hostOrigin?: string;
|
|
549
|
-
/**
|
|
566
|
+
/**
|
|
567
|
+
* Initial locale, e.g. `'en-US'` or `'zh-CN'`. Sent to the runtime and appended to every
|
|
568
|
+
* Element iframe src, so the first frame renders in that language. Unknown values fall back to
|
|
569
|
+
* the browser language. Change it later with `updateCheckout({ locale })`.
|
|
570
|
+
*/
|
|
550
571
|
locale?: string;
|
|
551
572
|
/** Appearance customization. */
|
|
552
573
|
appearance?: Appearance;
|
package/dist/index.d.ts
CHANGED
|
@@ -73,6 +73,13 @@ interface CheckoutElementOptions {
|
|
|
73
73
|
* `&colorScheme=`. Runtime switching goes through the updateCheckout command, not here.
|
|
74
74
|
*/
|
|
75
75
|
appearance?: Appearance;
|
|
76
|
+
/**
|
|
77
|
+
* Initial locale (from createCheckout's `locale`). When provided and non-empty it is appended
|
|
78
|
+
* to the iframe src as `&locale=<value>`, so the hosted iframe renders in that language on the
|
|
79
|
+
* first frame (no flash). The hosted side resolves it to a supported language and ignores
|
|
80
|
+
* unknown values. Runtime switching goes through the updateCheckout command, not here.
|
|
81
|
+
*/
|
|
82
|
+
locale?: string;
|
|
76
83
|
}
|
|
77
84
|
/** Options for {@link CheckoutElement.mount}. */
|
|
78
85
|
interface MountOptions {
|
|
@@ -98,6 +105,8 @@ declare class CheckoutElement {
|
|
|
98
105
|
private readonly colorScheme;
|
|
99
106
|
/** Initial appearance customization (appended to the iframe src when it contains variables/rules; not appended when absent or colorScheme-only). */
|
|
100
107
|
private readonly appearance;
|
|
108
|
+
/** Initial locale (appended to the iframe src; not appended when absent or empty). */
|
|
109
|
+
private readonly locale;
|
|
101
110
|
/** Destruction callback (injected by the instance): called at the end of destroy() so the instance removes itself from the mutual-exclusion registry to free the slot. */
|
|
102
111
|
private readonly onDestroy;
|
|
103
112
|
private status;
|
|
@@ -221,7 +230,8 @@ declare class CheckoutElement {
|
|
|
221
230
|
* (no flash on the first frame); if the initial appearance contains variables or rules, append
|
|
222
231
|
* `&appearance=<encodeURIComponent(JSON.stringify(appearance))>` (takes effect on the first
|
|
223
232
|
* frame, no flash). An appearance containing only colorScheme (no variables/rules) is not
|
|
224
|
-
* appended, to avoid an empty appearance string.
|
|
233
|
+
* appended, to avoid an empty appearance string. If an initial locale is provided, append
|
|
234
|
+
* `&locale=<value>` (first frame renders in that language). For expressCheckout, additionally append the
|
|
225
235
|
* wallet toggles / per-wallet buttonType / global buttonHeight (see {@link resolveExpressQuery}).
|
|
226
236
|
*
|
|
227
237
|
* elementId is sent with the src so the hosted child echoes it verbatim in iframe-resize
|
|
@@ -332,6 +342,11 @@ interface CheckoutInstanceOptions {
|
|
|
332
342
|
* Not appended when absent. Runtime switching goes through the updateCheckout command.
|
|
333
343
|
*/
|
|
334
344
|
appearance?: Appearance;
|
|
345
|
+
/**
|
|
346
|
+
* Initial locale (from createCheckout's `locale`). Passed through to every created Element and
|
|
347
|
+
* appended to its iframe src as `&locale=`, so the first frame renders in that language.
|
|
348
|
+
*/
|
|
349
|
+
locale?: string;
|
|
335
350
|
}
|
|
336
351
|
/**
|
|
337
352
|
* Optional confirm parameters (aligned with ConfirmReq, minus the instance-generated operationId,
|
|
@@ -362,6 +377,8 @@ declare class CheckoutInstance {
|
|
|
362
377
|
private session;
|
|
363
378
|
/** Initial appearance customization (passed through to each created Element's iframe src). */
|
|
364
379
|
private readonly appearance;
|
|
380
|
+
/** Initial locale (passed through to each created Element's iframe src). */
|
|
381
|
+
private readonly locale;
|
|
365
382
|
/** Created Elements (indexed by elementId). */
|
|
366
383
|
/**
|
|
367
384
|
* The **single source of truth** for the mutual-exclusion registry: elementId → the created
|
|
@@ -546,7 +563,11 @@ interface CreateCheckoutOptions {
|
|
|
546
563
|
env?: Env;
|
|
547
564
|
/** Override the hosted origin (takes precedence over env). */
|
|
548
565
|
hostOrigin?: string;
|
|
549
|
-
/**
|
|
566
|
+
/**
|
|
567
|
+
* Initial locale, e.g. `'en-US'` or `'zh-CN'`. Sent to the runtime and appended to every
|
|
568
|
+
* Element iframe src, so the first frame renders in that language. Unknown values fall back to
|
|
569
|
+
* the browser language. Change it later with `updateCheckout({ locale })`.
|
|
570
|
+
*/
|
|
550
571
|
locale?: string;
|
|
551
572
|
/** Appearance customization. */
|
|
552
573
|
appearance?: Appearance;
|
package/dist/index.global.js
CHANGED
|
@@ -582,6 +582,7 @@ var SunbayCheckout = (() => {
|
|
|
582
582
|
this.options = opts.initialOptions;
|
|
583
583
|
this.colorScheme = opts.colorScheme;
|
|
584
584
|
this.appearance = opts.appearance;
|
|
585
|
+
this.locale = opts.locale;
|
|
585
586
|
this.mode = opts.initialOptions?.mode;
|
|
586
587
|
this.onDestroy = opts.onDestroy;
|
|
587
588
|
this.installInputActions();
|
|
@@ -959,7 +960,8 @@ var SunbayCheckout = (() => {
|
|
|
959
960
|
* (no flash on the first frame); if the initial appearance contains variables or rules, append
|
|
960
961
|
* `&appearance=<encodeURIComponent(JSON.stringify(appearance))>` (takes effect on the first
|
|
961
962
|
* frame, no flash). An appearance containing only colorScheme (no variables/rules) is not
|
|
962
|
-
* appended, to avoid an empty appearance string.
|
|
963
|
+
* appended, to avoid an empty appearance string. If an initial locale is provided, append
|
|
964
|
+
* `&locale=<value>` (first frame renders in that language). For expressCheckout, additionally append the
|
|
963
965
|
* wallet toggles / per-wallet buttonType / global buttonHeight (see {@link resolveExpressQuery}).
|
|
964
966
|
*
|
|
965
967
|
* elementId is sent with the src so the hosted child echoes it verbatim in iframe-resize
|
|
@@ -982,6 +984,9 @@ var SunbayCheckout = (() => {
|
|
|
982
984
|
if (this.colorScheme) {
|
|
983
985
|
query += `&colorScheme=${encodeURIComponent(this.colorScheme)}`;
|
|
984
986
|
}
|
|
987
|
+
if (this.locale) {
|
|
988
|
+
query += `&locale=${encodeURIComponent(this.locale)}`;
|
|
989
|
+
}
|
|
985
990
|
const effectiveAppearance = this.perElementAppearance() ?? this.appearance;
|
|
986
991
|
if (effectiveAppearance && (effectiveAppearance.variables || effectiveAppearance.rules)) {
|
|
987
992
|
query += `&appearance=${encodeURIComponent(JSON.stringify(effectiveAppearance))}`;
|
|
@@ -1134,6 +1139,7 @@ var SunbayCheckout = (() => {
|
|
|
1134
1139
|
this.transport = opts.transport;
|
|
1135
1140
|
this.session = opts.session;
|
|
1136
1141
|
this.appearance = opts.appearance;
|
|
1142
|
+
this.locale = opts.locale;
|
|
1137
1143
|
this.paymentResultHandler = (payload) => {
|
|
1138
1144
|
this.handlePaymentResult(payload);
|
|
1139
1145
|
};
|
|
@@ -1165,6 +1171,7 @@ var SunbayCheckout = (() => {
|
|
|
1165
1171
|
initialOptions: options,
|
|
1166
1172
|
colorScheme: this.appearance?.colorScheme,
|
|
1167
1173
|
appearance: this.appearance,
|
|
1174
|
+
locale: this.locale,
|
|
1168
1175
|
onDestroy: (id) => this.releaseElement(id)
|
|
1169
1176
|
};
|
|
1170
1177
|
const element = CheckoutElement.create(elementOpts);
|
|
@@ -1549,7 +1556,8 @@ var SunbayCheckout = (() => {
|
|
|
1549
1556
|
capabilities: initResp.capabilities,
|
|
1550
1557
|
session: initResp.session,
|
|
1551
1558
|
initialWarnings: initResp.warnings,
|
|
1552
|
-
appearance: opts.appearance
|
|
1559
|
+
appearance: opts.appearance,
|
|
1560
|
+
locale: opts.locale
|
|
1553
1561
|
});
|
|
1554
1562
|
}
|
|
1555
1563
|
function waitForHello(transport) {
|
|
@@ -1578,7 +1586,7 @@ var SunbayCheckout = (() => {
|
|
|
1578
1586
|
const w = window;
|
|
1579
1587
|
w.SunbayCheckout = { ...w.SunbayCheckout ?? {}, createCheckout };
|
|
1580
1588
|
}
|
|
1581
|
-
var version = true ? "0.1.
|
|
1589
|
+
var version = true ? "0.1.1" : "0.0.0";
|
|
1582
1590
|
return __toCommonJS(index_exports);
|
|
1583
1591
|
})();
|
|
1584
1592
|
//# sourceMappingURL=index.global.js.map
|