zmp-sdk 2.49.3 → 2.50.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import e from'./../../external/@swc/helpers/src/_async_to_generator.mjs.js';import t from'./../../external/@swc/helpers/src/_object_without_properties.mjs.js';import o from'./../../external/@swc/helpers/src/_sliced_to_array.mjs.js';import r from'./../../external/@swc/helpers/src/_to_consumable_array.mjs.js';import n,{object as s,string as a}from'./../../external/zod/lib/index.mjs.js';import i from"../../appEnv/index.js";import c from"../../common/notFound.js";import{functionHandler as m}from"../../utils/decorator.js";import u from"../../common/token.js";import l from"../../common/call/index.js";import{setSearchParams as d,postMessageToWidget as p}from"../../utils/common.js";import{CHECKOUT_KIT_WIDGET_ID as f,WIDGET_URLS as h,ALLOW_WIDGET_ORIGIN as g}from"../../constants.js";import{getZaloVersionCode as j}from"../../common/utils.js";import{__generator as w}from'./../../external/tslib/tslib.es6.js';import y from"../../appEnv/getEnv.js";var v,_=[s({id:a(),onMethodChange:n.function().optional()}).catchall(n.any())];function b(e){return E.apply(this,arguments)}function E(){return E=e((function(n){return w(this,(function(s){return[2,m("showWidget",_,[n],(a=e((function(n){var s,a,m,_,b,E,P,I,C,M,x;return w(this,(function(L){if(i.isMp){try{if(s=document.getElementById(n.id),a=n.onMethodChange,m=n.fail,_=t(n,["onMethodChange","fail"]),s){if(b=document.getElementById(f))return console.warn("Widget with id ".concat(f," already exists.")),[2,Promise.resolve()];b=document.createElement("iframe"),E=f,P=new URL(h.CHECKOUT_KIT),I={id:E,appId:window.APP_ID},Object.entries(_).forEach((function(e){var t=o(e,2),r=t[0],n=t[1];n&&(I["data-".concat(r)]=n)})),C=JSON.stringify(I),M=btoa(C),x=encodeURIComponent(M),d(P.searchParams,"data",x),b.id=E,b.src=P.href,b.style.width="100%",b.style.height="100%",b.style.border="none",s.innerHTML=b.outerHTML,window.removeEventListener("message",v,!1),v=function(){var t=e((function(e){var t,o,n,s,i,c,d,f,h,v;return w(this,(function(w){switch(w.label){case 0:if(t=e.data,!e.origin.startsWith(g))return[3,9];if(o=t.type,n=document.getElementById(E),(s=new URL(t.href)).origin!==P.origin||s.pathname!==P.pathname||t.id!==E)return[3,9];switch(o){case"getInfo":return[3,1];case"getToken":return[3,2];case"heightChange":return[3,4];case"callAction":return[3,5];case"onMethodChange":return[3,6];case"onError":return[3,7]}return[3,8];case 1:return p(n,o,{appId:window.APP_ID,zaloVersion:j(),appPlatform:null===(i=y())||void 0===i?void 0:i.platformName}),[3,9];case 2:return[4,u.jumpAndGetToken()];case 3:return w.sent(),d=null===(c=u.miniProgramConfig)||void 0===c?void 0:c.jwt,p(n,o,{jwt:d}),[3,9];case 4:return n.style.height="".concat(t.payload,"px"),[3,9];case 5:return f=t.payload,h=f.actionName,v=f.actionData,String(h).length>0&&l(h,v,{success:function(e){p(n,o,{status:0,actionName:h,data:e})},fail:function(e){p(n,o,{status:-1,actionName:h,data:e})}},{}),[3,9];case 6:return null==a||a.apply(void 0,r(Object.values(t.payload))),[3,9];case 7:null==m||m(t.payload),w.label=8;case 8:return[3,9];case 9:return[2]}}))}));return function(e){return t.apply(this,arguments)}}(),window.addEventListener("message",v,!1)}}catch(e){console.log(e)}return[2,Promise.resolve()]}return i.isMpWeb?[2,Promise.resolve()]:[2,Promise.reject(c("showWidget",{}))]}))})),function(e){return a.apply(this,arguments)}))];var a}))})),E.apply(this,arguments)}export{b as showWidget};
1
+ import e from'./../../external/@swc/helpers/src/_async_to_generator.mjs.js';import t from'./../../external/@swc/helpers/src/_object_without_properties.mjs.js';import n from'./../../external/@swc/helpers/src/_sliced_to_array.mjs.js';import o from'./../../external/@swc/helpers/src/_to_consumable_array.mjs.js';import r,{object as s,string as a}from'./../../external/zod/lib/index.mjs.js';import i from"../../appEnv/index.js";import c from"../../common/notFound.js";import{functionHandler as m}from"../../utils/decorator.js";import l from"../../common/token.js";import u from"../../common/call/index.js";import{setSearchParams as d,postMessageToWidget as p}from"../../utils/common.js";import{CHECKOUT_KIT_WIDGET_ID as f,WIDGET_URLS as h,ALLOW_WIDGET_ORIGIN as g}from"../../constants.js";import{getZaloVersionCode as j}from"../../common/utils.js";import{__generator as y}from'./../../external/tslib/tslib.es6.js';import v from"../../appEnv/getEnv.js";var w,_=[s({id:a(),onMethodChange:r.function().optional()}).catchall(r.any())];function b(e){return E.apply(this,arguments)}function E(){return E=e((function(r){return y(this,(function(s){return[2,m("showWidget",_,[r],(a=e((function(r){var s,a,m,_,b,E,C,I,P,M,L,N;return y(this,(function(T){if(i.isMp){try{s=document.getElementById(r.id),a=r.onMethodChange,m=r.fail,_=t(r,["onMethodChange","fail"]),s&&((b=document.getElementById(f))&&(null==b||null===(E=b.parentNode)||void 0===E||E.removeChild(b),b=null),b=document.createElement("iframe"),C=f,I=new URL(h.CHECKOUT_KIT),P={id:C,appId:window.APP_ID},Object.entries(_).forEach((function(e){var t=n(e,2),o=t[0],r=t[1];r&&(P["data-".concat(o)]=r)})),M=JSON.stringify(P),L=btoa(M),N=encodeURIComponent(L),d(I.searchParams,"data",N),b.id=C,b.src=I.href,b.style.width="100%",b.style.height="100%",b.style.border="none",s.innerHTML=b.outerHTML,window.removeEventListener("message",w,!1),w=function(){var t=e((function(e){var t,n,r,s,i,c,d,f,h,w;return y(this,(function(y){switch(y.label){case 0:if(t=e.data,!e.origin.startsWith(g))return[3,9];if(n=t.type,r=document.getElementById(C),(s=new URL(t.href)).origin!==I.origin||s.pathname!==I.pathname||t.id!==C)return[3,9];switch(n){case"getInfo":return[3,1];case"getToken":return[3,2];case"heightChange":return[3,4];case"callAction":return[3,5];case"onMethodChange":return[3,6];case"onError":return[3,7]}return[3,8];case 1:return p(r,n,{appId:window.APP_ID,zaloVersion:j(),appPlatform:null===(i=v())||void 0===i?void 0:i.platformName}),[3,9];case 2:return[4,l.jumpAndGetToken()];case 3:return y.sent(),d=null===(c=l.miniProgramConfig)||void 0===c?void 0:c.jwt,p(r,n,{jwt:d}),[3,9];case 4:return r.style.height="".concat(t.payload,"px"),[3,9];case 5:return f=t.payload,h=f.actionName,w=f.actionData,String(h).length>0&&u(h,w,{success:function(e){p(r,n,{status:0,actionName:h,data:e})},fail:function(e){p(r,n,{status:-1,actionName:h,data:e})}},{}),[3,9];case 6:return null==a||a.apply(void 0,o(Object.values(t.payload))),[3,9];case 7:null==m||m(t.payload),y.label=8;case 8:return[3,9];case 9:return[2]}}))}));return function(e){return t.apply(this,arguments)}}(),window.addEventListener("message",w,!1))}catch(e){console.log(e)}return[2,Promise.resolve()]}return i.isMpWeb?[2,Promise.resolve()]:[2,Promise.reject(c("showWidget",{}))]}))})),function(e){return a.apply(this,arguments)}))];var a}))})),E.apply(this,arguments)}export{b as showWidget};
@@ -1 +1 @@
1
- import{createOrder as r}from"./createOrder.js";import{checkTransaction as e}from"./checkTransaction.js";import{createOrderIAP as t}from"./createOrderIAP.js";import{selectPaymentMethod as o}from"./selectPaymentMethod.js";import{purchase as c}from"./purchase.js";var a={purchase:c,createOrder:r,checkTransaction:e,createOrderIAP:t,selectPaymentMethod:o},m=a;export{m as CheckoutSDK,a as Payment};
1
+ import{createOrder as r}from"./createOrder.js";import{checkTransaction as e}from"./checkTransaction.js";import{createOrderIAP as t}from"./createOrderIAP.js";import{selectPaymentMethod as o}from"./selectPaymentMethod.js";import{openPaymentLink as m}from"./openPaymentLink.js";import{purchase as a}from"./purchase.js";var c={purchase:a,createOrder:r,checkTransaction:e,createOrderIAP:t,selectPaymentMethod:o,openPaymentLink:m},n=c;export{n as CheckoutSDK,c as Payment};
@@ -0,0 +1 @@
1
+ import o from'./../../external/@swc/helpers/src/_async_to_generator.mjs.js';import t,{object as e,string as n}from'./../../external/zod/lib/index.mjs.js';import r from"../../appEnv/index.js";import i from"../../common/notFound.js";import{functionHandler as s}from"../../utils/decorator.js";import m from"../../common/apis/general/openWebview.js";import{__generator as u}from'./../../external/tslib/tslib.es6.js';var a=[e({url:n(),config:e({style:t.enum(["bottomSheet","normal"]).default("bottomSheet").optional(),leftButton:t.enum(["back","none"]).default("back").optional()}).optional()})];function p(o){return l.apply(this,arguments)}function l(){return l=o((function(t){return u(this,(function(e){return[2,s("openPaymentLink",a,[t],(n=o((function(o){return u(this,(function(t){switch(t.label){case 0:return r.isMp?[4,m(o.url,o.config,11005)]:[3,2];case 1:return[2,t.sent()];case 2:return r.isMpWeb?[2,Promise.resolve()]:[2,Promise.reject(i("openPaymentLink",{}))]}}))})),function(o){return n.apply(this,arguments)}))];var n}))})),l.apply(this,arguments)}export{p as openPaymentLink};
@@ -1 +1 @@
1
- import t from'./../../../external/@swc/helpers/src/_async_to_generator.mjs.js';import s from"../../call/index.js";import{camelToSnakeCase as e}from"../../utils.js";import o from"../../../utils/lodash.js";import{__generator as n}from'./../../../external/tslib/tslib.es6.js';var l,r=(l=t((function(t,l){var r,i,u,a;return n(this,(function(n){return r=new URL(t),i=r.href.includes("vnpay"),u=r.searchParams.get("typeInapp"),a=o.isEmpty(l)?void 0:{modal_style:(null==l?void 0:l.style)?e(null==l?void 0:l.style):"bottom_sheet",left_button:(null==l?void 0:l.leftButton)?e(null==l?void 0:l.leftButton):"back"},!i&&o.isEmpty(u)&&r.searchParams.set("typeInapp","1"),[2,new Promise((function(t,e){s("OPEN_INAPP",{url:r.href,style:a},{success:function(){t()},fail:function(t){e(t)}},{})}))]}))})),function(t,s){return l.apply(this,arguments)});export{r as default};
1
+ import t from'./../../../external/@swc/helpers/src/_async_to_generator.mjs.js';import e from"../../call/index.js";import{camelToSnakeCase as s}from"../../utils.js";import o from"../../../utils/lodash.js";import{__generator as n}from'./../../../external/tslib/tslib.es6.js';var r,l=(r=t((function(t,r,l){var i,u,a,m,p;return n(this,(function(n){return i=new URL(t),u=i.href.includes("vnpay"),a=i.searchParams.get("typeInapp"),m=o.isEmpty(r)?void 0:{modal_style:(null==r?void 0:r.style)?s(null==r?void 0:r.style):"bottom_sheet",left_button:(null==r?void 0:r.leftButton)?s(null==r?void 0:r.leftButton):"back"},p=Number.isInteger(l)?l:void 0,!u&&o.isEmpty(a)&&i.searchParams.set("typeInapp","1"),[2,new Promise((function(t,s){e("OPEN_INAPP",{url:i.href,style:m,h5_src_open:p},{success:function(){t()},fail:function(t){s(t)}},{})}))]}))})),function(t,e,s){return r.apply(this,arguments)});export{l as default};
package/apis/index.d.ts CHANGED
@@ -5383,12 +5383,40 @@ declare const nativeStorage: {
5383
5383
  getStorageInfo: typeof getStorageInfoSync;
5384
5384
  };
