konnektive-one 1.6.6 → 1.6.7
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/membership.d.ts +123 -0
- package/dist/membership.mjs +1 -0
- package/package.json +17 -3
- package/readme.md +22 -2
- package/dist/membership.js +0 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// Types for dist/membership.mjs (konnektive-one#19). Shapes follow
|
|
2
|
+
// membership-portal-pro docs/api/portal-api.yaml.
|
|
3
|
+
|
|
4
|
+
export type Money = { amount: string; currency: string };
|
|
5
|
+
|
|
6
|
+
export type OrderStatus = 'processing' | 'shipped' | 'delivered' | 'cancelled' | 'refunded' | 'declined';
|
|
7
|
+
export type SubscriptionStatus = 'active' | 'paused' | 'cancelled';
|
|
8
|
+
|
|
9
|
+
export type Address = {
|
|
10
|
+
firstName: string;
|
|
11
|
+
lastName: string;
|
|
12
|
+
address1: string;
|
|
13
|
+
address2?: string;
|
|
14
|
+
city: string;
|
|
15
|
+
state: string;
|
|
16
|
+
postalCode: string;
|
|
17
|
+
country: string;
|
|
18
|
+
phone?: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type OrderSummary = {
|
|
22
|
+
orderId: string;
|
|
23
|
+
/** Shopify `#1234` for imported orders, otherwise the CheckoutChamp order number. */
|
|
24
|
+
displayNumber: string;
|
|
25
|
+
placedAt: string;
|
|
26
|
+
total: Money;
|
|
27
|
+
status: OrderStatus;
|
|
28
|
+
itemCount: number;
|
|
29
|
+
firstItem: { name: string; imageUrl?: string };
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type Shipment = {
|
|
33
|
+
carrier: string;
|
|
34
|
+
trackingNumber: string;
|
|
35
|
+
trackingUrl?: string;
|
|
36
|
+
status: 'in_transit' | 'delivered' | 'exception';
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type OrderDetail = OrderSummary & {
|
|
40
|
+
items: { name: string; qty: number; price: Money; imageUrl?: string }[];
|
|
41
|
+
shipping: Address;
|
|
42
|
+
shipments: Shipment[];
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type Subscription = {
|
|
46
|
+
id: string;
|
|
47
|
+
product: { name: string; imageUrl?: string };
|
|
48
|
+
price: Money;
|
|
49
|
+
status: SubscriptionStatus;
|
|
50
|
+
intervalDays: number;
|
|
51
|
+
nextBillDate?: string;
|
|
52
|
+
pausedUntil?: string;
|
|
53
|
+
/** Set once cancelled: the last day of service. */
|
|
54
|
+
endsOn?: string;
|
|
55
|
+
startedAt: string;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export type Me = { email: string; expiresAt: string };
|
|
59
|
+
export type Purchases = { subscriptions: Subscription[]; orders: OrderSummary[] };
|
|
60
|
+
|
|
61
|
+
/** Server codes from the contract, plus `network_error` and `bad_response` added by the client. */
|
|
62
|
+
export type MembershipErrorCode =
|
|
63
|
+
| 'code_invalid'
|
|
64
|
+
| 'date_out_of_range'
|
|
65
|
+
| 'not_allowed'
|
|
66
|
+
| 'not_found'
|
|
67
|
+
| 'slow_down'
|
|
68
|
+
| 'unauthenticated'
|
|
69
|
+
| 'server_error'
|
|
70
|
+
| 'network_error'
|
|
71
|
+
| 'bad_response';
|
|
72
|
+
|
|
73
|
+
export const ERROR_CODES: readonly MembershipErrorCode[];
|
|
74
|
+
|
|
75
|
+
export class MembershipApiError extends Error {
|
|
76
|
+
constructor(code: MembershipErrorCode, status: number, retryAfter?: number);
|
|
77
|
+
/** What went wrong; map it to the site's own wording. */
|
|
78
|
+
code: MembershipErrorCode;
|
|
79
|
+
/** HTTP status, or 0 when no answer arrived. */
|
|
80
|
+
status: number;
|
|
81
|
+
/** Seconds to wait (with `slow_down`). */
|
|
82
|
+
retryAfter?: number;
|
|
83
|
+
/** True for `network_error` and 5xx; the client has already retried these. */
|
|
84
|
+
readonly retryable: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Set when `retryable`: resends the same request (for a write, with the same
|
|
87
|
+
* Idempotency-Key). Use it for a "Try again" button instead of calling the
|
|
88
|
+
* operation again, which would start a new write.
|
|
89
|
+
*/
|
|
90
|
+
retry?: () => Promise<unknown>;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface MembershipClient {
|
|
94
|
+
requestCode(email: string, turnstileToken: string): Promise<void>;
|
|
95
|
+
verifyCode(email: string, code: string): Promise<Me>;
|
|
96
|
+
logout(): Promise<void>;
|
|
97
|
+
me(): Promise<Me>;
|
|
98
|
+
purchases(): Promise<Purchases>;
|
|
99
|
+
order(orderId: string): Promise<OrderDetail>;
|
|
100
|
+
subscription(id: string): Promise<Subscription>;
|
|
101
|
+
pause(id: string, resumeOn: string): Promise<Subscription>;
|
|
102
|
+
resume(id: string): Promise<Subscription>;
|
|
103
|
+
reschedule(id: string, nextBillDate: string): Promise<Subscription>;
|
|
104
|
+
setFrequency(id: string, intervalDays: number): Promise<Subscription>;
|
|
105
|
+
cancel(id: string, reason: string, offerShown: true): Promise<Subscription>;
|
|
106
|
+
billingAddress(): Promise<Address>;
|
|
107
|
+
saveBillingAddress(address: Address): Promise<Address>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface MembershipClientOptions {
|
|
111
|
+
/** Same-origin API root. Default `/account/api`. */
|
|
112
|
+
baseUrl?: string;
|
|
113
|
+
/** Default: the global `fetch`. */
|
|
114
|
+
fetch?: typeof fetch;
|
|
115
|
+
/** Per attempt, including reading the body. Default 15000. */
|
|
116
|
+
timeoutMs?: number;
|
|
117
|
+
/** Extra attempts after a network error or 5xx. Default 2. */
|
|
118
|
+
retries?: number;
|
|
119
|
+
/** First backoff in ms; doubles each retry. Default 250. */
|
|
120
|
+
retryDelayMs?: number;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function createMembershipClient(options?: MembershipClientOptions): MembershipClient;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={d:(t,r)=>{for(var s in r)e.o(r,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:r[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{O1:()=>r,V4:()=>A,YX:()=>o});const r=Object.freeze(["code_invalid","date_out_of_range","not_allowed","not_found","slow_down","unauthenticated","server_error","network_error","bad_response"]),s=new Set(r.slice(0,7));class o extends Error{constructor(e,t,r){super(`Membership request failed (${e})`),this.name="MembershipApiError",this.code=e,this.status=t,void 0!==r&&(this.retryAfter=r)}get retryable(){return"network_error"===this.code||this.status>=500&&this.status<=599}}const a=e=>"string"==typeof e,i=e=>"number"==typeof e&&Number.isFinite(e),n=(...e)=>t=>e.includes(t),c=e=>t=>void 0===t||e(t),d=e=>t=>Array.isArray(t)&&t.every(e),l=e=>t=>null!==t&&"object"==typeof t&&!Array.isArray(t)&&Object.keys(e).every((r=>e[r](t[r]))),u=l({amount:a,currency:a}),y=l({name:a,imageUrl:c(a)}),h=l({firstName:a,lastName:a,address1:a,address2:c(a),city:a,state:a,postalCode:a,country:a,phone:c(a)}),p={orderId:a,displayNumber:a,placedAt:a,total:u,status:n("processing","shipped","delivered","cancelled","refunded","declined"),itemCount:i,firstItem:y},b=l(p),m=l({...p,items:d(l({name:a,qty:i,price:u,imageUrl:c(a)})),shipping:h,shipments:d(l({carrier:a,trackingNumber:a,trackingUrl:c(a),status:n("in_transit","delivered","exception")}))}),f=l({id:a,product:y,price:u,status:n("active","paused","cancelled"),intervalDays:i,nextBillDate:c(a),pausedUntil:c(a),endsOn:c(a),startedAt:a}),w=l({email:a,expiresAt:a}),v=l({subscriptions:d(f),orders:d(b)}),g=l({ok:n(!0)}),k=l({error:e=>s.has(e),retryAfter:c(i)}),T=e=>void 0===e,O=e=>new Promise((t=>{setTimeout(t,e)}));function A({baseUrl:e="/account/api",fetch:t,timeoutMs:r=15e3,retries:s=2,retryDelayMs:a=250}={}){const i=e.replace(/\/+$/,""),n=t||((...e)=>globalThis.fetch(...e));async function c(e,t,s,a,c,d){const l=new AbortController,u=setTimeout((()=>l.abort()),r);try{let r,u,y;try{r=await n(i+t,{method:e,headers:s,body:a,credentials:"same-origin",cache:"no-store",signal:l.signal}),u=204===r.status?"":await r.text()}catch(e){throw new o("network_error",0)}if(""!==u)try{y=JSON.parse(u)}catch(e){y=void 0}if(!r.ok){if(!k(y))throw new o(r.status>=500?"server_error":"bad_response",r.status);const e=void 0!==y.retryAfter?y.retryAfter:function(e){const t=e.headers&&"function"==typeof e.headers.get?e.headers.get("Retry-After"):null,r=null===t?NaN:Number(t);return Number.isFinite(r)&&r>=0?r:void 0}(r);throw new o(y.error,r.status,e)}if(r.status!==c||!d(y))throw new o("bad_response",r.status);return y}finally{clearTimeout(u)}}async function d(e,t,{body:r,expectStatus:o=200,check:i}){const n={Accept:"application/json"};void 0!==r&&(n["Content-Type"]="application/json"),"GET"!==e&&(n["Idempotency-Key"]=globalThis.crypto.randomUUID());const d=void 0===r?void 0:JSON.stringify(r),l=async()=>{for(let r=0;;r+=1)try{return await c(e,t,n,d,o,i)}catch(e){if(!e.retryable||r>=s)throw e.retryable&&(e.retry=l),e;await O(a*2**r)}};return l()}const l=e=>encodeURIComponent(e),u=(e,t="")=>`/subscriptions/${l(e)}${t}`;return{async requestCode(e,t){await d("POST","/auth/code",{body:{email:e,turnstileToken:t},expectStatus:202,check:g})},verifyCode:(e,t)=>d("POST","/auth/verify",{body:{email:e,code:t},check:w}),async logout(){await d("POST","/auth/logout",{expectStatus:204,check:T})},me:()=>d("GET","/me",{check:w}),purchases:()=>d("GET","/purchases",{check:v}),order:e=>d("GET",`/orders/${l(e)}`,{check:m}),subscription:e=>d("GET",u(e),{check:f}),pause:(e,t)=>d("POST",u(e,"/pause"),{body:{resumeOn:t},check:f}),resume:e=>d("POST",u(e,"/resume"),{check:f}),reschedule:(e,t)=>d("POST",u(e,"/reschedule"),{body:{nextBillDate:t},check:f}),setFrequency:(e,t)=>d("POST",u(e,"/frequency"),{body:{intervalDays:t},check:f}),cancel:(e,t,r)=>d("POST",u(e,"/cancel"),{body:{reason:t,offerShown:r},check:f}),billingAddress:()=>d("GET","/billing-address",{check:h}),saveBillingAddress:e=>d("PUT","/billing-address",{body:e,check:h})}}var _=t.O1,S=t.YX,P=t.V4;export{_ as ERROR_CODES,S as MembershipApiError,P as createMembershipClient};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "konnektive-one",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.7",
|
|
4
4
|
"description": "Konnektive / CheckoutChamp checkout engine — single-bundle (jQuery + sweetalert2). Load dist/engine.js with a data-config attribute pointing at your OPconfig.js.",
|
|
5
5
|
"main": "dist/engine.js",
|
|
6
6
|
"repository": {
|
|
@@ -17,11 +17,15 @@
|
|
|
17
17
|
"watch": "npm run build -- --watch",
|
|
18
18
|
"dev": "concurrently \"npm run serve\" \"npm run watch\"",
|
|
19
19
|
"serve": "http-server ./dist -a 0.0.0.0 -p 3000",
|
|
20
|
-
"release": "npm run
|
|
20
|
+
"release": "npm run ci && npm publish",
|
|
21
21
|
"lint": "eslint ./src",
|
|
22
22
|
"lint:fix": "eslint ./src --fix",
|
|
23
23
|
"test": "jest",
|
|
24
|
-
"build:mid": "NODE_ENV=production webpack --color --progress --mode=production --env mid --env out=dist-mid && node scripts/check-mid-bundle.js dist-mid/engine-mid.js"
|
|
24
|
+
"build:mid": "NODE_ENV=production webpack --color --progress --mode=production --env mid --env out=dist-mid && node scripts/check-mid-bundle.js dist-mid/engine-mid.js",
|
|
25
|
+
"lint:membership": "eslint src/membership.js",
|
|
26
|
+
"check-engine-unchanged": "node scripts/check-engine-unchanged.js",
|
|
27
|
+
"check-membership-bundle": "node scripts/check-membership-bundle.js",
|
|
28
|
+
"ci": "npm run lint:membership && npm test -- --runInBand && npm run build:prod && npm run check-engine-unchanged && npm run check-membership-bundle && npm run build:mid"
|
|
25
29
|
},
|
|
26
30
|
"jest": {
|
|
27
31
|
"testEnvironment": "node",
|
|
@@ -64,8 +68,18 @@
|
|
|
64
68
|
"jest-environment-jsdom": "^30.5.2",
|
|
65
69
|
"jquery-1.12": "npm:jquery@^1.12.4",
|
|
66
70
|
"npm-watch": "^0.11.0",
|
|
71
|
+
"playwright-core": "1.56.1",
|
|
67
72
|
"rimraf": "^3.0.2",
|
|
68
73
|
"webpack": "^5.72.0",
|
|
69
74
|
"webpack-cli": "^4.10.0"
|
|
75
|
+
},
|
|
76
|
+
"exports": {
|
|
77
|
+
".": "./dist/engine.js",
|
|
78
|
+
"./membership": {
|
|
79
|
+
"types": "./dist/membership.d.ts",
|
|
80
|
+
"import": "./dist/membership.mjs"
|
|
81
|
+
},
|
|
82
|
+
"./dist/*": "./dist/*",
|
|
83
|
+
"./package.json": "./package.json"
|
|
70
84
|
}
|
|
71
85
|
}
|
package/readme.md
CHANGED
|
@@ -253,17 +253,37 @@ display. A funnel **with** its own `validateOfferCoupon()` keeps it: its jQuery
|
|
|
253
253
|
|
|
254
254
|
```bash
|
|
255
255
|
npm install
|
|
256
|
-
npm run build # dev build -> dist/engine.js + dist/membership.
|
|
256
|
+
npm run build # dev build -> dist/engine.js + dist/membership.mjs (with source maps)
|
|
257
257
|
npm run build:prod # minified production build
|
|
258
258
|
npm run build:mid # dist-mid/engine-mid.js for MID sites (never published; checked by scripts/check-mid-bundle.js)
|
|
259
259
|
npm run serve # static server on http://localhost:3000
|
|
260
260
|
npm run dev # watch + serve
|
|
261
|
+
npm run ci # everything a release needs (also runs on git push once hooks are installed)
|
|
262
|
+
sh scripts/install-hooks.sh # once per clone: pre-push runs `npm run ci` (SKIP_CI=1 to bypass)
|
|
261
263
|
```
|
|
262
264
|
|
|
265
|
+
## Membership client (`konnektive-one/membership`)
|
|
266
|
+
|
|
267
|
+
Since 1.6.7 the package also ships the membership portal's API client, `dist/membership.mjs` with types in `dist/membership.d.ts` (konnektive-one#19). It is a headless ES module: no jQuery, no DOM, no globals. The portal app bundles it into each site's own build; **never load it from a CDN** (a shared script address would link the sites).
|
|
268
|
+
|
|
269
|
+
```js
|
|
270
|
+
import { createMembershipClient, MembershipApiError } from 'konnektive-one/membership';
|
|
271
|
+
|
|
272
|
+
const api = createMembershipClient(); // same-origin /account/api
|
|
273
|
+
const { subscriptions, orders } = await api.purchases();
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
- Talks only to the site's own `/account/api` (contract: membership-portal-pro `docs/api/portal-api.yaml`). The session is an HttpOnly cookie set by the site's Worker; the client never sees a token.
|
|
277
|
+
- Every response is checked against the contract; anything else is a `MembershipApiError` with `code` `bad_response`.
|
|
278
|
+
- Errors carry `code` (contract enum plus `network_error`, `bad_response`), `status` and, for `slow_down`, `retryAfter` seconds. Messages name no site.
|
|
279
|
+
- Network errors, timeouts (15 s per attempt) and 5xx are retried twice (250 ms, 500 ms). A write keeps one `Idempotency-Key` across its retries; a new write gets a new key. When the automatic retries run out, `error.retry()` resends the same write with the same key: use it for a "Try again" button rather than calling the operation again.
|
|
280
|
+
|
|
263
281
|
## Publishing
|
|
264
282
|
|
|
283
|
+
Live sites load `konnektive-one@1.6` from jsDelivr, so **every 1.6.x publish reaches all of them at once**. A release that only changes the membership client must leave `dist/engine.js` byte for byte as before: `npm run ci` rebuilds it and `scripts/check-engine-unchanged.js` compares it with `scripts/engine-baseline.json` (engine 1.6.6). The engine reports its own version (`engineVersion` there), not the package version. A deliberate engine change updates both fields of the baseline.
|
|
284
|
+
|
|
265
285
|
Update `version` in `package.json` (npm versions are permanent), then:
|
|
266
286
|
|
|
267
287
|
```bash
|
|
268
|
-
npm run release #
|
|
288
|
+
npm run release # npm run ci && npm publish
|
|
269
289
|
```
|
package/dist/membership.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("jQuery"));else if("function"==typeof define&&define.amd)define(["jQuery"],t);else{var a="object"==typeof exports?t(require("jQuery")):t(e.jQuery);for(var r in a)("object"==typeof exports?exports:e)[r]=a[r]}}(this,(e=>(()=>{"use strict";var t={145:t=>{t.exports=e}},a={};function r(e){var s=a[e];if(void 0!==s)return s.exports;var o=a[e]={exports:{}};return t[e](o,o.exports,r),o.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};return(()=>{r.r(s),r.d(s,{detectCarrier:()=>C,konnektive_create_member:()=>_,konnektive_forgot_password:()=>x,konnektive_login_user:()=>y,konnektive_logout_user:()=>A,konnektive_reactivate_membership:()=>w,konnektive_update_order:()=>k,konnektive_update_order_subscription:()=>S,konnektive_user_order_details:()=>v,konnektive_user_orders_lookup:()=>f,konnektive_user_orders_set_images:()=>I,konnektive_validate_user:()=>h});var e=r(145),t=r.n(e),a=function(e){return function(){var t;return(t=window)[e].apply(t,arguments)}},o=a("getConfig"),d=a("debug"),n=a("throwError"),i=a("resetFormState"),c=a("getCookieValue"),l=a("deleteSessionStorage"),m=a("buildQuery"),p=a("getKNKBillingModels"),u=a("setStates"),g=function(){var e;return(e=window).loadUserOrders.apply(e,arguments)},b=function(){return window.ORDER_ICON_PLACEHOLDER};function h(e,a){var r={url:"".concat(o().konnektiveAPIURL,"/order/query?")+"&orderId="+a+"&emailAddress="+e,method:"POST",timeout:0,headers:{"X-SESSION-ID":""}};t().ajax(r).done((function(t){"SUCCESS"==t.result?_(e):(d(t),n("error",t.message))}))}function _(e){var a={url:"".concat(o().konnektiveAPIURL,"/members/reset?")+"&clubId="+o().clubID+"&clubUsername="+e,method:"POST",timeout:0,headers:{"X-SESSION-ID":""}};t().ajax(a).done((function(e){"SUCCESS"==e.result?(i(),n("info",e.message)):(d(e),i(),n("error",e.result))}))}function y(e,a){var r=new Date;r.setTime(r.getTime()+864e5);var s={url:"".concat(o().konnektiveAPIURL,"/members/login?")+m({clubId:o().clubID,clubUsername:e,clubPassword:a}),method:"POST",timeout:0,headers:{"X-SESSION-ID":""}};t().ajax(s).done((function(a){"SUCCESS"===a.result&&a.message&&a.message.memberId?(i(),document.cookie="konnektive_customer_email=".concat(e,";path=/;expires=").concat(r),document.cookie="konnektive_customer_id=".concat(a.message.memberId,";path=/;expires=").concat(r),document.cookie="member_token=".concat(a.message.memberId,";path=/;expires=").concat(r),sessionStorage.setItem("konnektive_customer_id",a.message.memberId),sessionStorage.setItem("konnektive_customer_email",e),sessionStorage.setItem("member_token",a.message.memberId),window.location.href=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:".html";return"".concat(e).concat(t)}("member",o().pageExtension),t()("#logform")[0].reset()):(n("error","string"==typeof a.message?a.message:"Login failed. Please check your email and password."),t()("#sForm #sFormOverlay").remove(),t()('#sForm button[type="submit"]').show())})).fail((function(e,a,r){console.log("Mailer Error: ",a,r),t()("#sForm #sFormOverlay").remove(),t()('#sForm button[type="submit"]').show()}))}function f(){t()(".overlay, .processing").show(),t()("#order_summary tbody").html("");var e="";o().campaignID.length&&(e="&campaignId=",t().each(o().campaignID,(function(t,a){e+=a.id+","})));var a=!1;t()("#subscription_summary").length&&(a=!0);var r={url:"".concat(o().konnektiveAPIURL,"/order/query?")+"&emailAddress="+sessionStorage.getItem("konnektive_customer_email")+"&resultsPerPage=100&orderStatus=SALE"+e+"&startDate="+new Date.parse("today").add(-1).year().toString("MM/dd/yyyy")+"&endDate="+new Date.parse("today").add(1).day().toString("MM/dd/yyyy"),method:"POST",timeout:0,headers:{"X-SESSION-ID":""}};t().ajax(r).done((function(e){if("SUCCESS"==e.result){d(e);var r="",s="";t().each(e.message.data,(function(e,o){var d="onetime",n="One Time Purchase",i="",c="",l="table-light",m=o.dateCreated;t().each(o.items,(function(e,t){if(""!=t.purchaseStatus){var p=new Date(t.nextBillDate).toString("MMM d, yyyy");n="Subscription",d="subscription",t.nextBillDate&&(n+="<br/><small>Next Shipment: ".concat(p,"</small>")),i=t.purchaseStatus,("ACTIVE"==t.purchaseStatus||"TRIAL"==t.purchaseStatus)&&(l="table-success"),"INACTIVE"==t.purchaseStatus&&(l="table-danger"),"CANCELLED"==t.purchaseStatus&&(l="table-secondary")}else i=o.orderStatus,"COMPLETE"==o.orderStatus&&(l="table-success"),"CANCELLED"==o.orderStatus&&(l="table-secondary");var u='<a href="#" onclick="konnektive_user_order_details(\''.concat(o.orderId,"', '").concat(btoa(o.emailAddress),"', '").concat(d,'\'); return false;" class="btn btn-secondary w-100"><span class="desktop">Details</span><span class="mobile"><i class="bi bi-info-circle-fill"></i></span></a>');return t.variantName&&(t.name+="<br/><small>"+t.variantName+"</small>"),c='<div class="mobileOnly">$'.concat(o.totalAmount,"<br/>").concat(i,"<br/>").concat(n,"</div>"),a&&"subscription"==d?(s+='<tr id="order-entry-'.concat(o.orderId,"-").concat(o.actualOrderId,'" data-pid="').concat(o.actualOrderId,'" data-shippable="" class="').concat(l," ty-order-entry order-entry-").concat(o.orderId,"-").concat(o.actualOrderId,'">'),s+="<td>".concat(o.orderId,"</td>"),s+='<td><div style="display:flex;gap:10px;"><img src="'.concat(b(),'" class="product-image oms-entry" data-pid="').concat(e,'" id="product-').concat(e,'" /><div>').concat(t.name).concat(c,"</div></div></td>"),s+='<td class="hideOnMobile">'.concat(m,"</td>"),s+='<td class="hideOnMobile">'.concat(n,"</td>"),s+='<td class="hideOnMobile">$'.concat(t.price,"</td>"),s+='<td class="hideOnMobile">'.concat(i,"</td>"),s+='<td class="align-top orderDetails" align="center">'.concat(u," </td>"),void(s+="</tr>")):(r+='<tr id="order-entry-'.concat(o.orderId,"-").concat(o.actualOrderId,'" data-pid="').concat(o.actualOrderId,'" data-shippable="" class="').concat(l," ty-order-entry order-entry-").concat(o.orderId,"-").concat(o.actualOrderId,'">'),r+="<td>".concat(o.orderId,"</td>"),r+='<td><div style="display:flex;gap:10px;"><img src="'.concat(b(),'" class="product-image oms-entry" data-pid="').concat(e,'" id="product-').concat(e,'" /><div>').concat(t.name).concat(c,"</div></div></td>"),r+='<td class="hideOnMobile">'.concat(m,"</td>"),r+='<td class="hideOnMobile">'.concat(n,"</td>"),r+='<td class="hideOnMobile">$'.concat(t.price,"</td>"),r+='<td class="hideOnMobile">'.concat(i,"</td>"),r+='<td class="align-top orderDetails" align="center">'.concat(u," </td>"),void(r+="</tr>"))}))})),t()("#order_summary tbody").html(""),t()("#order_summary tbody").append(r),t()("#order_summary tbody tr").each((function(){})),a&&(t()("#subscription_summary tbody").html(""),t()("#subscription_summary tbody").append(s),t()("#subscription_summary tbody tr").each((function(){}))),t().bootstrapSortable({sign:"reversed"}),I(),i()}else d(e),i(),n("error",e.message)}))}function v(e,a,r){t()(".overlay, .processing").show();var s=!1;t()("#subscription_summary").length&&(s=!0);var c={url:"".concat(o().konnektiveAPIURL,"/order/query?orderId=")+e,method:"POST",timeout:0,headers:{"X-SESSION-ID":""}};t().ajax(c).done((function(e){if("SUCCESS"==e.result){d(e),e.message.data[0].address2&&"undefined"!=e.message.data[0].address2||(e.message.data[0].address2=""),e.message.data[0].shipAddress2&&"undefined"!=e.message.data[0].shipAddress2||(e.message.data[0].shipAddress2=""),t()(".updateOrderDetails .btn").show();var a='<table class="table table-bordered"><thead><tr><th scope="col" colspan="2">Delivery Information</th></tr></thead><tbody><tr><td class="tab_cel1 col-md-4 col-lg-3 text-right"><strong>Name:</strong></td><td id="fullname" class="tab_cel2"><input type="text" id="newShippingFName" placeholder="First Name" value="'.concat(e.message.data[0].shipFirstName,'" class="form-control half" required><input type="text" id="newShippingLName" placeholder="Last Name" value="').concat(e.message.data[0].shipLastName,'" class="form-control half" required></td></tr><tr><td class="tab_cel1 col-md-4 col-lg-3 text-right"><strong>Address 1:</strong></td><td id="address" class="tab_cel2"><input type="text" id="newShippingAddress" placeholder="Address" value="').concat(e.message.data[0].shipAddress1,'" class="form-control" required></td></tr><tr><td class="tab_cel1 col-md-4 col-lg-3 text-right"><strong>Address 2:</strong></td><td id="address2" class="tab_cel2"><input type="text" id="newShippingAddress2" placeholder="Address" value="').concat(e.message.data[0].shipAddress2,'" class="form-control" ></td></tr><tr><td class="tab_cel1 col-md-4 col-lg-3 text-right"><strong>City/State:</strong></td><td id="city_state" class="tab_cel2"><input type="text" id="newShippingCity" placeholder="City" value="').concat(e.message.data[0].shipCity,'" class="form-control half" required><select id="newShippingState" class="form-select half"></select></td></tr><tr><td class="tab_cel1 col-md-4 col-lg-3 text-right"><strong>Zip:</strong></td><td id="zip" class="tab_cel2"><input type="text" placeholder="Zip" id="newShippingZip" value="').concat(e.message.data[0].shipPostalCode,'" class="form-control" required></td></tr></tbody></table>'),o='<table class="table table-bordered"><thead><tr><th scope="col" colspan="2">Delivery Information</th></tr></thead><tbody><tr><td class="tab_cel1 col-md-4 col-lg-3 text-right"><strong>Name:</strong></td><td id="fullname" class="tab_cel2">'.concat(e.message.data[0].shipFirstName," ").concat(e.message.data[0].shipLastName,'</td></tr><tr><td class="tab_cel1 col-md-4 col-lg-3 text-right"><strong>Address 1:</strong></td><td id="address" class="tab_cel2">').concat(e.message.data[0].shipAddress1,'</td></tr><tr><td class="tab_cel1 col-md-4 col-lg-3 text-right"><strong>Address 2:</strong></td><td id="address2" class="tab_cel2">').concat(e.message.data[0].shipAddress2,'</td></tr><tr><td class="tab_cel1 col-md-4 col-lg-3 text-right"><strong>City/State:</strong></td><td id="city_state" class="tab_cel2">').concat(e.message.data[0].shipCity,", ").concat(e.message.data[0].shipState,'</td></tr><tr><td class="tab_cel1 col-md-4 col-lg-3 text-right"><strong>Zip:</strong></td><td id="zip" class="tab_cel2">').concat(e.message.data[0].shipPostalCode,"</td></tr></tbody></table>"),c='<table class="table table-bordered"><thead><tr><th scope="col" colspan="2">Billing Information</th></tr></thead><tbody><tr><td class="tab_cel1 col-md-4 col-lg-3 text-right"><strong>Name:</strong></td><td id="fullname" class="tab_cel2"><input type="text" id="newBillingFName" placeholder="First Name" value="'.concat(e.message.data[0].firstName,'" class="form-control half" required><input type="text" id="newBillingLName" placeholder="Last Name" value="').concat(e.message.data[0].lastName,'" class="form-control half" required></td></tr><tr><td class="tab_cel1 col-md-4 col-lg-3 text-right"><strong>Address 1:</strong></td><td id="address" class="tab_cel2"><input type="text" id="newBillingAddress" placeholder="Address" value="').concat(e.message.data[0].address1,'" class="form-control" required></td></tr><tr><td class="tab_cel1 col-md-4 col-lg-3 text-right"><strong>Address 2:</strong></td><td id="address2" class="tab_cel2"><input type="text" id="newBillingAddress2" placeholder="Address" value="').concat(e.message.data[0].address2,'" class="form-control" ></td></tr><tr><td class="tab_cel1 col-md-4 col-lg-3 text-right"><strong>City/State:</strong></td><td id="city_state" class="tab_cel2"><input type="text" id="newBillingCity" placeholder="City" value="').concat(e.message.data[0].city,'" class="form-control half" required><select id="newBillingState" class="form-select half"></select></td></tr><tr><td class="tab_cel1 col-md-4 col-lg-3 text-right"><strong>Zip:</strong></td><td id="zip" class="tab_cel2"><input type="text" placeholder="Zip" id="newBillingZip" value="').concat(e.message.data[0].postalCode,'" class="form-control" required></td></tr></tbody></table>'),l='<table class="table table-bordered"><thead><tr><th scope="col" colspan="2">Billing Information</th></tr></thead><tbody><tr><td class="tab_cel1 col-md-4 col-lg-3 text-right"><strong>Name:</strong></td><td id="fullname" class="tab_cel2">'.concat(e.message.data[0].firstName," ").concat(e.message.data[0].lastName,'</td></tr><tr><td class="tab_cel1 col-md-4 col-lg-3 text-right"><strong>Address 1:</strong></td><td id="address" class="tab_cel2">').concat(e.message.data[0].address1,'</td></tr><tr><td class="tab_cel1 col-md-4 col-lg-3 text-right"><strong>Address 2:</strong></td><td id="address2" class="tab_cel2">').concat(e.message.data[0].address2,'</td></tr><tr><td class="tab_cel1 col-md-4 col-lg-3 text-right"><strong>City/State:</strong></td><td id="city_state" class="tab_cel2">').concat(e.message.data[0].city,", ").concat(e.message.data[0].state,'</td></tr><tr><td class="tab_cel1 col-md-4 col-lg-3 text-right"><strong>Zip:</strong></td><td id="zip" class="tab_cel2">').concat(e.message.data[0].postalCode,"</td></tr></tbody></table>"),m="",g="",b=!1;globalsOrderId=e.message.data[0].clientOrderId,t().each(e.message.data[0].items,(function(a,o){if(0!=a){if(o.variantName&&(o.name+=" — "+o.variantName),s)if("onetime"==r){if(-1!=o.variantName.indexOf("cription"))return}else if(-1==o.variantName.indexOf("cription"))return;(""==o.purchaseStatus||"CANCELLED"==o.purchaseStatus)&&(t()(".updateOrderDetails .btn").hide(),b=!0),m+='<tr><td class="tab_cel1 text-right orderContents freeGift"><i class="bi bi-gift"></i> '.concat(o.name,"</td><td>$").concat(o.price,"</td></tr>");var d='<select id="billingModelUpdate" name="billingModelUpdate" class="form-select" aria-label="Default select example"><option value="" disabled selected> - Change billing cycle - </option>'.concat(p(),"</select>");if(""!=o.purchaseStatus){var n=new Date(o.nextBillDate).toString("MMM d, yyyy"),i=new Date(o.nextBillDate).toString("MM/dd/yyyy"),c="<strong>Subscription</strong>";o.nextBillDate&&(c+="<br/>Next shipment date: ".concat(n))}else c="One Time Purchase";g='<tr><td colspan="2" class="tab_cel1 text-right"> '.concat(c,"</td></tr>"),""!=o.purchaseStatus&&"CANCELLED"!=o.purchaseStatus&&(g+='<tr><td colspan="2" class="tab_cel1 text-right">',("ACTIVE"==o.purchaseStatus||"TRIAL"==o.purchaseStatus)&&(g+='<a class="btn btn-danger" href="#" onclick="konnektive_update_order_subscription(\''.concat(globalsOrderId,"', '").concat(o.purchaseId,"', 'subscription_stop'); return false;\"><i class=\"bi bi-pause-fill\"></i> Cancel Subscription</a>")),"INACTIVE"==o.purchaseStatus&&(g+=' <a class="btn btn-success" href="#" onclick="konnektive_update_order_subscription(\''.concat(globalsOrderId,"', '").concat(o.purchaseId,"', 'subscription_restart'); return false;\"><i class=\"bi bi-play-fill\"></i> Resume Subscription</a>")),g+="</td></tr>",g+='<tr><td colspan="2" class="tab_cel2 bilcycle">'.concat(d,' <label>New Next Bill Date:</label> <input type="text" value="').concat(i,'" class="form-control" name="newRecurringDate" id="newRecurringDate" data-format="MM/dd/yyyy" autocomplete="off" /> <a href="#" onclick="konnektive_update_order_subscription(\'').concat(globalsOrderId,"', '").concat(o.purchaseId,"', 'billing_model'); return false;\" class=\"btn btn-primary\">Save</a></td></tr>")),m+=g,e.message.data[0].tracking_number?(t()("#trackNumber").html("<tr><td>".concat(e.tracking_number,' <a href="#" target="_blank" id="shipmentTrackingLink">Track Shipment</a></td></tr>')),t()(".trackingCol").show(),C(e.tracking_number)):t()(".trackingCol").hide()}})),t()("#orderModal h5").text("Order #".concat(globalsOrderId)),t()("#orderModal .modal-body #shippingInfo").html(a),b&&t()("#orderModal .modal-body #shippingInfo").html(o),t()("#orderModal .modal-body #billingInfo").html(c),b&&t()("#orderModal .modal-body #billingInfo").html(l),t()("#orderModal .modal-body #orderContents").html(m),t()("#orderModal .modal-body #billingModel").append(""),t()("#orderModal .modal-body .billingModelCol").hide(),t()("#newRecurringDate").datepicker({autoclose:!0,format:"mm/dd/yyyy",todayHighlight:!0}),e.tracking_number&&(t()("#orderModal .modal-body #shippingInfo input, #orderModal .modal-body #shippingInfo select").attr("disabled","true"),t()("#orderModal .modal-body #billingInfo input, #orderModal .modal-body #billingInfo select").attr("disabled","true"),t()(".updateOrderDetails .btn").hide()),u("newShippingState",e.message.data[0].shipState),u("newBillingState",e.message.data[0].state),i(),t()("#orderModalOpener").click()}else d(e),i(),n("error",e.message)}))}function k(e){t()(".overlay, .processing").show();var a={url:"".concat(o().konnektiveAPIURL,"/order/update?")+m({orderId:e,shipFirstName:t()("#newShippingFName").val(),shipLastName:t()("#newShippingLName").val(),shipAddress1:t()("#newShippingAddress").val(),shipAddress2:t()("#newShippingAddress2").val(),shipCity:t()("#newShippingCity").val(),shipState:t()("#newShippingState").val(),shipPostCode:t()("#newShippingZip").val(),firstName:t()("#newBillingFName").val(),lastName:t()("#newBillingLName").val(),address1:t()("#newBillingAddress").val(),address2:t()("#newBillingAddress2").val(),city:t()("#newBillingCity").val(),state:t()("#newBillingState").val(),postCode:t()("#newBillingZip").val()}),method:"POST",timeout:0,headers:{"X-SESSION-ID":""}};t().ajax(a).done((function(a){"SUCCESS"==a.result?(g(),i(),t()("#orderModal .btn-close").click(),v(e,"".concat(btoa(c("konnektive_customer_email"))))):(i(),n("error",a.message),d(a))}))}function S(e,a,r){t()(".overlay, .processing").show();var s="";"subscription_restart"===r?s={url:"".concat(o().konnektiveAPIURL,"/purchase/update?purchaseId=")+a+"&reactivate=true",method:"POST",timeout:0,headers:{"X-SESSION-ID":""}}:"subscription_stop"===r?s={url:"".concat(o().konnektiveAPIURL,"/purchase/pause?purchaseId=")+a+"&restartDate="+new Date.parse("today").add(365).day().toString("MM/dd/yyyy"),method:"POST",timeout:0,headers:{"X-SESSION-ID":""}}:"billing_model"===r&&(s={url:"".concat(o().konnektiveAPIURL,"/purchase/update?")+m({purchaseId:a,nextBillDate:t()("#newRecurringDate").val(),billingIntervalDays:t()("#billingModelUpdate option:selected").val()}),method:"POST",timeout:0,headers:{"X-SESSION-ID":""}}),t().ajax(s).done((function(a){"SUCCESS"==a.result?("subscription_stop"==r&&w(),g(),i(),t()("#orderModal .btn-close").click(),v(e,"".concat(btoa(c("konnektive_customer_email"))))):(i(),n("error",a.message),d(a))}))}function I(){var e="",a="";t().each(o().campaignID,(function(e){a+=o().campaignID[e].id,e+1<o().campaignID.length&&(a+=",")}));var r={url:"".concat(o().konnektiveAPIURL,"/campaign/query?campaignId=")+a+"&resultsPerPage=50&sortBy=campaignId&sortDir=0",method:"POST",timeout:0,headers:{"X-SESSION-ID":""}};t().ajax(r).done((function(a){"SUCCESS"==a.result&&t().each(a.message.data,(function(a,r){e=r.products,t().each(e,(function(e,a){t()(".product-image").each((function(){var e=t()(this),r=parseInt(t()(this).attr("data-pid"));a.campaignProductId==r&&a.imageUrl&&e.attr("src",a.imageUrl)}))}))}))}))}function x(e){_(e)}function w(){var e={url:"".concat(o().konnektiveAPIURL,"/members/reactivate?")+"&clubId="+o().clubID+"&memberId="+sessionStorage.getItem("member_token"),method:"POST",timeout:0,headers:{"X-SESSION-ID":""}};t().ajax(e).done((function(e){d(e)}))}function A(){document.cookie="member_token=;path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT",document.cookie="konnektive_customer_email=;path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT",document.cookie="konnektive_customer_id=;path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT",l("member_token"),l("konnektive_customer_id"),l("konnektive_customer_email"),window.location.href="./"}function C(e){var a="",r=new RegExp("\b(1Z ?[0-9A-Z]{3} ?[0-9A-Z]{3} ?[0-9A-Z]{2} ?[0-9A-Z]{4} ?[0-9A-Z]{3} ?[0-9A-Z]|[dT]ddd ?dddd ?ddd)\b"),s=new RegExp("^[kKJj]{1}[0-9]{10}$"),o=new RegExp("(\b96d{20}\b)|(\bd{15}\b)|(\bd{12}\b)"),d=new RegExp("\b((98ddddd?dddd|98dd) ?dddd ?dddd( ?ddd)?)\b"),n=new RegExp("^[0-9]{15}$"),i=new RegExp("(\bd{30}\b)|(\b91d+\b)|(\bd{20}\b)"),c=new RegExp("(\bd{30}\b)|(\b91d+\b)|(\bd{20}\b)|(\bd{26}\b)| ^ED{1}d{9}D{2}$|^9d{15,21}$| ^91[0-9]+$| ^[A-Za-z]{2}[0-9]+US$/i"),l=new RegExp("^ED{1}d{9}D{2}$|^9d{15,21}$"),m=new RegExp("^91[0-9]+$"),p=new RegExp("^[A-Za-z]{2}[0-9]+US$"),u=new RegExp("(\bd{30}\b)|(\b91d+\b)|(\bd{20}\b)|(\bd{26}\b)| ^ED{1}d{9}D{2}$|^9d{15,21}$| ^91[0-9]+$| ^[A-Za-z]{2}[0-9]+US$/i");if((r.test(e)||s.test(e))&&(a="ups"),(o.test(e)||d.test(e)||n.test(e))&&(a="fedex"),(o.test(e)||d.test(e)||n.test(e))&&(a="fedex"),(i.test(e)||c.test(e)||l.test(e)||m.test(e)||p.test(e)||u.test(e))&&(a="usps"),a){switch(a){case"ups":t()("#shipmentTrackingLink").attr("href","https://www.ups.com/mobile/track?trackingNumber=".concat(encodeURIComponent(e)));break;case"usps":t()("#shipmentTrackingLink").attr("href","https://tools.usps.com/go/TrackConfirmAction_input?strOrigTrackNum=".concat(encodeURIComponent(e)));break;case"fedex":t()("#shipmentTrackingLink").attr("href","https://www.fedex.com/apps/fedextrack/?action=track&trackingnumber=".concat(encodeURIComponent(e)))}t()("#shipmentTrackingLink").show()}else t()("#shipmentTrackingLink").hide()}Object.assign(window,{konnektive_validate_user:h,konnektive_create_member:_,konnektive_login_user:y,konnektive_user_orders_lookup:f,konnektive_user_order_details:v,konnektive_update_order:k,konnektive_update_order_subscription:S,konnektive_user_orders_set_images:I,konnektive_forgot_password:x,konnektive_reactivate_membership:w,konnektive_logout_user:A,detectCarrier:C})})(),s})()));
|