@sunbay/checkout-sdk-js 0.0.9 → 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/README.md +4 -1
- package/dist/index.cjs +16 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -4
- package/dist/index.d.ts +25 -4
- package/dist/index.global.js +23 -6
- package/dist/index.global.js.map +1 -1
- package/dist/index.mjs +16 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ElementType, CommandName, EventName, ElementOptions, Appearance, ElementStatus, AvailableWallets, EventPayloadMap, PublicSessionView, WarningEvent, ConfirmReq, PaymentOutcome, GetPaymentStatusResp, AddressInfo, PaymentMethodFilter } from '@sunbay/checkout-sdk-protocol';
|
|
2
|
-
export { AddressElementOptions, AddressInfo, Appearance, AppearanceRuleStyle, AppearanceRuleTarget, AppearanceVariables, ApplePayButtonTheme, ApplePayButtonType, ApplePayOptions, AvailableWallets, BlurEvent, CardElementOptions, CardFieldElementOptions, ChangeEvent, CheckoutError, CheckoutErrorCategory, ElementOptions, ElementReadyEvent, ElementStatus, ElementType, ErrorCode, ErrorCodeValue, ErrorEvent, EventName, EventPayloadMap, ExpressAvailabilityChangeEvent, ExpressCheckoutElementOptions, FocusEvent, GooglePayButtonTheme, GooglePayButtonType, GooglePayOptions, LoadErrorEvent, PaymentAction, PaymentMethod, PaymentMethodFilter, PaymentOutcome, PaymentResultEvent, PaymentStateChangeEvent, PublicPaymentMethod, PublicProductLine, PublicSessionView, ReadyEvent, TxnStatus, WARNING_CODES, WalletErrorStage, WarningCode, WarningEvent } from '@sunbay/checkout-sdk-protocol';
|
|
2
|
+
export { AddressElementOptions, AddressFormStyle, AddressInfo, Appearance, AppearanceRuleStyle, AppearanceRuleTarget, AppearanceVariables, ApplePayButtonTheme, ApplePayButtonType, ApplePayOptions, AvailableWallets, BlurEvent, CardElementOptions, CardFieldElementOptions, ChangeEvent, CheckoutError, CheckoutErrorCategory, ElementOptions, ElementReadyEvent, ElementStatus, ElementType, ErrorCode, ErrorCodeValue, ErrorEvent, EventName, EventPayloadMap, ExpressAvailabilityChangeEvent, ExpressCheckoutElementOptions, FocusEvent, GooglePayButtonTheme, GooglePayButtonType, GooglePayOptions, LoadErrorEvent, PaymentAction, PaymentMethod, PaymentMethodFilter, PaymentOutcome, PaymentResultEvent, PaymentStateChangeEvent, PublicPaymentMethod, PublicProductLine, PublicSessionView, ReadyEvent, SessionStatus, TxnStatus, WARNING_CODES, WalletErrorStage, WarningCode, WarningEvent } from '@sunbay/checkout-sdk-protocol';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* CheckoutElement — the merchant-side Element handle (spec 6).
|
|
@@ -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
|
|
@@ -444,7 +461,7 @@ declare class CheckoutInstance {
|
|
|
444
461
|
/**
|
|
445
462
|
* Query the payment status (returns TxnStatus as-is, no transformation).
|
|
446
463
|
*
|
|
447
|
-
* @returns txnStatus (may
|
|
464
|
+
* @returns txnStatus (may be absent when the session is expired), sessionStatus and txnId.
|
|
448
465
|
* @throws rejects INSTANCE_DESTROYED when destroyed.
|
|
449
466
|
*/
|
|
450
467
|
getPaymentStatus(): Promise<GetPaymentStatusResp>;
|
|
@@ -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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ElementType, CommandName, EventName, ElementOptions, Appearance, ElementStatus, AvailableWallets, EventPayloadMap, PublicSessionView, WarningEvent, ConfirmReq, PaymentOutcome, GetPaymentStatusResp, AddressInfo, PaymentMethodFilter } from '@sunbay/checkout-sdk-protocol';
|
|
2
|
-
export { AddressElementOptions, AddressInfo, Appearance, AppearanceRuleStyle, AppearanceRuleTarget, AppearanceVariables, ApplePayButtonTheme, ApplePayButtonType, ApplePayOptions, AvailableWallets, BlurEvent, CardElementOptions, CardFieldElementOptions, ChangeEvent, CheckoutError, CheckoutErrorCategory, ElementOptions, ElementReadyEvent, ElementStatus, ElementType, ErrorCode, ErrorCodeValue, ErrorEvent, EventName, EventPayloadMap, ExpressAvailabilityChangeEvent, ExpressCheckoutElementOptions, FocusEvent, GooglePayButtonTheme, GooglePayButtonType, GooglePayOptions, LoadErrorEvent, PaymentAction, PaymentMethod, PaymentMethodFilter, PaymentOutcome, PaymentResultEvent, PaymentStateChangeEvent, PublicPaymentMethod, PublicProductLine, PublicSessionView, ReadyEvent, TxnStatus, WARNING_CODES, WalletErrorStage, WarningCode, WarningEvent } from '@sunbay/checkout-sdk-protocol';
|
|
2
|
+
export { AddressElementOptions, AddressFormStyle, AddressInfo, Appearance, AppearanceRuleStyle, AppearanceRuleTarget, AppearanceVariables, ApplePayButtonTheme, ApplePayButtonType, ApplePayOptions, AvailableWallets, BlurEvent, CardElementOptions, CardFieldElementOptions, ChangeEvent, CheckoutError, CheckoutErrorCategory, ElementOptions, ElementReadyEvent, ElementStatus, ElementType, ErrorCode, ErrorCodeValue, ErrorEvent, EventName, EventPayloadMap, ExpressAvailabilityChangeEvent, ExpressCheckoutElementOptions, FocusEvent, GooglePayButtonTheme, GooglePayButtonType, GooglePayOptions, LoadErrorEvent, PaymentAction, PaymentMethod, PaymentMethodFilter, PaymentOutcome, PaymentResultEvent, PaymentStateChangeEvent, PublicPaymentMethod, PublicProductLine, PublicSessionView, ReadyEvent, SessionStatus, TxnStatus, WARNING_CODES, WalletErrorStage, WarningCode, WarningEvent } from '@sunbay/checkout-sdk-protocol';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* CheckoutElement — the merchant-side Element handle (spec 6).
|
|
@@ -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
|
|
@@ -444,7 +461,7 @@ declare class CheckoutInstance {
|
|
|
444
461
|
/**
|
|
445
462
|
* Query the payment status (returns TxnStatus as-is, no transformation).
|
|
446
463
|
*
|
|
447
|
-
* @returns txnStatus (may
|
|
464
|
+
* @returns txnStatus (may be absent when the session is expired), sessionStatus and txnId.
|
|
448
465
|
* @throws rejects INSTANCE_DESTROYED when destroyed.
|
|
449
466
|
*/
|
|
450
467
|
getPaymentStatus(): Promise<GetPaymentStatusResp>;
|
|
@@ -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
|
@@ -137,7 +137,13 @@ var SunbayCheckout = (() => {
|
|
|
137
137
|
/** A host-provided billing/shipping address was incomplete, so it was treated as not provided. */
|
|
138
138
|
ADDRESS_INCOMPLETE: "ADDRESS_INCOMPLETE",
|
|
139
139
|
/** A host-provided address was ignored because our Address Element owns that mode. */
|
|
140
|
-
ADDRESS_ENTRY_IGNORED: "ADDRESS_ENTRY_IGNORED"
|
|
140
|
+
ADDRESS_ENTRY_IGNORED: "ADDRESS_ENTRY_IGNORED",
|
|
141
|
+
/**
|
|
142
|
+
* The wallet (Apple Pay / Google Pay) payment parameters delivered by the session were missing
|
|
143
|
+
* or invalid, so that wallet is not offered. Registered for the native SDKs (iOS first); the Web
|
|
144
|
+
* runtime currently only logs this condition and does not emit the event.
|
|
145
|
+
*/
|
|
146
|
+
WALLET_PARAMS_INVALID: "WALLET_PARAMS_INVALID"
|
|
141
147
|
};
|
|
142
148
|
var IFRAME_RESIZE_MESSAGE_TYPE = "sunbay:checkout:iframe-resize";
|
|
143
149
|
function isIframeResizeMessage(data) {
|
|
@@ -576,6 +582,7 @@ var SunbayCheckout = (() => {
|
|
|
576
582
|
this.options = opts.initialOptions;
|
|
577
583
|
this.colorScheme = opts.colorScheme;
|
|
578
584
|
this.appearance = opts.appearance;
|
|
585
|
+
this.locale = opts.locale;
|
|
579
586
|
this.mode = opts.initialOptions?.mode;
|
|
580
587
|
this.onDestroy = opts.onDestroy;
|
|
581
588
|
this.installInputActions();
|
|
@@ -953,7 +960,8 @@ var SunbayCheckout = (() => {
|
|
|
953
960
|
* (no flash on the first frame); if the initial appearance contains variables or rules, append
|
|
954
961
|
* `&appearance=<encodeURIComponent(JSON.stringify(appearance))>` (takes effect on the first
|
|
955
962
|
* frame, no flash). An appearance containing only colorScheme (no variables/rules) is not
|
|
956
|
-
* 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
|
|
957
965
|
* wallet toggles / per-wallet buttonType / global buttonHeight (see {@link resolveExpressQuery}).
|
|
958
966
|
*
|
|
959
967
|
* elementId is sent with the src so the hosted child echoes it verbatim in iframe-resize
|
|
@@ -965,14 +973,20 @@ var SunbayCheckout = (() => {
|
|
|
965
973
|
let query = `?checkoutId=${encodeURIComponent(this.checkoutId)}`;
|
|
966
974
|
query += `&elementId=${encodeURIComponent(this.elementId)}`;
|
|
967
975
|
if (this.type === "address") {
|
|
968
|
-
const mode = this.options
|
|
976
|
+
const { mode, style } = this.options ?? {};
|
|
969
977
|
if (mode) {
|
|
970
978
|
query += `&mode=${encodeURIComponent(mode)}`;
|
|
971
979
|
}
|
|
980
|
+
if (style === "simple" || style === "full") {
|
|
981
|
+
query += `&style=${style}`;
|
|
982
|
+
}
|
|
972
983
|
}
|
|
973
984
|
if (this.colorScheme) {
|
|
974
985
|
query += `&colorScheme=${encodeURIComponent(this.colorScheme)}`;
|
|
975
986
|
}
|
|
987
|
+
if (this.locale) {
|
|
988
|
+
query += `&locale=${encodeURIComponent(this.locale)}`;
|
|
989
|
+
}
|
|
976
990
|
const effectiveAppearance = this.perElementAppearance() ?? this.appearance;
|
|
977
991
|
if (effectiveAppearance && (effectiveAppearance.variables || effectiveAppearance.rules)) {
|
|
978
992
|
query += `&appearance=${encodeURIComponent(JSON.stringify(effectiveAppearance))}`;
|
|
@@ -1125,6 +1139,7 @@ var SunbayCheckout = (() => {
|
|
|
1125
1139
|
this.transport = opts.transport;
|
|
1126
1140
|
this.session = opts.session;
|
|
1127
1141
|
this.appearance = opts.appearance;
|
|
1142
|
+
this.locale = opts.locale;
|
|
1128
1143
|
this.paymentResultHandler = (payload) => {
|
|
1129
1144
|
this.handlePaymentResult(payload);
|
|
1130
1145
|
};
|
|
@@ -1156,6 +1171,7 @@ var SunbayCheckout = (() => {
|
|
|
1156
1171
|
initialOptions: options,
|
|
1157
1172
|
colorScheme: this.appearance?.colorScheme,
|
|
1158
1173
|
appearance: this.appearance,
|
|
1174
|
+
locale: this.locale,
|
|
1159
1175
|
onDestroy: (id) => this.releaseElement(id)
|
|
1160
1176
|
};
|
|
1161
1177
|
const element = CheckoutElement.create(elementOpts);
|
|
@@ -1287,7 +1303,7 @@ var SunbayCheckout = (() => {
|
|
|
1287
1303
|
/**
|
|
1288
1304
|
* Query the payment status (returns TxnStatus as-is, no transformation).
|
|
1289
1305
|
*
|
|
1290
|
-
* @returns txnStatus (may
|
|
1306
|
+
* @returns txnStatus (may be absent when the session is expired), sessionStatus and txnId.
|
|
1291
1307
|
* @throws rejects INSTANCE_DESTROYED when destroyed.
|
|
1292
1308
|
*/
|
|
1293
1309
|
async getPaymentStatus() {
|
|
@@ -1540,7 +1556,8 @@ var SunbayCheckout = (() => {
|
|
|
1540
1556
|
capabilities: initResp.capabilities,
|
|
1541
1557
|
session: initResp.session,
|
|
1542
1558
|
initialWarnings: initResp.warnings,
|
|
1543
|
-
appearance: opts.appearance
|
|
1559
|
+
appearance: opts.appearance,
|
|
1560
|
+
locale: opts.locale
|
|
1544
1561
|
});
|
|
1545
1562
|
}
|
|
1546
1563
|
function waitForHello(transport) {
|
|
@@ -1569,7 +1586,7 @@ var SunbayCheckout = (() => {
|
|
|
1569
1586
|
const w = window;
|
|
1570
1587
|
w.SunbayCheckout = { ...w.SunbayCheckout ?? {}, createCheckout };
|
|
1571
1588
|
}
|
|
1572
|
-
var version = true ? "0.
|
|
1589
|
+
var version = true ? "0.1.1" : "0.0.0";
|
|
1573
1590
|
return __toCommonJS(index_exports);
|
|
1574
1591
|
})();
|
|
1575
1592
|
//# sourceMappingURL=index.global.js.map
|