@vio-live/web-sdk 0.11.0 → 0.19.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/README.md +9 -0
- package/dist/{chunk-U2QG4IVJ.js → chunk-CMNTHF66.js} +1321 -57
- package/dist/chunk-CMNTHF66.js.map +1 -0
- package/dist/{chunk-XU5LGUBU.js → chunk-NUNGU6LL.js} +1774 -269
- package/dist/chunk-NUNGU6LL.js.map +1 -0
- package/dist/chunk-PZUOMOLF.js +3 -0
- package/dist/{chunk-QYQQ5J6E.js.map → chunk-PZUOMOLF.js.map} +1 -1
- package/dist/core/index.d.ts +623 -120
- package/dist/core/index.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +3 -3
- package/dist/{tokens-D6PBisUm.d.ts → tokens-IrVSMVcA.d.ts} +384 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +3 -3
- package/package.json +2 -1
- package/dist/chunk-QYQQ5J6E.js +0 -3
- package/dist/chunk-U2QG4IVJ.js.map +0 -1
- package/dist/chunk-XU5LGUBU.js.map +0 -1
package/dist/core/index.d.ts
CHANGED
|
@@ -196,7 +196,7 @@ declare function formatPrice(amount: number, currency?: string): string;
|
|
|
196
196
|
declare function primaryImageUrl(product: Product): string | undefined;
|
|
197
197
|
|
|
198
198
|
/**
|
|
199
|
-
* Vio REST API client — talks to `api-
|
|
199
|
+
* Vio REST API client — talks to `api-staging.vio.live` (or override).
|
|
200
200
|
*
|
|
201
201
|
* Endpoints (mirrors the iOS SDK's surface):
|
|
202
202
|
* GET /v2/mobile/config bootstrap (sponsors + market)
|
|
@@ -211,7 +211,7 @@ declare function primaryImageUrl(product: Product): string | undefined;
|
|
|
211
211
|
*/
|
|
212
212
|
|
|
213
213
|
interface VioApiOptions {
|
|
214
|
-
/** REST API base URL, e.g. `https://api-
|
|
214
|
+
/** REST API base URL, e.g. `https://api-staging.vio.live`. */
|
|
215
215
|
apiBase: string;
|
|
216
216
|
/** Top-level Vio apiKey for this client app. */
|
|
217
217
|
apiKey: string;
|
|
@@ -280,6 +280,16 @@ declare class ChannelProduct {
|
|
|
280
280
|
* Returns an empty array if no ids are provided.
|
|
281
281
|
*/
|
|
282
282
|
getByIds(options: GetProductsByIdsOptions): Promise<Product[]>;
|
|
283
|
+
/**
|
|
284
|
+
* The seller's Company name for one product, or null (none set, or an API
|
|
285
|
+
* that does not have the field yet). Never throws.
|
|
286
|
+
*
|
|
287
|
+
* Never from the cache, on purpose: graphql caches product answers by
|
|
288
|
+
* path whatever fields the query asked, so this narrow query, written to
|
|
289
|
+
* the cache, would hand the next full product query a product with no
|
|
290
|
+
* price and no images. `useCache: false` neither reads nor writes it.
|
|
291
|
+
*/
|
|
292
|
+
getSellerCompany(productId: number): Promise<string | null>;
|
|
283
293
|
}
|
|
284
294
|
declare class Channel {
|
|
285
295
|
readonly product: ChannelProduct;
|
|
@@ -470,6 +480,174 @@ declare class CartManager extends EventTarget {
|
|
|
470
480
|
private emit;
|
|
471
481
|
}
|
|
472
482
|
|
|
483
|
+
/**
|
|
484
|
+
* Vipps MobilePay Payment Adapter — GraphQL Integration & Types.
|
|
485
|
+
*
|
|
486
|
+
* Vipps payment integration uses 2 GraphQL operations:
|
|
487
|
+
*
|
|
488
|
+
* 1. `CreatePaymentVipps` mutation:
|
|
489
|
+
* Initiates a Vipps payment session for a checkout and returns `payment_url`.
|
|
490
|
+
*
|
|
491
|
+
* 2. `GetVippsStatus` query:
|
|
492
|
+
* Queries Vipps payment state directly for a checkout (`state`).
|
|
493
|
+
*/
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* GraphQL mutation to create a Vipps payment session.
|
|
497
|
+
*/
|
|
498
|
+
declare const CREATE_PAYMENT_VIPPS_MUTATION = "\nmutation CreatePaymentVipps($checkoutId: String!, $email: String, $returnUrl: String!, $express: Boolean) {\n Payment {\n CreatePaymentVipps(checkout_id: $checkoutId, email: $email, return_url: $returnUrl, express: $express) {\n payment_url\n reference\n express\n reason\n }\n }\n}\n";
|
|
499
|
+
/**
|
|
500
|
+
* GraphQL query to fetch current Vipps payment status.
|
|
501
|
+
*/
|
|
502
|
+
declare const GET_VIPPS_STATUS_QUERY = "\nquery GetVippsStatus($checkoutId: String!) {\n Payment {\n GetVippsStatus(checkout_id: $checkoutId) {\n state\n }\n }\n}\n";
|
|
503
|
+
interface CreatePaymentVippsVariables extends Record<string, unknown> {
|
|
504
|
+
checkoutId: string;
|
|
505
|
+
/** Optional since Express: Vipps hands the email back with the payment. */
|
|
506
|
+
email?: string;
|
|
507
|
+
returnUrl: string;
|
|
508
|
+
/**
|
|
509
|
+
* `true` asks for Express — address and delivery chosen inside the Vipps
|
|
510
|
+
* app. When the cart cannot have it, no payment is created and the answer
|
|
511
|
+
* says `express: false` with the reason; the caller then opens the
|
|
512
|
+
* ordinary checkout.
|
|
513
|
+
*/
|
|
514
|
+
express?: boolean;
|
|
515
|
+
}
|
|
516
|
+
interface CreatePaymentVippsResponse {
|
|
517
|
+
/** Absent when Express was asked for and refused. */
|
|
518
|
+
payment_url?: string;
|
|
519
|
+
/** The reference the seller reads in its Vipps portal. */
|
|
520
|
+
reference?: string;
|
|
521
|
+
express?: boolean;
|
|
522
|
+
reason?: string;
|
|
523
|
+
}
|
|
524
|
+
interface GetVippsStatusVariables extends Record<string, unknown> {
|
|
525
|
+
checkoutId: string;
|
|
526
|
+
}
|
|
527
|
+
interface VippsStatusResult {
|
|
528
|
+
state: string;
|
|
529
|
+
}
|
|
530
|
+
type VippsPaymentState = 'CREATED' | 'INITIATED' | 'AUTHORIZED' | 'TERMINATED' | 'EXPIRED' | string;
|
|
531
|
+
/**
|
|
532
|
+
* Executes the `CreatePaymentVipps` GraphQL mutation.
|
|
533
|
+
*/
|
|
534
|
+
declare function createPaymentVipps(variables: CreatePaymentVippsVariables | Record<string, unknown>, options?: CartQueryOptions): Promise<CreatePaymentVippsResponse | null>;
|
|
535
|
+
/**
|
|
536
|
+
* Executes the `GetVippsStatus` GraphQL query.
|
|
537
|
+
*/
|
|
538
|
+
declare function getVippsStatus(variables: GetVippsStatusVariables | Record<string, unknown>, options?: CartQueryOptions): Promise<VippsStatusResult | null>;
|
|
539
|
+
|
|
540
|
+
declare const CREATE_CART_MUTATION = "\nmutation CreateCart($customerSessionId: String!, $currency: String!, $shippingCountry: String) {\n Cart {\n CreateCart(customer_session_id: $customerSessionId, currency: $currency, shipping_country: $shippingCountry) {\n cart_id\n customer_session_id\n shipping_country\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n subtotal\n shipping\n currency\n available_shipping_countries\n }\n }\n}\n";
|
|
541
|
+
declare const ADD_ITEM_MUTATION = "\nmutation AddItem($cartId: String!, $lineItems: [LineItemInput!]!) {\n Cart {\n AddItem(cart_id: $cartId, line_items: $lineItems) {\n cart_id\n customer_session_id\n shipping_country\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n subtotal\n shipping\n currency\n available_shipping_countries\n }\n }\n}\n";
|
|
542
|
+
declare const DELETE_ITEM_MUTATION = "\nmutation DeleteItem($cartId: String!, $cartItemId: String!) {\n Cart {\n DeleteItem(cart_id: $cartId, cart_item_id: $cartItemId) {\n cart_id\n customer_session_id\n shipping_country\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n subtotal\n shipping\n currency\n available_shipping_countries\n }\n }\n}\n";
|
|
543
|
+
declare const UPDATE_ITEM_MUTATION = "\nmutation UpdateItem($cartId: String!, $cartItemId: String!, $shippingId: String, $qty: Int) {\n Cart {\n UpdateItem(cart_id: $cartId, cart_item_id: $cartItemId, shipping_id: $shippingId, qty: $qty) {\n cart_id\n customer_session_id\n shipping_country\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n subtotal\n shipping\n currency\n available_shipping_countries\n }\n }\n}\n";
|
|
544
|
+
declare const GET_CART_QUERY = "\nquery GetCart($cartId: String!) {\n Cart {\n GetCart(cart_id: $cartId) {\n cart_id\n customer_session_id\n shipping_country\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n subtotal\n shipping\n currency\n available_shipping_countries\n }\n }\n}\n";
|
|
545
|
+
declare const GET_LINE_ITEMS_BY_SUPPLIER_QUERY = "\nquery GetLineItemsBySupplier($cartId: String!) {\n Cart {\n GetLineItemsBySupplier(cart_id: $cartId) {\n supplier {\n id\n name\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n }\n }\n}\n";
|
|
546
|
+
declare const UPDATE_SHIPPINGS_BY_SUPPLIER_MUTATION = "\nmutation UpdateShippingsBySupplier($cartId: String!, $data: [DataUpdateShippingsBySupplier!]!) {\n Cart {\n UpdateShippingsBySupplier(cart_id: $cartId, data: $data) {\n cart_id\n customer_session_id\n shipping_country\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n subtotal\n shipping\n currency\n available_shipping_countries\n }\n }\n}\n";
|
|
547
|
+
declare const CREATE_CHECKOUT_MUTATION = "\nmutation CreateCheckout($cartId: String!) {\n Checkout {\n CreateCheckout(cart_id: $cartId) {\n buyer_accepts_purchase_conditions\n buyer_accepts_terms_conditions\n created_at\n updated_at\n id\n deleted_at\n success_url\n cancel_url\n payment_method\n email\n status\n checkout_url\n origin_payment_id\n billing_address {\n id\n first_name\n last_name\n phone_code\n phone\n company\n address1\n address2\n city\n province\n province_code\n country\n country_code\n zip\n }\n shipping_address {\n id\n first_name\n last_name\n phone_code\n phone\n company\n address1\n address2\n city\n province\n province_code\n country\n country_code\n zip\n }\n available_payment_methods {\n name\n }\n discount_code\n cart {\n cart_id\n customer_session_id\n shipping_country\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n subtotal\n shipping\n currency\n available_shipping_countries\n }\n totals {\n currency_code\n subtotal\n shipping\n total\n taxes\n tax_rate\n discounts\n }\n }\n }\n}\n";
|
|
548
|
+
declare const UPDATE_CHECKOUT_MUTATION = "\nmutation UpdateCheckout($checkoutId: String!, $status: String, $successUrl: String, $email: String, $cancelUrl: String, $paymentMethod: String, $shippingAddress: AddressArgs, $billingAddress: AddressArgs, $buyerAcceptsPurchaseConditions: Boolean, $buyerAcceptsTermsConditions: Boolean) {\n Checkout {\n UpdateCheckout(checkout_id: $checkoutId, status: $status, success_url: $successUrl, email: $email, cancel_url: $cancelUrl, payment_method: $paymentMethod, shipping_address: $shippingAddress, billing_address: $billingAddress, buyer_accepts_purchase_conditions: $buyerAcceptsPurchaseConditions, buyer_accepts_terms_conditions: $buyerAcceptsTermsConditions) {\n buyer_accepts_purchase_conditions\n buyer_accepts_terms_conditions\n created_at\n updated_at\n id\n deleted_at\n success_url\n cancel_url\n payment_method\n email\n status\n checkout_url\n origin_payment_id\n billing_address {\n id\n first_name\n last_name\n phone_code\n phone\n company\n address1\n address2\n city\n province\n province_code\n country\n country_code\n zip\n }\n shipping_address {\n id\n first_name\n last_name\n phone_code\n phone\n company\n address1\n address2\n city\n province\n province_code\n country\n country_code\n zip\n }\n available_payment_methods {\n name\n }\n discount_code\n cart {\n cart_id\n customer_session_id\n shipping_country\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n subtotal\n shipping\n currency\n available_shipping_countries\n }\n totals {\n currency_code\n subtotal\n shipping\n total\n taxes\n tax_rate\n discounts\n }\n }\n }\n}\n";
|
|
549
|
+
declare const GET_CHECKOUT_QUERY = "\nquery GetCheckout($checkoutId: String!) {\n Checkout {\n GetCheckout(checkout_id: $checkoutId) {\n buyer_accepts_purchase_conditions\n buyer_accepts_terms_conditions\n created_at\n updated_at\n id\n deleted_at\n success_url\n cancel_url\n payment_method\n email\n status\n checkout_url\n origin_payment_id\n billing_address {\n id\n first_name\n last_name\n phone_code\n phone\n company\n address1\n address2\n city\n province\n province_code\n country\n country_code\n zip\n }\n shipping_address {\n id\n first_name\n last_name\n phone_code\n phone\n company\n address1\n address2\n city\n province\n province_code\n country\n country_code\n zip\n }\n available_payment_methods {\n name\n }\n discount_code\n cart {\n cart_id\n customer_session_id\n shipping_country\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n subtotal\n shipping\n currency\n available_shipping_countries\n }\n totals {\n currency_code\n subtotal\n shipping\n total\n taxes\n tax_rate\n discounts\n }\n }\n }\n}\n";
|
|
550
|
+
declare const GET_AVAILABLE_PAYMENT_METHODS_QUERY = "\nquery Config {\n Payment {\n GetAvailablePaymentMethods {\n config {\n name\n type\n value\n }\n name\n }\n }\n}\n";
|
|
551
|
+
/** Transport options for a cart/checkout GraphQL call. */
|
|
552
|
+
interface CartQueryOptions {
|
|
553
|
+
endpoint?: string;
|
|
554
|
+
apiKey?: string;
|
|
555
|
+
/** Sponsor commerce key — goes in the Authorization header. */
|
|
556
|
+
commerceKey?: string;
|
|
557
|
+
/** True when the commerce key came from a resolved sponsor (bootstrap).
|
|
558
|
+
* False = we fell back to the host apiKey — writes like CreateCart should
|
|
559
|
+
* NOT proceed with the wrong key (the cart would be orphaned). */
|
|
560
|
+
sponsorResolved?: boolean;
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Resolve endpoint + keys for cart GraphQL calls. Awaits Vio.bootstrap() once
|
|
564
|
+
* if it hasn't run yet (the sponsor commerce keys come from bootstrap), then
|
|
565
|
+
* uses the sponsor's commerce apiKey (via the Vio facade on globalThis,
|
|
566
|
+
* avoiding an import cycle); falls back to the host apiKey.
|
|
567
|
+
*/
|
|
568
|
+
declare function getCartGraphQLOptions(sponsorId?: number): Promise<CartQueryOptions>;
|
|
569
|
+
/** Stable per-browser customer session id (backend CreateCart requires one). */
|
|
570
|
+
declare function getCustomerSessionId(): string;
|
|
571
|
+
interface GraphQLEnvelope {
|
|
572
|
+
data?: Record<string, Record<string, unknown>>;
|
|
573
|
+
errors?: Array<{
|
|
574
|
+
message?: string;
|
|
575
|
+
}>;
|
|
576
|
+
}
|
|
577
|
+
/** Execute a GraphQL query/mutation against the configured commerce endpoint.
|
|
578
|
+
* Callers that skip `getCartGraphQLOptions()` (or pass a bare sponsorId) get
|
|
579
|
+
* it resolved here instead of silently sending an unauthenticated request. */
|
|
580
|
+
declare function executeCartGraphQL(query: string, variables: Record<string, unknown>, options?: CartQueryOptions | number | undefined): Promise<GraphQLEnvelope>;
|
|
581
|
+
declare function createCart(customerSessionId: string, currency: string, shippingCountry?: string | null, options?: CartQueryOptions): Promise<any>;
|
|
582
|
+
declare function addItem(cartId: string, lineItems: unknown[], options?: CartQueryOptions): Promise<any>;
|
|
583
|
+
declare function deleteItem(cartId: string, cartItemId: string, options?: CartQueryOptions): Promise<any>;
|
|
584
|
+
declare function updateItem(cartId: string, cartItemId: string, shippingId?: string | null, qty?: number | null, options?: CartQueryOptions): Promise<any>;
|
|
585
|
+
declare function getCart(cartId: string, options?: CartQueryOptions): Promise<any>;
|
|
586
|
+
declare function getLineItemsBySupplier(cartId: string, options?: CartQueryOptions): Promise<any>;
|
|
587
|
+
declare function updateShippingsBySupplier(cartId: string, data: unknown[], options?: CartQueryOptions): Promise<any>;
|
|
588
|
+
declare function createCheckout(cartId: string, options?: CartQueryOptions): Promise<any>;
|
|
589
|
+
declare function updateCheckout(variables: Record<string, unknown>, options?: CartQueryOptions): Promise<any>;
|
|
590
|
+
declare function getCheckout(checkoutId: string, options?: CartQueryOptions): Promise<any>;
|
|
591
|
+
declare function getAvailablePaymentMethods(options?: CartQueryOptions): Promise<any>;
|
|
592
|
+
declare const CREATE_PAYMENT_STRIPE_MUTATION = "\nmutation CreatePaymentStripe($checkoutId: String!, $successUrl: String!, $paymentMethod: String!, $email: String!) {\n Payment {\n CreatePaymentStripe(checkout_id: $checkoutId, success_url: $successUrl, payment_method: $paymentMethod, email: $email) {\n order_id\n checkout_url\n }\n }\n}\n";
|
|
593
|
+
declare function createPaymentStripe(variables: Record<string, unknown>, options?: CartQueryOptions): Promise<any>;
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Stripe on our own page — the Payment Element, no redirect.
|
|
597
|
+
*
|
|
598
|
+
* The older web flow minted a Stripe Payment Link and sent the shopper to a
|
|
599
|
+
* page hosted by Stripe. This one keeps them here (Angelo, 2026-09-24):
|
|
600
|
+
*
|
|
601
|
+
* 1. Vio Commerce creates a PaymentIntent for the checkout
|
|
602
|
+
* (`Payment { CreatePaymentIntentStripe }`) and answers with its client
|
|
603
|
+
* secret AND the publishable key of the account that minted it — the
|
|
604
|
+
* seller's when they brought both keys, ours otherwise. The two are
|
|
605
|
+
* halves of one account: the browser confirms with the key what the
|
|
606
|
+
* server minted with the secret one.
|
|
607
|
+
* 2. Stripe's Payment Element is mounted in a LIGHT-DOM container, the way
|
|
608
|
+
* the other embedded widgets are. Card fields are Stripe's own iframes,
|
|
609
|
+
* so card data never touches this SDK or our servers.
|
|
610
|
+
* 3. `confirm()` pays. A 3-D Secure challenge opens in Stripe's own modal
|
|
611
|
+
* over the page: `redirect: 'if_required'` keeps the shopper here for
|
|
612
|
+
* cards, and still redirects for a method that has no other way.
|
|
613
|
+
* 4. The Commerce order is NOT born here. Stripe's `payment_intent.succeeded`
|
|
614
|
+
* webhook creates it, verified server-side; the checkout is polled for
|
|
615
|
+
* its status afterwards, exactly as the redirect return does.
|
|
616
|
+
*/
|
|
617
|
+
|
|
618
|
+
/** What the backend hands over to pay a checkout on our page. */
|
|
619
|
+
interface StripeIntent {
|
|
620
|
+
/** `pi_..._secret_...`: what the browser confirms. */
|
|
621
|
+
client_secret: string;
|
|
622
|
+
/** The key of the SAME account that minted the secret. */
|
|
623
|
+
publishable_key: string;
|
|
624
|
+
customer?: string;
|
|
625
|
+
/**
|
|
626
|
+
* Stripe Connect (ADR-0022): the seller's connected account, where the
|
|
627
|
+
* intent lives. The browser must name it or Stripe answers "no such
|
|
628
|
+
* payment_intent". Absent for every seller not on Connect.
|
|
629
|
+
*/
|
|
630
|
+
stripe_account?: string;
|
|
631
|
+
}
|
|
632
|
+
/** What `confirm()` answers. The browser's word is never the order. */
|
|
633
|
+
type StripeConfirmOutcome = {
|
|
634
|
+
status: 'succeeded';
|
|
635
|
+
paymentIntentId?: string;
|
|
636
|
+
}
|
|
637
|
+
/** Authorised but not settled yet, or Stripe redirected and will return. */
|
|
638
|
+
| {
|
|
639
|
+
status: 'pending';
|
|
640
|
+
paymentIntentId?: string;
|
|
641
|
+
} | {
|
|
642
|
+
status: 'failed';
|
|
643
|
+
message?: string;
|
|
644
|
+
code?: string;
|
|
645
|
+
};
|
|
646
|
+
interface StripeElementHandle {
|
|
647
|
+
confirm(): Promise<StripeConfirmOutcome>;
|
|
648
|
+
unmount(): void;
|
|
649
|
+
}
|
|
650
|
+
|
|
473
651
|
/**
|
|
474
652
|
* Apple Pay on the Web — via Stripe Payment Request API.
|
|
475
653
|
*
|
|
@@ -640,105 +818,6 @@ declare global {
|
|
|
640
818
|
}
|
|
641
819
|
}
|
|
642
820
|
|
|
643
|
-
/**
|
|
644
|
-
* Vipps MobilePay Payment Adapter — GraphQL Integration & Types.
|
|
645
|
-
*
|
|
646
|
-
* Vipps payment integration uses 2 GraphQL operations:
|
|
647
|
-
*
|
|
648
|
-
* 1. `CreatePaymentVipps` mutation:
|
|
649
|
-
* Initiates a Vipps payment session for a checkout and returns `payment_url`.
|
|
650
|
-
*
|
|
651
|
-
* 2. `GetVippsStatus` query:
|
|
652
|
-
* Queries Vipps payment state directly for a checkout (`state`).
|
|
653
|
-
*/
|
|
654
|
-
|
|
655
|
-
/**
|
|
656
|
-
* GraphQL mutation to create a Vipps payment session.
|
|
657
|
-
*/
|
|
658
|
-
declare const CREATE_PAYMENT_VIPPS_MUTATION = "\nmutation CreatePaymentVipps($checkoutId: String!, $email: String!, $returnUrl: String!) {\n Payment {\n CreatePaymentVipps(checkout_id: $checkoutId, email: $email, return_url: $returnUrl) {\n payment_url\n }\n }\n}\n";
|
|
659
|
-
/**
|
|
660
|
-
* GraphQL query to fetch current Vipps payment status.
|
|
661
|
-
*/
|
|
662
|
-
declare const GET_VIPPS_STATUS_QUERY = "\nquery GetVippsStatus($checkoutId: String!) {\n Payment {\n GetVippsStatus(checkout_id: $checkoutId) {\n state\n }\n }\n}\n";
|
|
663
|
-
interface CreatePaymentVippsVariables extends Record<string, unknown> {
|
|
664
|
-
checkoutId: string;
|
|
665
|
-
email: string;
|
|
666
|
-
returnUrl: string;
|
|
667
|
-
}
|
|
668
|
-
interface CreatePaymentVippsResponse {
|
|
669
|
-
payment_url: string;
|
|
670
|
-
}
|
|
671
|
-
interface GetVippsStatusVariables extends Record<string, unknown> {
|
|
672
|
-
checkoutId: string;
|
|
673
|
-
}
|
|
674
|
-
interface VippsStatusResult {
|
|
675
|
-
state: string;
|
|
676
|
-
}
|
|
677
|
-
type VippsPaymentState = 'CREATED' | 'INITIATED' | 'AUTHORIZED' | 'TERMINATED' | 'EXPIRED' | string;
|
|
678
|
-
/**
|
|
679
|
-
* Executes the `CreatePaymentVipps` GraphQL mutation.
|
|
680
|
-
*/
|
|
681
|
-
declare function createPaymentVipps(variables: CreatePaymentVippsVariables | Record<string, unknown>, options?: CartQueryOptions): Promise<CreatePaymentVippsResponse | null>;
|
|
682
|
-
/**
|
|
683
|
-
* Executes the `GetVippsStatus` GraphQL query.
|
|
684
|
-
*/
|
|
685
|
-
declare function getVippsStatus(variables: GetVippsStatusVariables | Record<string, unknown>, options?: CartQueryOptions): Promise<VippsStatusResult | null>;
|
|
686
|
-
|
|
687
|
-
declare const CREATE_CART_MUTATION = "\nmutation CreateCart($customerSessionId: String!, $currency: String!, $shippingCountry: String) {\n Cart {\n CreateCart(customer_session_id: $customerSessionId, currency: $currency, shipping_country: $shippingCountry) {\n cart_id\n customer_session_id\n shipping_country\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n subtotal\n shipping\n currency\n available_shipping_countries\n }\n }\n}\n";
|
|
688
|
-
declare const ADD_ITEM_MUTATION = "\nmutation AddItem($cartId: String!, $lineItems: [LineItemInput!]!) {\n Cart {\n AddItem(cart_id: $cartId, line_items: $lineItems) {\n cart_id\n customer_session_id\n shipping_country\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n subtotal\n shipping\n currency\n available_shipping_countries\n }\n }\n}\n";
|
|
689
|
-
declare const DELETE_ITEM_MUTATION = "\nmutation DeleteItem($cartId: String!, $cartItemId: String!) {\n Cart {\n DeleteItem(cart_id: $cartId, cart_item_id: $cartItemId) {\n cart_id\n customer_session_id\n shipping_country\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n subtotal\n shipping\n currency\n available_shipping_countries\n }\n }\n}\n";
|
|
690
|
-
declare const UPDATE_ITEM_MUTATION = "\nmutation UpdateItem($cartId: String!, $cartItemId: String!, $shippingId: String, $qty: Int) {\n Cart {\n UpdateItem(cart_id: $cartId, cart_item_id: $cartItemId, shipping_id: $shippingId, qty: $qty) {\n cart_id\n customer_session_id\n shipping_country\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n subtotal\n shipping\n currency\n available_shipping_countries\n }\n }\n}\n";
|
|
691
|
-
declare const GET_CART_QUERY = "\nquery GetCart($cartId: String!) {\n Cart {\n GetCart(cart_id: $cartId) {\n cart_id\n customer_session_id\n shipping_country\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n subtotal\n shipping\n currency\n available_shipping_countries\n }\n }\n}\n";
|
|
692
|
-
declare const GET_LINE_ITEMS_BY_SUPPLIER_QUERY = "\nquery GetLineItemsBySupplier($cartId: String!) {\n Cart {\n GetLineItemsBySupplier(cart_id: $cartId) {\n supplier {\n id\n name\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n }\n }\n}\n";
|
|
693
|
-
declare const UPDATE_SHIPPINGS_BY_SUPPLIER_MUTATION = "\nmutation UpdateShippingsBySupplier($cartId: String!, $data: [DataUpdateShippingsBySupplier!]!) {\n Cart {\n UpdateShippingsBySupplier(cart_id: $cartId, data: $data) {\n cart_id\n customer_session_id\n shipping_country\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n subtotal\n shipping\n currency\n available_shipping_countries\n }\n }\n}\n";
|
|
694
|
-
declare const CREATE_CHECKOUT_MUTATION = "\nmutation CreateCheckout($cartId: String!) {\n Checkout {\n CreateCheckout(cart_id: $cartId) {\n buyer_accepts_purchase_conditions\n buyer_accepts_terms_conditions\n created_at\n updated_at\n id\n deleted_at\n success_url\n cancel_url\n payment_method\n email\n status\n checkout_url\n origin_payment_id\n billing_address {\n id\n first_name\n last_name\n phone_code\n phone\n company\n address1\n address2\n city\n province\n province_code\n country\n country_code\n zip\n }\n shipping_address {\n id\n first_name\n last_name\n phone_code\n phone\n company\n address1\n address2\n city\n province\n province_code\n country\n country_code\n zip\n }\n available_payment_methods {\n name\n }\n discount_code\n cart {\n cart_id\n customer_session_id\n shipping_country\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n subtotal\n shipping\n currency\n available_shipping_countries\n }\n totals {\n currency_code\n subtotal\n shipping\n total\n taxes\n tax_rate\n discounts\n }\n }\n }\n}\n";
|
|
695
|
-
declare const UPDATE_CHECKOUT_MUTATION = "\nmutation UpdateCheckout($checkoutId: String!, $status: String, $successUrl: String, $email: String, $cancelUrl: String, $paymentMethod: String, $shippingAddress: AddressArgs, $billingAddress: AddressArgs, $buyerAcceptsPurchaseConditions: Boolean, $buyerAcceptsTermsConditions: Boolean) {\n Checkout {\n UpdateCheckout(checkout_id: $checkoutId, status: $status, success_url: $successUrl, email: $email, cancel_url: $cancelUrl, payment_method: $paymentMethod, shipping_address: $shippingAddress, billing_address: $billingAddress, buyer_accepts_purchase_conditions: $buyerAcceptsPurchaseConditions, buyer_accepts_terms_conditions: $buyerAcceptsTermsConditions) {\n buyer_accepts_purchase_conditions\n buyer_accepts_terms_conditions\n created_at\n updated_at\n id\n deleted_at\n success_url\n cancel_url\n payment_method\n email\n status\n checkout_url\n origin_payment_id\n billing_address {\n id\n first_name\n last_name\n phone_code\n phone\n company\n address1\n address2\n city\n province\n province_code\n country\n country_code\n zip\n }\n shipping_address {\n id\n first_name\n last_name\n phone_code\n phone\n company\n address1\n address2\n city\n province\n province_code\n country\n country_code\n zip\n }\n available_payment_methods {\n name\n }\n discount_code\n cart {\n cart_id\n customer_session_id\n shipping_country\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n subtotal\n shipping\n currency\n available_shipping_countries\n }\n totals {\n currency_code\n subtotal\n shipping\n total\n taxes\n tax_rate\n discounts\n }\n }\n }\n}\n";
|
|
696
|
-
declare const GET_CHECKOUT_QUERY = "\nquery GetCheckout($checkoutId: String!) {\n Checkout {\n GetCheckout(checkout_id: $checkoutId) {\n buyer_accepts_purchase_conditions\n buyer_accepts_terms_conditions\n created_at\n updated_at\n id\n deleted_at\n success_url\n cancel_url\n payment_method\n email\n status\n checkout_url\n origin_payment_id\n billing_address {\n id\n first_name\n last_name\n phone_code\n phone\n company\n address1\n address2\n city\n province\n province_code\n country\n country_code\n zip\n }\n shipping_address {\n id\n first_name\n last_name\n phone_code\n phone\n company\n address1\n address2\n city\n province\n province_code\n country\n country_code\n zip\n }\n available_payment_methods {\n name\n }\n discount_code\n cart {\n cart_id\n customer_session_id\n shipping_country\n line_items {\n id\n supplier\n image {\n id\n url\n width\n height\n }\n sku\n barcode\n brand\n product_id\n title\n variant_id\n variant_title\n variant {\n option\n value\n }\n quantity\n price {\n amount\n currency_code\n discount\n compare_at\n compare_at_incl_taxes\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n shipping {\n id\n name\n description\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n available_shippings {\n id\n name\n description\n country_code\n price {\n amount\n currency_code\n amount_incl_taxes\n tax_amount\n tax_rate\n }\n }\n }\n subtotal\n shipping\n currency\n available_shipping_countries\n }\n totals {\n currency_code\n subtotal\n shipping\n total\n taxes\n tax_rate\n discounts\n }\n }\n }\n}\n";
|
|
697
|
-
declare const GET_AVAILABLE_PAYMENT_METHODS_QUERY = "\nquery Config {\n Payment {\n GetAvailablePaymentMethods {\n config {\n name\n type\n value\n }\n name\n }\n }\n}\n";
|
|
698
|
-
/** Transport options for a cart/checkout GraphQL call. */
|
|
699
|
-
interface CartQueryOptions {
|
|
700
|
-
endpoint?: string;
|
|
701
|
-
apiKey?: string;
|
|
702
|
-
/** Sponsor commerce key — goes in the Authorization header. */
|
|
703
|
-
commerceKey?: string;
|
|
704
|
-
/** True when the commerce key came from a resolved sponsor (bootstrap).
|
|
705
|
-
* False = we fell back to the host apiKey — writes like CreateCart should
|
|
706
|
-
* NOT proceed with the wrong key (the cart would be orphaned). */
|
|
707
|
-
sponsorResolved?: boolean;
|
|
708
|
-
}
|
|
709
|
-
/**
|
|
710
|
-
* Resolve endpoint + keys for cart GraphQL calls. Awaits Vio.bootstrap() once
|
|
711
|
-
* if it hasn't run yet (the sponsor commerce keys come from bootstrap), then
|
|
712
|
-
* uses the sponsor's commerce apiKey (via the Vio facade on globalThis,
|
|
713
|
-
* avoiding an import cycle); falls back to the host apiKey.
|
|
714
|
-
*/
|
|
715
|
-
declare function getCartGraphQLOptions(sponsorId?: number): Promise<CartQueryOptions>;
|
|
716
|
-
/** Stable per-browser customer session id (backend CreateCart requires one). */
|
|
717
|
-
declare function getCustomerSessionId(): string;
|
|
718
|
-
interface GraphQLEnvelope {
|
|
719
|
-
data?: Record<string, Record<string, unknown>>;
|
|
720
|
-
errors?: Array<{
|
|
721
|
-
message?: string;
|
|
722
|
-
}>;
|
|
723
|
-
}
|
|
724
|
-
/** Execute a GraphQL query/mutation against the configured commerce endpoint.
|
|
725
|
-
* Callers that skip `getCartGraphQLOptions()` (or pass a bare sponsorId) get
|
|
726
|
-
* it resolved here instead of silently sending an unauthenticated request. */
|
|
727
|
-
declare function executeCartGraphQL(query: string, variables: Record<string, unknown>, options?: CartQueryOptions | number | undefined): Promise<GraphQLEnvelope>;
|
|
728
|
-
declare function createCart(customerSessionId: string, currency: string, shippingCountry?: string | null, options?: CartQueryOptions): Promise<any>;
|
|
729
|
-
declare function addItem(cartId: string, lineItems: unknown[], options?: CartQueryOptions): Promise<any>;
|
|
730
|
-
declare function deleteItem(cartId: string, cartItemId: string, options?: CartQueryOptions): Promise<any>;
|
|
731
|
-
declare function updateItem(cartId: string, cartItemId: string, shippingId?: string | null, qty?: number | null, options?: CartQueryOptions): Promise<any>;
|
|
732
|
-
declare function getCart(cartId: string, options?: CartQueryOptions): Promise<any>;
|
|
733
|
-
declare function getLineItemsBySupplier(cartId: string, options?: CartQueryOptions): Promise<any>;
|
|
734
|
-
declare function updateShippingsBySupplier(cartId: string, data: unknown[], options?: CartQueryOptions): Promise<any>;
|
|
735
|
-
declare function createCheckout(cartId: string, options?: CartQueryOptions): Promise<any>;
|
|
736
|
-
declare function updateCheckout(variables: Record<string, unknown>, options?: CartQueryOptions): Promise<any>;
|
|
737
|
-
declare function getCheckout(checkoutId: string, options?: CartQueryOptions): Promise<any>;
|
|
738
|
-
declare function getAvailablePaymentMethods(options?: CartQueryOptions): Promise<any>;
|
|
739
|
-
declare const CREATE_PAYMENT_STRIPE_MUTATION = "\nmutation CreatePaymentStripe($checkoutId: String!, $successUrl: String!, $paymentMethod: String!, $email: String!) {\n Payment {\n CreatePaymentStripe(checkout_id: $checkoutId, success_url: $successUrl, payment_method: $paymentMethod, email: $email) {\n order_id\n checkout_url\n }\n }\n}\n";
|
|
740
|
-
declare function createPaymentStripe(variables: Record<string, unknown>, options?: CartQueryOptions): Promise<any>;
|
|
741
|
-
|
|
742
821
|
/**
|
|
743
822
|
* Kustom (former Klarna Checkout) — embedded KCO v3 checkout.
|
|
744
823
|
*
|
|
@@ -747,26 +826,64 @@ declare function createPaymentStripe(variables: Record<string, unknown>, options
|
|
|
747
826
|
*
|
|
748
827
|
* 1. Vio Commerce creates the order (`Payment { CreatePaymentKustom }`,
|
|
749
828
|
* authed with the sponsor's commerce API key; the seller's own
|
|
750
|
-
* kco_*_api_* key lives server-side, per seller, never here).
|
|
751
|
-
*
|
|
752
|
-
*
|
|
753
|
-
*
|
|
754
|
-
*
|
|
755
|
-
*
|
|
756
|
-
*
|
|
757
|
-
*
|
|
829
|
+
* kco_*_api_* key lives server-side, per seller, never here). One order
|
|
830
|
+
* per checkout: asking again while it is open UPDATES it.
|
|
831
|
+
* 2. The response's `html_snippet` is injected into a LIGHT-DOM container
|
|
832
|
+
* — it renders Kustom's iframe, which collects address, shipping AND
|
|
833
|
+
* payment by itself (the widget does everything; no Vio address form).
|
|
834
|
+
* 3. While it is open, the widget talks through `window._klarnaCheckout`:
|
|
835
|
+
* we suspend it around a cart change (`Payment { SyncPaymentKustom }`),
|
|
836
|
+
* and listen to its totals so our summary never disagrees with it.
|
|
837
|
+
* 4. On completion Kustom redirects to the confirmation URL
|
|
838
|
+
* (`?order_id=…&payment_processor=KUSTOM&checkout_id=…`), where the SDK
|
|
839
|
+
* re-reads the order (`Payment { GetKustomOrder }`) — the backend
|
|
840
|
+
* completes it right there — and renders Kustom's own receipt.
|
|
758
841
|
*
|
|
759
|
-
* The Commerce order
|
|
760
|
-
* (
|
|
842
|
+
* The Commerce order is created server-side, from what Kustom says it
|
|
843
|
+
* charged (Order Management), whether the shopper comes back or not (the
|
|
844
|
+
* push) — the browser never confirms money.
|
|
761
845
|
*/
|
|
762
846
|
|
|
763
|
-
/**
|
|
847
|
+
/** A Kustom order as shopcart normalizes it (never Kustom's raw order). */
|
|
764
848
|
interface KustomOrder {
|
|
765
849
|
order_id: string;
|
|
850
|
+
/** `checkout_incomplete` | `checkout_complete`, lower-cased by the backend. */
|
|
766
851
|
status: string;
|
|
767
852
|
html_snippet: string;
|
|
768
853
|
purchase_country?: string;
|
|
769
854
|
purchase_currency?: string;
|
|
855
|
+
checkout_id?: string;
|
|
856
|
+
environment?: string;
|
|
857
|
+
/** Goods + the shipping shown or charged, decimal. */
|
|
858
|
+
total_price?: number;
|
|
859
|
+
shipping_name?: string;
|
|
860
|
+
shipping_price?: number;
|
|
861
|
+
/** Whether the Vio Commerce order exists (after completion). */
|
|
862
|
+
order_created?: boolean;
|
|
863
|
+
/** Kustom's short shopper-facing reference (after completion). */
|
|
864
|
+
reference?: string;
|
|
865
|
+
}
|
|
866
|
+
interface KustomShippingChange {
|
|
867
|
+
id?: string;
|
|
868
|
+
name?: string;
|
|
869
|
+
description?: string;
|
|
870
|
+
/** Minor units, as the widget reports them. */
|
|
871
|
+
price?: number;
|
|
872
|
+
tax_amount?: number;
|
|
873
|
+
tax_rate?: number;
|
|
874
|
+
}
|
|
875
|
+
interface KustomListenerHandlers {
|
|
876
|
+
/** The iframe rendered. */
|
|
877
|
+
onLoad?: (data: any) => void;
|
|
878
|
+
/** The order total the widget shows, in MINOR units. */
|
|
879
|
+
onOrderTotalChange?: (orderTotalMinor: number) => void;
|
|
880
|
+
/** The shopper picked a rate inside the widget. */
|
|
881
|
+
onShippingOptionChange?: (option: KustomShippingChange) => void;
|
|
882
|
+
/** The shopper could not pay (declined credit…): show another way. */
|
|
883
|
+
onCannotComplete?: () => void;
|
|
884
|
+
onNetworkError?: () => void;
|
|
885
|
+
/** The shopper is about to leave for the confirmation page. */
|
|
886
|
+
onRedirectInitiated?: () => void;
|
|
770
887
|
}
|
|
771
888
|
|
|
772
889
|
/**
|
|
@@ -872,6 +989,179 @@ interface WalleyOrder {
|
|
|
872
989
|
total_price?: number;
|
|
873
990
|
}
|
|
874
991
|
|
|
992
|
+
/**
|
|
993
|
+
* Nexi Checkout (formerly Nets Easy) — embedded checkout via Vio Commerce.
|
|
994
|
+
*
|
|
995
|
+
* Fourth embedded provider, same category as Kustom/Qliro/Walley: the widget
|
|
996
|
+
* collects email, phone, addresses AND payment. Two things set it apart and
|
|
997
|
+
* shape this module:
|
|
998
|
+
*
|
|
999
|
+
* 1. There is no html_snippet. `Payment { CreatePaymentNexi }` creates the
|
|
1000
|
+
* payment server-side (the seller's SECRET key never leaves shopcart)
|
|
1001
|
+
* and returns the paymentId plus the PUBLIC checkout key; the browser
|
|
1002
|
+
* loads Nexi's `checkout.js` and mounts `new Dibs.Checkout({…})` in a
|
|
1003
|
+
* LIGHT-DOM container — Nexi refuses a container inside a shadow root
|
|
1004
|
+
* or another iframe.
|
|
1005
|
+
* 2. Nexi has no shipping picker. The payment is created with
|
|
1006
|
+
* `merchantHandlesShippingCost`, so Nexi holds its pay button until we
|
|
1007
|
+
* price the address the shopper typed: on `address-changed` the widget
|
|
1008
|
+
* is frozen, `Payment { UpdateNexiShipping }` re-prices for that country
|
|
1009
|
+
* and pushes the SHIPPING line, and the widget is thawed.
|
|
1010
|
+
*
|
|
1011
|
+
* Completion arrives as the `payment-completed` event — Nexi neither
|
|
1012
|
+
* redirects nor renders a receipt of its own, so the component shows Vio's
|
|
1013
|
+
* confirmation. Some methods inside Nexi (Vipps, Swish, MobilePay) leave the
|
|
1014
|
+
* page and come back to the SAME url with `?paymentId=…` appended; the
|
|
1015
|
+
* pending session is remembered in sessionStorage so the widget can be
|
|
1016
|
+
* re-mounted on that paymentId and finish.
|
|
1017
|
+
*
|
|
1018
|
+
* The Commerce order itself is created server-side by Nexi's webhook
|
|
1019
|
+
* (shopcart /checkout/payment/nexi/ok) — the browser never confirms money.
|
|
1020
|
+
*/
|
|
1021
|
+
|
|
1022
|
+
/** Normalized Nexi payment (shopcart maps the Payment API). */
|
|
1023
|
+
interface NexiOrder {
|
|
1024
|
+
/** Nexi paymentId (32 hex). */
|
|
1025
|
+
order_id: string;
|
|
1026
|
+
/** Created | Reserved | Charged | Cancelled | Terminated | Unknown. */
|
|
1027
|
+
status: string;
|
|
1028
|
+
/** Public checkout key for Dibs.Checkout. */
|
|
1029
|
+
checkout_key: string;
|
|
1030
|
+
/** checkout.js of the seller's environment (test or live). */
|
|
1031
|
+
checkout_js_url: string;
|
|
1032
|
+
purchase_country?: string;
|
|
1033
|
+
purchase_currency?: string;
|
|
1034
|
+
total_price?: number;
|
|
1035
|
+
/**
|
|
1036
|
+
* Shipping to show next to the widget: the purchase country's rates while
|
|
1037
|
+
* no address is known (`reason: AWAITING_ADDRESS`, nothing charged), or what
|
|
1038
|
+
* the payment carries once one was priced (a resumed widget does not
|
|
1039
|
+
* announce its address again).
|
|
1040
|
+
*/
|
|
1041
|
+
shipping?: NexiShippingUpdate | null;
|
|
1042
|
+
/** How it was paid ("Visa", "Vipps"…) — once Nexi has the details. */
|
|
1043
|
+
payment_method?: string | null;
|
|
1044
|
+
/** Last four digits of the card. */
|
|
1045
|
+
card_last4?: string | null;
|
|
1046
|
+
/** Where the receipt goes. */
|
|
1047
|
+
email?: string | null;
|
|
1048
|
+
}
|
|
1049
|
+
interface NexiShippingUpdate {
|
|
1050
|
+
ok: boolean;
|
|
1051
|
+
/**
|
|
1052
|
+
* When !ok: NO_SHIPPING — Vio does not ship to that country; or
|
|
1053
|
+
* AWAITING_ADDRESS — nothing charged yet, `options` are the purchase
|
|
1054
|
+
* country's rates and `shipping_id` the suggested one.
|
|
1055
|
+
*/
|
|
1056
|
+
reason?: string;
|
|
1057
|
+
order_id: string;
|
|
1058
|
+
total_price?: number;
|
|
1059
|
+
shipping_name?: string;
|
|
1060
|
+
shipping_price?: number;
|
|
1061
|
+
/** The rate on the payment now. */
|
|
1062
|
+
shipping_id?: string;
|
|
1063
|
+
/**
|
|
1064
|
+
* Every rate the shopper may pick for this address, best first. Nexi has
|
|
1065
|
+
* no shipping picker of its own, so the checkout shows these.
|
|
1066
|
+
*/
|
|
1067
|
+
options?: NexiShippingOption[];
|
|
1068
|
+
/** The address it was priced for (alpha-2 country). */
|
|
1069
|
+
country?: string;
|
|
1070
|
+
postal_code?: string;
|
|
1071
|
+
/** market — the checkout's country, priced at creation; consumer — the shopper's address. */
|
|
1072
|
+
address_source?: 'market' | 'consumer' | null;
|
|
1073
|
+
/** Whether this call changed the amount on the payment. */
|
|
1074
|
+
changed?: boolean | null;
|
|
1075
|
+
/**
|
|
1076
|
+
* Client-side only: set when the amount changed as the shopper pressed pay,
|
|
1077
|
+
* so the payment was stopped and the widget reloaded.
|
|
1078
|
+
*/
|
|
1079
|
+
repriced_at_pay?: boolean;
|
|
1080
|
+
}
|
|
1081
|
+
interface NexiShippingOption {
|
|
1082
|
+
id: string;
|
|
1083
|
+
name: string;
|
|
1084
|
+
/** Incl. VAT, decimal. */
|
|
1085
|
+
price: number;
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
/**
|
|
1089
|
+
* Adyen — payment via Vio Commerce, rendered with Adyen's own Drop-in.
|
|
1090
|
+
*
|
|
1091
|
+
* Adyen is NOT an embedded checkout like Kustom/Qliro/Walley/Nexi: Drop-in
|
|
1092
|
+
* lists payment methods (cards, Vipps, Klarna, Swish…) and charges, and that
|
|
1093
|
+
* is all. It collects no email, address or shipping, so it belongs with the
|
|
1094
|
+
* FORM-FIRST methods (Stripe, Klarna Payments): the shopper fills Vio's form
|
|
1095
|
+
* and picks Vio's shipping first, and only then is there a session. Three
|
|
1096
|
+
* things shape this module:
|
|
1097
|
+
*
|
|
1098
|
+
* 1. A session is an immutable PHOTO of the purchase. `Payment {
|
|
1099
|
+
* CreatePaymentAdyen }` creates it server-side (the seller's API key
|
|
1100
|
+
* never leaves shopcart) from the saved checkout, with the final amount,
|
|
1101
|
+
* and returns the session plus the PUBLIC client key. It is never
|
|
1102
|
+
* updated: after any change the caller discards it and creates another.
|
|
1103
|
+
* At "Pay", `ConfirmAdyenPayment` only VERIFIES (lesson 2026-09-17: the
|
|
1104
|
+
* amount does not change while the PSP charges).
|
|
1105
|
+
* 2. Adyen Web is loaded from Adyen's CDN, version-pinned and with
|
|
1106
|
+
* Subresource Integrity — never bundled: it weighs more than this whole
|
|
1107
|
+
* SDK, and publisher pages must only pay for it when Adyen is used.
|
|
1108
|
+
* Drop-in is real DOM styled by a real stylesheet (not an iframe), so it
|
|
1109
|
+
* mounts in the LIGHT DOM and its stylesheet goes in `document.head`.
|
|
1110
|
+
* 3. Vipps, Klarna, Trustly and redirect-3DS leave the page and come back
|
|
1111
|
+
* to `return_url` with `redirectResult` appended. The return is
|
|
1112
|
+
* finalised on the SERVER (`GetAdyenPayment(redirect_result)`), and the
|
|
1113
|
+
* return URL names the checkout, so nothing depends on this tab's
|
|
1114
|
+
* storage — a shopper sent from an in-app browser to Safari still lands
|
|
1115
|
+
* on a confirmation. Nothing is resumed from storage on a plain open,
|
|
1116
|
+
* which is how Nexi once opened one cart's payment on another (0.12.2).
|
|
1117
|
+
*
|
|
1118
|
+
* The page's origin must be in the "Allowed origins" of the credential whose
|
|
1119
|
+
* client key is used, or Adyen refuses to render — see `AdyenOriginError`.
|
|
1120
|
+
*
|
|
1121
|
+
* The Commerce order itself is created server-side by Adyen's webhook —
|
|
1122
|
+
* the browser never confirms money.
|
|
1123
|
+
*/
|
|
1124
|
+
|
|
1125
|
+
/** What `CreatePaymentAdyen` answers: everything Drop-in is created with. */
|
|
1126
|
+
interface AdyenSession {
|
|
1127
|
+
order_id: string;
|
|
1128
|
+
session_id: string;
|
|
1129
|
+
session_data: string;
|
|
1130
|
+
client_key: string;
|
|
1131
|
+
environment: 'test' | 'live' | string;
|
|
1132
|
+
country_code: string;
|
|
1133
|
+
/** As ADYEN names it: Norwegian is `no-NO` (`nb-NO` renders in English). */
|
|
1134
|
+
shopper_locale: string;
|
|
1135
|
+
purchase_currency: string;
|
|
1136
|
+
/** Minor units — Drop-in's Pay button. */
|
|
1137
|
+
amount: number;
|
|
1138
|
+
/** Major units, shipping included. */
|
|
1139
|
+
total_price: number;
|
|
1140
|
+
shipping_name?: string | null;
|
|
1141
|
+
shipping_price?: number | null;
|
|
1142
|
+
expires_at?: string | null;
|
|
1143
|
+
}
|
|
1144
|
+
type AdyenOutcome = 'authorised' | 'pending' | 'refused' | 'cancelled' | 'error' | 'unknown';
|
|
1145
|
+
/** Outcome of the session a checkout owns, as Adyen reported it. */
|
|
1146
|
+
interface AdyenPayment {
|
|
1147
|
+
order_id: string;
|
|
1148
|
+
status: AdyenOutcome | string;
|
|
1149
|
+
result_code?: string | null;
|
|
1150
|
+
psp_reference?: string | null;
|
|
1151
|
+
payment_method?: string | null;
|
|
1152
|
+
purchase_country?: string | null;
|
|
1153
|
+
purchase_currency?: string | null;
|
|
1154
|
+
total_price?: number | null;
|
|
1155
|
+
shipping_name?: string | null;
|
|
1156
|
+
shipping_price?: number | null;
|
|
1157
|
+
email?: string | null;
|
|
1158
|
+
order_created: boolean;
|
|
1159
|
+
}
|
|
1160
|
+
interface AdyenResult {
|
|
1161
|
+
resultCode?: string;
|
|
1162
|
+
sessionResult?: string;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
875
1165
|
/**
|
|
876
1166
|
* Checkout types — multi-sponsor compatible.
|
|
877
1167
|
*
|
|
@@ -879,7 +1169,7 @@ interface WalleyOrder {
|
|
|
879
1169
|
* merchant, same as iOS multi-sponsor model). Multiple sponsors → multiple
|
|
880
1170
|
* sequential checkouts.
|
|
881
1171
|
*/
|
|
882
|
-
type PaymentMethod = 'apple-pay' | 'klarna' | 'vipps' | 'card' | 'stripe' | 'kustom' | 'qliro' | 'walley';
|
|
1172
|
+
type PaymentMethod = 'apple-pay' | 'klarna' | 'vipps' | 'card' | 'stripe' | 'kustom' | 'qliro' | 'walley' | 'nexi' | 'adyen';
|
|
883
1173
|
interface CheckoutAddress {
|
|
884
1174
|
firstName: string;
|
|
885
1175
|
lastName: string;
|
|
@@ -910,6 +1200,12 @@ interface CheckoutState {
|
|
|
910
1200
|
sessionId?: string;
|
|
911
1201
|
/** Klarna Payments client token (native GraphQL flow). */
|
|
912
1202
|
clientToken?: string;
|
|
1203
|
+
/**
|
|
1204
|
+
* Which `open()` this state belongs to — a new number every time a checkout
|
|
1205
|
+
* is opened, kept by every later update. An embedded widget belongs to the
|
|
1206
|
+
* session it was mounted in: a new session means a new order.
|
|
1207
|
+
*/
|
|
1208
|
+
session?: number;
|
|
913
1209
|
}
|
|
914
1210
|
|
|
915
1211
|
/**
|
|
@@ -975,18 +1271,39 @@ interface KlarnaPaymentsHandle {
|
|
|
975
1271
|
declare class CheckoutManager extends EventTarget {
|
|
976
1272
|
private readonly cartManager;
|
|
977
1273
|
private state;
|
|
1274
|
+
/** Counts `open()` calls — see CheckoutState.session. */
|
|
1275
|
+
private sessionSeq;
|
|
978
1276
|
private applePayAvailableCache;
|
|
979
1277
|
/** Gateway hints learned from CreatePaymentApplePay (per session). The
|
|
980
1278
|
* backend's gateway_merchant_id may be a publishable key (pk_…) or a Stripe
|
|
981
1279
|
* Connect account (acct_…) — stored defensively by prefix. */
|
|
982
1280
|
private applePayPublishableKey;
|
|
983
1281
|
private applePayConnectedAccount;
|
|
1282
|
+
/** Stripe Connect account of the channel, from its Stripe config. */
|
|
1283
|
+
private stripeConnectAccount;
|
|
984
1284
|
private klarnaAvailableCache;
|
|
985
1285
|
/** Live q1 listeners while a Qliro widget is mounted. */
|
|
986
1286
|
private qliroController;
|
|
1287
|
+
/** Live Dibs.Checkout handle while a Nexi widget is mounted. */
|
|
1288
|
+
private nexiHandle;
|
|
1289
|
+
/** Live Drop-in while an Adyen session is mounted. */
|
|
1290
|
+
private adyenHandle;
|
|
1291
|
+
private stripeHandle;
|
|
1292
|
+
/**
|
|
1293
|
+
* The rate the shopper wants. Before an address it is only remembered (the
|
|
1294
|
+
* suggested one, or their pick); every re-pricing asks for it, and the
|
|
1295
|
+
* backend charges it if it reaches the address.
|
|
1296
|
+
*/
|
|
1297
|
+
private nexiPreferredShipping;
|
|
1298
|
+
/** The rates offered before an address was typed. */
|
|
1299
|
+
private nexiShippingPreview;
|
|
1300
|
+
/** What the last `address-changed` was priced with — a picked rate re-prices the same address. */
|
|
1301
|
+
private nexiShippingContext;
|
|
987
1302
|
private klarnaOrderInFlight;
|
|
988
1303
|
/** Last backend shippings fetched (per-supplier), for UI reuse. */
|
|
989
1304
|
private lastFetchedShippings;
|
|
1305
|
+
/** See `lastShippingsResolved`. */
|
|
1306
|
+
private shippingsResolved;
|
|
990
1307
|
/** Per-sponsor payment methods cache + in-flight dedupe. */
|
|
991
1308
|
private paymentMethodsCache;
|
|
992
1309
|
private paymentMethodsPromises;
|
|
@@ -998,6 +1315,12 @@ declare class CheckoutManager extends EventTarget {
|
|
|
998
1315
|
/** Update the backend checkout (terms are re-asserted unless overridden). */
|
|
999
1316
|
updateCheckout(variables: Record<string, unknown>, sponsorId?: number): Promise<any>;
|
|
1000
1317
|
getCheckout(checkoutId: string, sponsorId?: number): Promise<any>;
|
|
1318
|
+
/**
|
|
1319
|
+
* The Vio order number (#4497) a checkout became, or null: not born yet,
|
|
1320
|
+
* or an API that does not say it. Never throws — it is a line on a
|
|
1321
|
+
* receipt, and a receipt does not fail for it.
|
|
1322
|
+
*/
|
|
1323
|
+
getOrderNumber(checkoutId: string, sponsorId?: number): Promise<number | null>;
|
|
1001
1324
|
/**
|
|
1002
1325
|
* Payment methods enabled for the sponsor (backend-configured). Memoised per
|
|
1003
1326
|
* sponsor with in-flight dedupe — several UI components ask on every open.
|
|
@@ -1014,6 +1337,13 @@ declare class CheckoutManager extends EventTarget {
|
|
|
1014
1337
|
* this at all.
|
|
1015
1338
|
*/
|
|
1016
1339
|
fetchAvailableShippings(sponsorId?: number): Promise<KlarnaShippingOption[]>;
|
|
1340
|
+
/**
|
|
1341
|
+
* Whether the last `fetchAvailableShippings` got an answer from the backend,
|
|
1342
|
+
* possibly an empty one, rather than failing or finding no cart. The two
|
|
1343
|
+
* return the same empty list, and only an answer means the cart has
|
|
1344
|
+
* nothing it can ship with.
|
|
1345
|
+
*/
|
|
1346
|
+
get lastShippingsResolved(): boolean;
|
|
1017
1347
|
/** Set the chosen shipping per supplier on the backend cart. */
|
|
1018
1348
|
updateShippingsBySupplier(data: Array<{
|
|
1019
1349
|
shipping_id: string;
|
|
@@ -1034,10 +1364,29 @@ declare class CheckoutManager extends EventTarget {
|
|
|
1034
1364
|
*/
|
|
1035
1365
|
startStripePayment(sponsorId?: number, formData?: unknown): Promise<any>;
|
|
1036
1366
|
/**
|
|
1037
|
-
* Vipps
|
|
1038
|
-
*
|
|
1367
|
+
* Vipps: create the payment via Vio Commerce and redirect to Vipps'
|
|
1368
|
+
* landing page (on a phone it opens the app; on a desktop it offers to
|
|
1369
|
+
* send the payment to the phone).
|
|
1370
|
+
*
|
|
1371
|
+
* `express: true` asks for Vipps Express — address and delivery chosen
|
|
1372
|
+
* inside the app, the email handed back with the payment — which is what
|
|
1373
|
+
* the Vipps buttons on the product and the cart ask for. When the cart
|
|
1374
|
+
* cannot have it (several suppliers, digital goods, no rate for the
|
|
1375
|
+
* country) the backend creates NO payment and answers `express: false`
|
|
1376
|
+
* with the reason; this resolves with that answer, without redirecting,
|
|
1377
|
+
* so the caller can open the ordinary checkout instead. Without the flag
|
|
1378
|
+
* the backend decides: Express while the cart has no delivery yet, a
|
|
1379
|
+
* plain payment once the shopper chose one in our form.
|
|
1380
|
+
*/
|
|
1381
|
+
startVippsPayment(sponsorId?: number, formData?: unknown, options?: {
|
|
1382
|
+
express?: boolean;
|
|
1383
|
+
}): Promise<any>;
|
|
1384
|
+
/**
|
|
1385
|
+
* The Vipps Express button: the shopper taps it and the app opens with
|
|
1386
|
+
* address and delivery already there. Resolves with `{ express: false,
|
|
1387
|
+
* reason }` — and nothing redirected — when this cart cannot have it.
|
|
1039
1388
|
*/
|
|
1040
|
-
|
|
1389
|
+
startVippsExpress(sponsorId?: number): Promise<any>;
|
|
1041
1390
|
/** Vipps' own payment state for the checkout — see getVippsStatus in
|
|
1042
1391
|
* cart-queries.ts for why this exists instead of trusting GetCheckout. */
|
|
1043
1392
|
getVippsStatus(checkoutId: string, sponsorId?: number): Promise<{
|
|
@@ -1048,7 +1397,17 @@ declare class CheckoutManager extends EventTarget {
|
|
|
1048
1397
|
* and render its html_snippet into `container`. The widget collects
|
|
1049
1398
|
* address, shipping and payment by itself; the SDK renders nothing else.
|
|
1050
1399
|
*/
|
|
1051
|
-
mountKustomCheckout(container: HTMLElement, sponsorId?: number): Promise<KustomOrder>;
|
|
1400
|
+
mountKustomCheckout(container: HTMLElement, sponsorId?: number, handlers?: KustomListenerHandlers): Promise<KustomOrder>;
|
|
1401
|
+
private kustomController;
|
|
1402
|
+
/** Disarm the widget's listeners with the widget they belong to. */
|
|
1403
|
+
destroyKustomListeners(): void;
|
|
1404
|
+
/**
|
|
1405
|
+
* The cart changed under an open Kustom widget: lock it, push the cart
|
|
1406
|
+
* into the SAME order, and let the widget refresh itself. Kustom's own
|
|
1407
|
+
* rule — never a new order for a cart change. The widget auto-resumes
|
|
1408
|
+
* after 10 s if the sync never comes back.
|
|
1409
|
+
*/
|
|
1410
|
+
syncKustomOrder(sponsorId?: number): Promise<KustomOrder | null>;
|
|
1052
1411
|
/** Re-read a Kustom order — used on the confirmation return trip. */
|
|
1053
1412
|
getKustomOrder(orderId: string, sponsorId?: number): Promise<KustomOrder | null>;
|
|
1054
1413
|
/** Render a Kustom html_snippet (e.g. the confirmation receipt) into a container. */
|
|
@@ -1084,8 +1443,123 @@ declare class CheckoutManager extends EventTarget {
|
|
|
1084
1443
|
mountWalleyCheckout(container: HTMLElement, sponsorId?: number, onPurchaseCompleted?: (order: WalleyOrder) => void): Promise<WalleyOrder>;
|
|
1085
1444
|
/** Re-read the Walley session owned by a checkout — the confirmation trip. */
|
|
1086
1445
|
getWalleyOrder(checkoutId: string, sponsorId?: number): Promise<WalleyOrder | null>;
|
|
1446
|
+
/**
|
|
1447
|
+
* Mount the Nexi embedded checkout — Nexi's own JS SDK, not a snippet.
|
|
1448
|
+
*
|
|
1449
|
+
* `onCompleted` fires on Nexi's `payment-completed` (no redirect: Nexi
|
|
1450
|
+
* renders no receipt, the component shows Vio's confirmation). Shipping is
|
|
1451
|
+
* Vio's: Nexi holds its pay button until `address-changed` has been
|
|
1452
|
+
* re-priced through `UpdateNexiShipping` — the widget is frozen meanwhile
|
|
1453
|
+
* and `onShipping` reports the outcome (NO_SHIPPING keeps it held).
|
|
1454
|
+
*
|
|
1455
|
+
* A session interrupted by a third-party redirect inside Nexi (Vipps,
|
|
1456
|
+
* Swish, MobilePay) is remembered in sessionStorage and resumed on the
|
|
1457
|
+
* same paymentId instead of creating a new payment — only when `resume`
|
|
1458
|
+
* names it. Every other opening creates a payment for the cart as it is.
|
|
1459
|
+
*/
|
|
1460
|
+
mountNexiCheckout(container: HTMLElement, sponsorId?: number, handlers?: {
|
|
1461
|
+
onCompleted?: (order: NexiOrder) => void;
|
|
1462
|
+
onShipping?: (result: NexiShippingUpdate | null, error?: unknown) => void;
|
|
1463
|
+
},
|
|
1464
|
+
/**
|
|
1465
|
+
* Set ONLY when the page came back from a redirect inside Nexi
|
|
1466
|
+
* (Vipps/Swish/MobilePay) with `?paymentId=`: resume that payment.
|
|
1467
|
+
*/
|
|
1468
|
+
resume?: {
|
|
1469
|
+
paymentId: string;
|
|
1470
|
+
}): Promise<NexiOrder>;
|
|
1471
|
+
/**
|
|
1472
|
+
* The shopper picked another rate from the `options` Nexi's last
|
|
1473
|
+
* re-pricing returned: charge that one instead. Nexi has no shipping picker,
|
|
1474
|
+
* so the checkout shows the rates and calls this. A no-op until an address
|
|
1475
|
+
* has been typed in the widget.
|
|
1476
|
+
*/
|
|
1477
|
+
pickNexiShipping(shippingId: string): Promise<void>;
|
|
1478
|
+
/**
|
|
1479
|
+
* `pay-initialized` → confirm the shipping for the address Nexi will ship
|
|
1480
|
+
* to → `payment-order-finalized`.
|
|
1481
|
+
*
|
|
1482
|
+
* The payment already carries a shipping (set at creation, re-priced on
|
|
1483
|
+
* every address and pick), so normally nothing changes and Nexi charges.
|
|
1484
|
+
* When the shopper's address was never announced — Nexi fills it in for a
|
|
1485
|
+
* shopper it recognises — the backend reads it from the payment. If that
|
|
1486
|
+
* changes the amount, the payment is STOPPED and the widget reloaded: an
|
|
1487
|
+
* amount that changes while Nexi charges is what failed on 2026-09-16/17
|
|
1488
|
+
* (payments 085277846ae44f7498ae94e112435d63, f6116e6d68294a88927d35b05d907f10).
|
|
1489
|
+
*/
|
|
1490
|
+
private finalizeNexiPayment;
|
|
1491
|
+
/** address-changed → freeze → UpdateNexiShipping → thaw. */
|
|
1492
|
+
private repriceNexiShipping;
|
|
1493
|
+
/** Release the Dibs.Checkout listeners with the widget they belong to. */
|
|
1494
|
+
destroyNexi(): void;
|
|
1495
|
+
/** Re-read the Nexi payment owned by a checkout. */
|
|
1496
|
+
getNexiOrder(checkoutId: string, sponsorId?: number): Promise<NexiOrder | null>;
|
|
1497
|
+
/**
|
|
1498
|
+
* Adyen: FORM-FIRST. Saves the shopper's form and shipping pick on the
|
|
1499
|
+
* checkout (Adyen collects neither), creates a session with that final
|
|
1500
|
+
* amount and mounts Adyen's Drop-in on it. A session is never updated —
|
|
1501
|
+
* after ANY change the caller destroys this mount and calls again.
|
|
1502
|
+
*
|
|
1503
|
+
* At "Pay" the backend only confirms that the session still pays for the
|
|
1504
|
+
* checkout; when it does not, Adyen is stopped and `onReplaced` tells the
|
|
1505
|
+
* caller to remount. Completion is asked of Adyen through the backend
|
|
1506
|
+
* (`GetAdyenPayment`) — the browser's own result is never the answer.
|
|
1507
|
+
*/
|
|
1508
|
+
mountAdyenCheckout(container: HTMLElement, sponsorId: number | undefined, formData: unknown, callbacks: {
|
|
1509
|
+
onCompleted: (payment: AdyenPayment | null, session: AdyenSession) => void;
|
|
1510
|
+
onFailed: (result: AdyenResult, session: AdyenSession) => void;
|
|
1511
|
+
/** The session no longer pays for the checkout (reason from the backend). */
|
|
1512
|
+
onReplaced: (reason: string) => void;
|
|
1513
|
+
onError?: (error: unknown) => void;
|
|
1514
|
+
}): Promise<AdyenSession>;
|
|
1515
|
+
/** Unmount Drop-in. Safe to call when nothing is mounted. */
|
|
1516
|
+
destroyAdyen(): void;
|
|
1517
|
+
/**
|
|
1518
|
+
* Outcome of the Adyen session a checkout owns. With `redirectResult` (the
|
|
1519
|
+
* return from Vipps, Klarna, Trustly or a redirect-3DS) the redirect is
|
|
1520
|
+
* finalised on the server.
|
|
1521
|
+
*/
|
|
1522
|
+
getAdyenPayment(checkoutId: string, proof?: {
|
|
1523
|
+
sessionResult?: string;
|
|
1524
|
+
redirectResult?: string;
|
|
1525
|
+
}, sponsorId?: number): Promise<AdyenPayment | null>;
|
|
1087
1526
|
setAddress(address: CheckoutAddress): void;
|
|
1088
1527
|
selectPaymentMethod(method: PaymentMethod): void;
|
|
1528
|
+
/**
|
|
1529
|
+
* Which Stripe flow this channel offers: `native` pays on our own page,
|
|
1530
|
+
* `link` sends the shopper to a page hosted by Stripe. The channel's two
|
|
1531
|
+
* toggles decide it and the answer travels in the method's config
|
|
1532
|
+
* (api-microservice, `stripe-offer.ts`). A channel that predates that
|
|
1533
|
+
* field answers `link`, which is what every client did before.
|
|
1534
|
+
*/
|
|
1535
|
+
/**
|
|
1536
|
+
* Does this channel's Vipps offer Express — the buy-now buttons that open
|
|
1537
|
+
* the app with address and delivery? Vio Commerce announces it as
|
|
1538
|
+
* `config.express` on the Vipps method, the way Stripe announces `mode`;
|
|
1539
|
+
* the seller switches it on its Vipps row. Unknown means yes: Express is
|
|
1540
|
+
* the default, and the backend refuses it with a reason if it cannot.
|
|
1541
|
+
*/
|
|
1542
|
+
getVippsExpressEnabled(sponsorId?: number): Promise<boolean>;
|
|
1543
|
+
getStripeMode(sponsorId?: number): Promise<'native' | 'link'>;
|
|
1544
|
+
/**
|
|
1545
|
+
* Stripe's Payment Element, mounted on our own page for a checkout that is
|
|
1546
|
+
* ready to be paid. Creating it mints a PaymentIntent, so it happens when
|
|
1547
|
+
* the shopper asks for the payment step, never while they type.
|
|
1548
|
+
*
|
|
1549
|
+
* The order is not born here: `confirm()` only says what Stripe told the
|
|
1550
|
+
* browser. The `payment_intent.succeeded` webhook creates it server-side,
|
|
1551
|
+
* and the caller then reads the checkout to see it land.
|
|
1552
|
+
*/
|
|
1553
|
+
mountStripeCheckout(container: HTMLElement, sponsorId: number | undefined, formData: unknown, callbacks?: {
|
|
1554
|
+
onReady?: () => void;
|
|
1555
|
+
onLoadError?: (message: string) => void;
|
|
1556
|
+
}): Promise<{
|
|
1557
|
+
handle: StripeElementHandle;
|
|
1558
|
+
intent: StripeIntent;
|
|
1559
|
+
checkoutId: string;
|
|
1560
|
+
}>;
|
|
1561
|
+
/** Unmount the Payment Element. Safe when nothing is mounted. */
|
|
1562
|
+
destroyStripe(): void;
|
|
1089
1563
|
/**
|
|
1090
1564
|
* The Stripe publishable key for a sponsor, taken from its own commerce
|
|
1091
1565
|
* channel (`GetAvailablePaymentMethods` → Stripe → config.publishableKey).
|
|
@@ -1217,6 +1691,8 @@ declare class CheckoutManager extends EventTarget {
|
|
|
1217
1691
|
* (Stripe will route to the platform account in that case).
|
|
1218
1692
|
*/
|
|
1219
1693
|
private findStripeConnectAccount;
|
|
1694
|
+
/** The sponsor's connected account, read fresh from its channel config. */
|
|
1695
|
+
private resolveStripeConnectAccount;
|
|
1220
1696
|
private emit;
|
|
1221
1697
|
}
|
|
1222
1698
|
|
|
@@ -1430,7 +1906,7 @@ declare class VioFacade {
|
|
|
1430
1906
|
* listeners are installed) until an explicit `Vio.analytics.start()`.
|
|
1431
1907
|
*/
|
|
1432
1908
|
get analytics(): AnalyticsManager;
|
|
1433
|
-
/** Lazy VioApi for REST endpoints on `api-
|
|
1909
|
+
/** Lazy VioApi for REST endpoints on `api-staging.vio.live`. */
|
|
1434
1910
|
get api(): VioApi;
|
|
1435
1911
|
/**
|
|
1436
1912
|
* Bootstrap — fetches client config and caches it. Dedupes in-flight
|
|
@@ -1456,6 +1932,33 @@ declare const Vio: VioFacade;
|
|
|
1456
1932
|
*
|
|
1457
1933
|
* RELEASE CHECKLIST: bump together with package.json (see CONTRIBUTING).
|
|
1458
1934
|
*/
|
|
1459
|
-
declare const SDK_VERSION = "0.
|
|
1935
|
+
declare const SDK_VERSION = "0.19.0";
|
|
1936
|
+
|
|
1937
|
+
/**
|
|
1938
|
+
* Vipps MobilePay's own button, the way the design guidelines ask for it.
|
|
1939
|
+
*
|
|
1940
|
+
* Vipps publishes a web component (`<vipps-mobilepay-button>`) that draws
|
|
1941
|
+
* the on-brand button and nothing else: it does not start the payment, we
|
|
1942
|
+
* do, on its click. Using it means no logo of ours to keep in step with the
|
|
1943
|
+
* brand rules (ePayment checklist, "Follow the design guidelines",
|
|
1944
|
+
* 2026-10-06). The script is loaded once, on demand, from Vipps' CDN; when
|
|
1945
|
+
* it does not arrive in time — blocked, offline — callers draw the plain
|
|
1946
|
+
* orange button they always had.
|
|
1947
|
+
*/
|
|
1948
|
+
declare const VIPPS_BUTTON_SCRIPT = "https://cdn.vippsmobilepay.com/js/button/button.js";
|
|
1949
|
+
declare const VIPPS_BUTTON_TAG = "vipps-mobilepay-button";
|
|
1950
|
+
/**
|
|
1951
|
+
* Resolves true once Vipps' button element is defined, false when its script
|
|
1952
|
+
* failed to load (or, with `timeoutMs`, did not answer in time). Callers draw
|
|
1953
|
+
* their own button meanwhile and swap it for Vipps' when this resolves — the
|
|
1954
|
+
* CDN takes a few seconds on a slow line, and nobody should wait for it.
|
|
1955
|
+
*/
|
|
1956
|
+
declare function ensureVippsButton(timeoutMs?: number): Promise<boolean>;
|
|
1957
|
+
/** The attributes of the official button as Vio uses it (React hosts spread these). */
|
|
1958
|
+
declare function vippsButtonAttributes(verb?: 'buy' | 'pay' | 'express' | 'continue', opts?: {
|
|
1959
|
+
stretched?: boolean;
|
|
1960
|
+
compact?: boolean;
|
|
1961
|
+
language?: string;
|
|
1962
|
+
}): Record<string, string>;
|
|
1460
1963
|
|
|
1461
|
-
export { ADD_ITEM_MUTATION, type AddManualOptions, type AddProductOptions, type AnalyticsCommerce, type AnalyticsContext, type AnalyticsEventName, type AnalyticsItemInput, AnalyticsManager, type AnalyticsStartOptions, type ApplePayConfig, type ApplePayResult, type BootstrapResponse, CREATE_CART_MUTATION, CREATE_CHECKOUT_MUTATION, CREATE_PAYMENT_STRIPE_MUTATION, CREATE_PAYMENT_VIPPS_MUTATION, type CartChangeDetail, type CartLineItem, CartManager, type CartQueryOptions, type CheckoutAddress, type CheckoutChangeDetail, CheckoutManager, type CheckoutState, CommerceClient, Configuration, type CreatePaymentVippsResponse, type CreatePaymentVippsVariables, DELETE_ITEM_MUTATION, type Environment, GET_AVAILABLE_PAYMENT_METHODS_QUERY, GET_CART_QUERY, GET_CHECKOUT_QUERY, GET_LINE_ITEMS_BY_SUPPLIER_QUERY, GET_VIPPS_STATUS_QUERY, type GetVippsStatusVariables, type ImageSize, type PaymentCompleteDetail, type PaymentMethod, type PaymentSelectDetail, type PlacementComponent, type Product, type ProductCategory, type ProductImage, type ProductOption, type ProductPrice, type ProductVariant, type ResolvedConfig, SDK_VERSION, type Sponsor, type SponsorCartState, type SponsorCommerceBlock, type TrackOptions, UPDATE_CHECKOUT_MUTATION, UPDATE_ITEM_MUTATION, UPDATE_SHIPPINGS_BY_SUPPLIER_MUTATION, Vio, VioApi, VioApiError, type VioConfig, type VippsPaymentState, type VippsStatusResult, 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 };
|
|
1964
|
+
export { ADD_ITEM_MUTATION, type AddManualOptions, type AddProductOptions, type AnalyticsCommerce, type AnalyticsContext, type AnalyticsEventName, type AnalyticsItemInput, AnalyticsManager, type AnalyticsStartOptions, type ApplePayConfig, type ApplePayResult, type BootstrapResponse, CREATE_CART_MUTATION, CREATE_CHECKOUT_MUTATION, CREATE_PAYMENT_STRIPE_MUTATION, CREATE_PAYMENT_VIPPS_MUTATION, type CartChangeDetail, type CartLineItem, CartManager, type CartQueryOptions, type CheckoutAddress, type CheckoutChangeDetail, CheckoutManager, type CheckoutState, CommerceClient, Configuration, type CreatePaymentVippsResponse, type CreatePaymentVippsVariables, DELETE_ITEM_MUTATION, type Environment, GET_AVAILABLE_PAYMENT_METHODS_QUERY, GET_CART_QUERY, GET_CHECKOUT_QUERY, GET_LINE_ITEMS_BY_SUPPLIER_QUERY, GET_VIPPS_STATUS_QUERY, type GetVippsStatusVariables, type ImageSize, type PaymentCompleteDetail, type PaymentMethod, type PaymentSelectDetail, type PlacementComponent, type Product, type ProductCategory, type ProductImage, type ProductOption, type ProductPrice, type ProductVariant, type ResolvedConfig, SDK_VERSION, type Sponsor, type SponsorCartState, type SponsorCommerceBlock, type TrackOptions, UPDATE_CHECKOUT_MUTATION, UPDATE_ITEM_MUTATION, UPDATE_SHIPPINGS_BY_SUPPLIER_MUTATION, VIPPS_BUTTON_SCRIPT, VIPPS_BUTTON_TAG, Vio, VioApi, VioApiError, type VioConfig, type VippsPaymentState, type VippsStatusResult, addItem, checkApplePayAvailability, createCart, createCheckout, createCommerceClient, createPaymentStripe, createPaymentVipps, createVioApi, deleteItem, displayPrice, ensureVippsButton, executeCartGraphQL, formatPrice, getAvailablePaymentMethods, getCart, getCartGraphQLOptions, getCheckout, getCustomerSessionId, getGlobalCurrency, getLineItemsBySupplier, getVippsStatus, primaryImageUrl, showApplePaySheet, updateCheckout, updateItem, updateShippingsBySupplier, vippsButtonAttributes };
|