5385
5385
 
5386
+ declare const openPaymentLinkArgs: ZodObject<{
5387
+ url: ZodString;
5388
+ config: ZodOptional<ZodObject<{
5389
+ style: ZodOptional<ZodDefault<ZodEnum<["bottomSheet", "normal"]>>>;
5390
+ leftButton: ZodOptional<ZodDefault<ZodEnum<["back", "none"]>>>;
5391
+ }, "strip", ZodTypeAny, {
5392
+ style?: "normal" | "bottomSheet" | undefined;
5393
+ leftButton?: "none" | "back" | undefined;
5394
+ }, {
5395
+ style?: "normal" | "bottomSheet" | undefined;
5396
+ leftButton?: "none" | "back" | undefined;
5397
+ }>>;
5398
+ }, "strip", ZodTypeAny, {
5399
+ config?: {
5400
+ style?: "normal" | "bottomSheet" | undefined;
5401
+ leftButton?: "none" | "back" | undefined;
5402
+ } | undefined;
5403
+ url: string;
5404
+ }, {
5405
+ config?: {
5406
+ style?: "normal" | "bottomSheet" | undefined;
5407
+ leftButton?: "none" | "back" | undefined;
5408
+ } | undefined;
5409
+ url: string;
5410
+ }>[];
5411
+ declare function openPaymentLink(args: AsyncCallback<OpenWebviewReturns> & TypeOf<(typeof openPaymentLinkArgs)[0]>): Promise<void>;
5412
+
5386
5413
  declare const Payment: {
5387
5414
  purchase: typeof purchase$1;
5388
5415
  createOrder: typeof createOrder;
5389
5416
  checkTransaction: typeof checkTransaction;
5390
5417
  createOrderIAP: typeof createOrderIAP;
5391
5418
  selectPaymentMethod: typeof selectPaymentMethod;
5419
+ openPaymentLink: typeof openPaymentLink;
5392
5420
  };
5393
5421
  declare const CheckoutSDK: {
5394
5422
  purchase: typeof purchase$1;
@@ -5396,6 +5424,7 @@ declare const CheckoutSDK: {
5396
5424
  checkTransaction: typeof checkTransaction;
5397
5425
  createOrderIAP: typeof createOrderIAP;
5398
5426
  selectPaymentMethod: typeof selectPaymentMethod;
5427
+ openPaymentLink: typeof openPaymentLink;
5399
5428
  };
5400
5429
 
5401
5430
  declare const downloadFileArgs: ZodOptional<ZodObject<{
@@ -1 +1 @@
1
- var r="2.49.3";export{r as version};
1
+ var a="2.50.0-beta.1";export{a as version};