@vio-live/web-sdk 0.7.0 → 0.9.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.
- package/dist/{chunk-GPMDZSC2.js → chunk-OTL6QM3G.js} +168 -17
- package/dist/chunk-OTL6QM3G.js.map +1 -0
- package/dist/{chunk-4ZEN4J7I.js → chunk-SNIF67UB.js} +99 -3
- package/dist/chunk-SNIF67UB.js.map +1 -0
- package/dist/core/index.d.ts +50 -2
- package/dist/core/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +3 -3
- package/dist/{tokens-CCZuuTN6.d.ts → tokens-CrO2ciCS.d.ts} +35 -4
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +3 -3
- package/package.json +2 -2
- package/dist/chunk-4ZEN4J7I.js.map +0 -1
- package/dist/chunk-GPMDZSC2.js.map +0 -1
|
@@ -2591,6 +2591,47 @@ async function getQliroOrder(checkoutId, options) {
|
|
|
2591
2591
|
return json?.data?.Payment?.GetQliroOrder ?? null;
|
|
2592
2592
|
}
|
|
2593
2593
|
|
|
2594
|
+
// src/core/checkout/payments/walley.ts
|
|
2595
|
+
var CREATE_PAYMENT_WALLEY_MUTATION = `
|
|
2596
|
+
mutation CreatePaymentWalley($checkoutId: String!, $countryCode: String!, $href: String!, $email: String) {
|
|
2597
|
+
Payment {
|
|
2598
|
+
CreatePaymentWalley(checkout_id: $checkoutId, country_code: $countryCode, href: $href, email: $email) {
|
|
2599
|
+
order_id
|
|
2600
|
+
status
|
|
2601
|
+
html_snippet
|
|
2602
|
+
public_token
|
|
2603
|
+
purchase_country
|
|
2604
|
+
purchase_currency
|
|
2605
|
+
total_price
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2609
|
+
`;
|
|
2610
|
+
var GET_WALLEY_ORDER_QUERY = `
|
|
2611
|
+
query GetWalleyOrder($checkoutId: String!) {
|
|
2612
|
+
Payment {
|
|
2613
|
+
GetWalleyOrder(checkout_id: $checkoutId) {
|
|
2614
|
+
order_id
|
|
2615
|
+
status
|
|
2616
|
+
html_snippet
|
|
2617
|
+
public_token
|
|
2618
|
+
purchase_country
|
|
2619
|
+
purchase_currency
|
|
2620
|
+
total_price
|
|
2621
|
+
}
|
|
2622
|
+
}
|
|
2623
|
+
}
|
|
2624
|
+
`;
|
|
2625
|
+
async function createPaymentWalley(variables, options) {
|
|
2626
|
+
const json = await executeCartGraphQL(CREATE_PAYMENT_WALLEY_MUTATION, variables, options);
|
|
2627
|
+
return json?.data?.Payment?.CreatePaymentWalley ?? null;
|
|
2628
|
+
}
|
|
2629
|
+
async function getWalleyOrder(checkoutId, options) {
|
|
2630
|
+
const json = await executeCartGraphQL(GET_WALLEY_ORDER_QUERY, { checkoutId }, options);
|
|
2631
|
+
return json?.data?.Payment?.GetWalleyOrder ?? null;
|
|
2632
|
+
}
|
|
2633
|
+
var WALLEY_PURCHASE_COMPLETED_EVENT = "walleyCheckoutPurchaseCompleted";
|
|
2634
|
+
|
|
2594
2635
|
// src/core/checkout/checkout-manager.ts
|
|
2595
2636
|
function describeError(err) {
|
|
2596
2637
|
if (err instanceof Error) return err.message;
|
|
@@ -3249,6 +3290,61 @@ var CheckoutManager = class _CheckoutManager extends EventTarget {
|
|
|
3249
3290
|
const opts = await getCartGraphQLOptions(sponsorId ?? this.state?.sponsorId);
|
|
3250
3291
|
return getQliroOrder(checkoutId, opts);
|
|
3251
3292
|
}
|
|
3293
|
+
/**
|
|
3294
|
+
* Mount the Walley embedded checkout. `onPurchaseCompleted` fires as soon
|
|
3295
|
+
* as Walley's own script dispatches its success event INSIDE the widget —
|
|
3296
|
+
* no redirect needed. `getWalleyOrder`/the confirmation-URL fallback
|
|
3297
|
+
* remain for the case the event is missed (tab backgrounded, reload).
|
|
3298
|
+
*/
|
|
3299
|
+
async mountWalleyCheckout(container, sponsorId, onPurchaseCompleted) {
|
|
3300
|
+
const spId = sponsorId ?? this.state?.sponsorId;
|
|
3301
|
+
if (!spId) throw new Error("[CheckoutManager] no sponsor for Walley");
|
|
3302
|
+
const cart = this.cartManager.getCart(spId);
|
|
3303
|
+
let cartId = cart?.cartId;
|
|
3304
|
+
if (!cartId) cartId = await this.cartManager.ensureCartId(spId);
|
|
3305
|
+
if (!cartId) {
|
|
3306
|
+
throw new Error(`[CheckoutManager] Failed to obtain cart_id for sponsor ${spId}`);
|
|
3307
|
+
}
|
|
3308
|
+
const opts = await getCartGraphQLOptions(spId);
|
|
3309
|
+
let checkoutId = this.state?.checkoutId;
|
|
3310
|
+
if (!checkoutId) {
|
|
3311
|
+
const checkoutRes = await createCheckout(cartId, opts);
|
|
3312
|
+
checkoutId = checkoutRes?.id;
|
|
3313
|
+
if (checkoutId && this.state) {
|
|
3314
|
+
this.state = { ...this.state, checkoutId };
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
if (!checkoutId) {
|
|
3318
|
+
throw new Error("[CheckoutManager] no backend checkout for the Walley order");
|
|
3319
|
+
}
|
|
3320
|
+
const href = kustomCleanHref();
|
|
3321
|
+
const order = await createPaymentWalley(
|
|
3322
|
+
{
|
|
3323
|
+
checkoutId,
|
|
3324
|
+
countryCode: getGlobalCountryCode(),
|
|
3325
|
+
href,
|
|
3326
|
+
email: this.state?.address?.email || void 0
|
|
3327
|
+
},
|
|
3328
|
+
opts
|
|
3329
|
+
);
|
|
3330
|
+
if (!order?.html_snippet) {
|
|
3331
|
+
throw new Error("Walley order creation failed: missing html_snippet");
|
|
3332
|
+
}
|
|
3333
|
+
renderKustomSnippet(container, order.html_snippet);
|
|
3334
|
+
if (onPurchaseCompleted) {
|
|
3335
|
+
const handler = () => {
|
|
3336
|
+
document.removeEventListener(WALLEY_PURCHASE_COMPLETED_EVENT, handler);
|
|
3337
|
+
onPurchaseCompleted(order);
|
|
3338
|
+
};
|
|
3339
|
+
document.addEventListener(WALLEY_PURCHASE_COMPLETED_EVENT, handler, { once: true });
|
|
3340
|
+
}
|
|
3341
|
+
return order;
|
|
3342
|
+
}
|
|
3343
|
+
/** Re-read the Walley session owned by a checkout — the confirmation trip. */
|
|
3344
|
+
async getWalleyOrder(checkoutId, sponsorId) {
|
|
3345
|
+
const opts = await getCartGraphQLOptions(sponsorId ?? this.state?.sponsorId);
|
|
3346
|
+
return getWalleyOrder(checkoutId, opts);
|
|
3347
|
+
}
|
|
3252
3348
|
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
3253
3349
|
setAddress(address) {
|
|
3254
3350
|
if (!this.state) return;
|
|
@@ -4058,7 +4154,7 @@ function toSmallestUnit(amount, currency) {
|
|
|
4058
4154
|
}
|
|
4059
4155
|
|
|
4060
4156
|
// src/core/version.ts
|
|
4061
|
-
var SDK_VERSION = "0.
|
|
4157
|
+
var SDK_VERSION = "0.9.0";
|
|
4062
4158
|
|
|
4063
4159
|
// src/core/analytics/analytics-manager.ts
|
|
4064
4160
|
var SESSION_TTL_MS = 30 * 60 * 1e3;
|
|
@@ -4684,5 +4780,5 @@ var _vioGlobal = globalThis;
|
|
|
4684
4780
|
var Vio = _vioGlobal.__VIO_FACADE__ ?? (_vioGlobal.__VIO_FACADE__ = new VioFacade());
|
|
4685
4781
|
|
|
4686
4782
|
export { ADD_ITEM_MUTATION, AnalyticsManager, CREATE_CART_MUTATION, CREATE_CHECKOUT_MUTATION, CREATE_PAYMENT_STRIPE_MUTATION, CREATE_PAYMENT_VIPPS_MUTATION, CartManager, CheckoutManager, CommerceClient, Configuration, DELETE_ITEM_MUTATION, GET_AVAILABLE_PAYMENT_METHODS_QUERY, GET_CART_QUERY, GET_CHECKOUT_QUERY, GET_LINE_ITEMS_BY_SUPPLIER_QUERY, GET_VIPPS_STATUS_QUERY, SDK_VERSION, UPDATE_CHECKOUT_MUTATION, UPDATE_ITEM_MUTATION, UPDATE_SHIPPINGS_BY_SUPPLIER_MUTATION, Vio, VioApi, VioApiError, __decorateClass, addItem, checkApplePayAvailability, createCart, createCheckout, createCommerceClient, createPaymentStripe, createPaymentVipps, createVioApi, deleteItem, displayPrice, executeCartGraphQL, formatPrice, getAvailablePaymentMethods, getCart, getCartGraphQLOptions, getCheckout, getCustomerSessionId, getGlobalCurrency, getLineItemsBySupplier, getVippsStatus, primaryImageUrl, showApplePaySheet, updateCheckout, updateItem, updateShippingsBySupplier };
|
|
4687
|
-
//# sourceMappingURL=chunk-
|
|
4688
|
-
//# sourceMappingURL=chunk-
|
|
4783
|
+
//# sourceMappingURL=chunk-SNIF67UB.js.map
|
|
4784
|
+
//# sourceMappingURL=chunk-SNIF67UB.js.map
|