@sunbay/checkout-sdk-js 0.0.7 → 0.0.9
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 -2
- package/dist/index.cjs +20 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -2
- package/dist/index.d.ts +18 -2
- package/dist/index.global.js +29 -2
- package/dist/index.global.js.map +1 -1
- package/dist/index.mjs +21 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ElementType, CommandName, EventName, ElementOptions, Appearance, ElementStatus, AvailableWallets, EventPayloadMap, PublicSessionView, ConfirmReq, PaymentOutcome, GetPaymentStatusResp, 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, WalletErrorStage } from '@sunbay/checkout-sdk-protocol';
|
|
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';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* CheckoutElement — the merchant-side Element handle (spec 6).
|
|
@@ -318,6 +318,11 @@ interface CheckoutInstanceOptions {
|
|
|
318
318
|
capabilities: string[];
|
|
319
319
|
/** The initial session view returned by initialize. */
|
|
320
320
|
session: PublicSessionView;
|
|
321
|
+
/**
|
|
322
|
+
* Warnings produced during initialize (the instance did not exist yet, so they could not be
|
|
323
|
+
* delivered as events). Replayed once to the first `warning` listener.
|
|
324
|
+
*/
|
|
325
|
+
initialWarnings?: WarningEvent[];
|
|
321
326
|
/**
|
|
322
327
|
* Initial appearance customization (from createCheckout's appearance).
|
|
323
328
|
* Passed through to every created Element and serialized into its iframe src (no flash on the
|
|
@@ -371,6 +376,8 @@ declare class CheckoutInstance {
|
|
|
371
376
|
/** The paymentResult event subscription handler (unbound on destroy). */
|
|
372
377
|
private readonly paymentResultHandler;
|
|
373
378
|
private destroyed;
|
|
379
|
+
/** Warnings from initialize not yet delivered to any `warning` listener. */
|
|
380
|
+
private pendingWarnings;
|
|
374
381
|
constructor(opts: CheckoutInstanceOptions);
|
|
375
382
|
/**
|
|
376
383
|
* Create an Element handle (not auto-mounted; a mutual-exclusion conflict throws ELEMENT_CONFLICT).
|
|
@@ -450,6 +457,8 @@ declare class CheckoutInstance {
|
|
|
450
457
|
updateCheckout(patch: {
|
|
451
458
|
locale?: string;
|
|
452
459
|
appearance?: Appearance;
|
|
460
|
+
billingAddress?: AddressInfo;
|
|
461
|
+
shippingAddress?: AddressInfo;
|
|
453
462
|
}): Promise<void>;
|
|
454
463
|
/**
|
|
455
464
|
* Register a Checkout-level event handler (passes through the transport).
|
|
@@ -543,6 +552,13 @@ interface CreateCheckoutOptions {
|
|
|
543
552
|
appearance?: Appearance;
|
|
544
553
|
/** Payment method filter (subtractive/reordering only). */
|
|
545
554
|
paymentMethods?: PaymentMethodFilter;
|
|
555
|
+
/**
|
|
556
|
+
* Host-collected billing address. When complete, Apple Pay / Google Pay do not ask the user for
|
|
557
|
+
* it again, and it is used as the default for card `confirm()`.
|
|
558
|
+
*/
|
|
559
|
+
billingAddress?: AddressInfo;
|
|
560
|
+
/** Host-collected shipping address (complete = address + name + phone). Same rules as above. */
|
|
561
|
+
shippingAddress?: AddressInfo;
|
|
546
562
|
/** Internal injection point: custom transport factory (test use; not part of the public API contract). */
|
|
547
563
|
__transportFactory?: TransportFactory;
|
|
548
564
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ElementType, CommandName, EventName, ElementOptions, Appearance, ElementStatus, AvailableWallets, EventPayloadMap, PublicSessionView, ConfirmReq, PaymentOutcome, GetPaymentStatusResp, 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, WalletErrorStage } from '@sunbay/checkout-sdk-protocol';
|
|
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';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* CheckoutElement — the merchant-side Element handle (spec 6).
|
|
@@ -318,6 +318,11 @@ interface CheckoutInstanceOptions {
|
|
|
318
318
|
capabilities: string[];
|
|
319
319
|
/** The initial session view returned by initialize. */
|
|
320
320
|
session: PublicSessionView;
|
|
321
|
+
/**
|
|
322
|
+
* Warnings produced during initialize (the instance did not exist yet, so they could not be
|
|
323
|
+
* delivered as events). Replayed once to the first `warning` listener.
|
|
324
|
+
*/
|
|
325
|
+
initialWarnings?: WarningEvent[];
|
|
321
326
|
/**
|
|
322
327
|
* Initial appearance customization (from createCheckout's appearance).
|
|
323
328
|
* Passed through to every created Element and serialized into its iframe src (no flash on the
|
|
@@ -371,6 +376,8 @@ declare class CheckoutInstance {
|
|
|
371
376
|
/** The paymentResult event subscription handler (unbound on destroy). */
|
|
372
377
|
private readonly paymentResultHandler;
|
|
373
378
|
private destroyed;
|
|
379
|
+
/** Warnings from initialize not yet delivered to any `warning` listener. */
|
|
380
|
+
private pendingWarnings;
|
|
374
381
|
constructor(opts: CheckoutInstanceOptions);
|
|
375
382
|
/**
|
|
376
383
|
* Create an Element handle (not auto-mounted; a mutual-exclusion conflict throws ELEMENT_CONFLICT).
|
|
@@ -450,6 +457,8 @@ declare class CheckoutInstance {
|
|
|
450
457
|
updateCheckout(patch: {
|
|
451
458
|
locale?: string;
|
|
452
459
|
appearance?: Appearance;
|
|
460
|
+
billingAddress?: AddressInfo;
|
|
461
|
+
shippingAddress?: AddressInfo;
|
|
453
462
|
}): Promise<void>;
|
|
454
463
|
/**
|
|
455
464
|
* Register a Checkout-level event handler (passes through the transport).
|
|
@@ -543,6 +552,13 @@ interface CreateCheckoutOptions {
|
|
|
543
552
|
appearance?: Appearance;
|
|
544
553
|
/** Payment method filter (subtractive/reordering only). */
|
|
545
554
|
paymentMethods?: PaymentMethodFilter;
|
|
555
|
+
/**
|
|
556
|
+
* Host-collected billing address. When complete, Apple Pay / Google Pay do not ask the user for
|
|
557
|
+
* it again, and it is used as the default for card `confirm()`.
|
|
558
|
+
*/
|
|
559
|
+
billingAddress?: AddressInfo;
|
|
560
|
+
/** Host-collected shipping address (complete = address + name + phone). Same rules as above. */
|
|
561
|
+
shippingAddress?: AddressInfo;
|
|
546
562
|
/** Internal injection point: custom transport factory (test use; not part of the public API contract). */
|
|
547
563
|
__transportFactory?: TransportFactory;
|
|
548
564
|
}
|
package/dist/index.global.js
CHANGED
|
@@ -24,6 +24,7 @@ var SunbayCheckout = (() => {
|
|
|
24
24
|
CheckoutElement: () => CheckoutElement,
|
|
25
25
|
CheckoutInstance: () => CheckoutInstance,
|
|
26
26
|
ErrorCode: () => ErrorCode,
|
|
27
|
+
WARNING_CODES: () => WARNING_CODES,
|
|
27
28
|
createCheckout: () => createCheckout,
|
|
28
29
|
version: () => version
|
|
29
30
|
});
|
|
@@ -128,6 +129,16 @@ var SunbayCheckout = (() => {
|
|
|
128
129
|
PAYMENT_FLOW_ERROR: "PAYMENT_FLOW_ERROR",
|
|
129
130
|
UNSUPPORTED_CAPABILITY: "UNSUPPORTED_CAPABILITY"
|
|
130
131
|
};
|
|
132
|
+
var WARNING_CODES = {
|
|
133
|
+
/** A `paymentMethods` filter identifier matched nothing (unknown / not offered). */
|
|
134
|
+
PAYMENT_METHOD_FILTER_IGNORED: "PAYMENT_METHOD_FILTER_IGNORED",
|
|
135
|
+
/** An expressCheckout option was not whitelisted or had an invalid value. */
|
|
136
|
+
EXPRESS_OPTION_IGNORED: "EXPRESS_OPTION_IGNORED",
|
|
137
|
+
/** A host-provided billing/shipping address was incomplete, so it was treated as not provided. */
|
|
138
|
+
ADDRESS_INCOMPLETE: "ADDRESS_INCOMPLETE",
|
|
139
|
+
/** A host-provided address was ignored because our Address Element owns that mode. */
|
|
140
|
+
ADDRESS_ENTRY_IGNORED: "ADDRESS_ENTRY_IGNORED"
|
|
141
|
+
};
|
|
131
142
|
var IFRAME_RESIZE_MESSAGE_TYPE = "sunbay:checkout:iframe-resize";
|
|
132
143
|
function isIframeResizeMessage(data) {
|
|
133
144
|
if (typeof data !== "object" || data === null) {
|
|
@@ -1106,6 +1117,7 @@ var SunbayCheckout = (() => {
|
|
|
1106
1117
|
/** The current pending confirm (at most one at a time). */
|
|
1107
1118
|
this.pendingConfirm = null;
|
|
1108
1119
|
this.destroyed = false;
|
|
1120
|
+
this.pendingWarnings = opts.initialWarnings ? [...opts.initialWarnings] : [];
|
|
1109
1121
|
this.checkoutId = opts.checkoutId;
|
|
1110
1122
|
this.runtimeId = opts.runtimeId;
|
|
1111
1123
|
this.capabilities = opts.capabilities;
|
|
@@ -1303,6 +1315,18 @@ var SunbayCheckout = (() => {
|
|
|
1303
1315
|
on(event, handler) {
|
|
1304
1316
|
this.assertAlive();
|
|
1305
1317
|
this.transport.on(event, handler);
|
|
1318
|
+
if (event === "warning" && this.pendingWarnings.length > 0) {
|
|
1319
|
+
const pending = this.pendingWarnings;
|
|
1320
|
+
this.pendingWarnings = [];
|
|
1321
|
+
queueMicrotask(() => {
|
|
1322
|
+
if (this.destroyed) {
|
|
1323
|
+
return;
|
|
1324
|
+
}
|
|
1325
|
+
for (const w of pending) {
|
|
1326
|
+
handler(w);
|
|
1327
|
+
}
|
|
1328
|
+
});
|
|
1329
|
+
}
|
|
1306
1330
|
}
|
|
1307
1331
|
/**
|
|
1308
1332
|
* Unregister an event handler (safe to call after destruction).
|
|
@@ -1497,7 +1521,9 @@ var SunbayCheckout = (() => {
|
|
|
1497
1521
|
checkoutClientSecret: opts.checkoutClientSecret,
|
|
1498
1522
|
locale: opts.locale,
|
|
1499
1523
|
appearance: opts.appearance,
|
|
1500
|
-
paymentMethods: opts.paymentMethods
|
|
1524
|
+
paymentMethods: opts.paymentMethods,
|
|
1525
|
+
billingAddress: opts.billingAddress,
|
|
1526
|
+
shippingAddress: opts.shippingAddress
|
|
1501
1527
|
};
|
|
1502
1528
|
let initResp;
|
|
1503
1529
|
try {
|
|
@@ -1513,6 +1539,7 @@ var SunbayCheckout = (() => {
|
|
|
1513
1539
|
transport,
|
|
1514
1540
|
capabilities: initResp.capabilities,
|
|
1515
1541
|
session: initResp.session,
|
|
1542
|
+
initialWarnings: initResp.warnings,
|
|
1516
1543
|
appearance: opts.appearance
|
|
1517
1544
|
});
|
|
1518
1545
|
}
|
|
@@ -1542,7 +1569,7 @@ var SunbayCheckout = (() => {
|
|
|
1542
1569
|
const w = window;
|
|
1543
1570
|
w.SunbayCheckout = { ...w.SunbayCheckout ?? {}, createCheckout };
|
|
1544
1571
|
}
|
|
1545
|
-
var version = true ? "0.0.
|
|
1572
|
+
var version = true ? "0.0.9" : "0.0.0";
|
|
1546
1573
|
return __toCommonJS(index_exports);
|
|
1547
1574
|
})();
|
|
1548
1575
|
//# sourceMappingURL=index.global.js.map
|