diff --git a/.gitignore b/.gitignore index 765fc42e..38f849ed 100755 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ vendor .phpunit.result.cache composer.lock .nvmrc +wp-content diff --git a/composer.json b/composer.json index 4b78e989..e2d6e7eb 100644 --- a/composer.json +++ b/composer.json @@ -6,9 +6,16 @@ "require-dev": { "phpunit/phpunit": "^5.7 || ^9.5", "mockery/mockery": "^1.6", - "brain/monkey": "^2.6" + "brain/monkey": "^2.6", + "woocommerce/woocommerce-blocks": "^11.7" }, "scripts": { "test": "vendor/bin/phpunit --testdox --colors" + }, + "config": { + "allow-plugins": { + "composer/installers": true, + "automattic/jetpack-autoloader": true + } } } diff --git a/includes/blocks/assets/js/build/credit_card.asset.php b/includes/blocks/assets/js/build/credit_card.asset.php index 198cafb2..484c165d 100644 --- a/includes/blocks/assets/js/build/credit_card.asset.php +++ b/includes/blocks/assets/js/build/credit_card.asset.php @@ -1 +1 @@ - array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '88ba4364a3f634f4b5463c95dd4574e6'); \ No newline at end of file + array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '85f6dde2a4f73007da7b68a01588b596'); \ No newline at end of file diff --git a/includes/blocks/assets/js/build/credit_card.js b/includes/blocks/assets/js/build/credit_card.js index b1b51212..72866702 100644 --- a/includes/blocks/assets/js/build/credit_card.js +++ b/includes/blocks/assets/js/build/credit_card.js @@ -1 +1 @@ -(()=>{"use strict";const e=window.React,t=window.wp.i18n,n=window.wc.wcBlocksRegistry,r=window.wp.htmlEntities,a=window.wc.wcSettings,s=window.wp.element,c=({onChange:n,existingCards:r})=>(0,e.createElement)(e.Fragment,null,(0,e.createElement)("h3",null,(0,t.__)("Use an existing card","omise")),(0,e.createElement)("ul",{className:"omise-customer-card-list"},r.map(((t,r)=>(0,e.createElement)("li",{key:t.id,className:"item"},(0,e.createElement)("input",{defaultChecked:0===r,id:`card-${t.id}`,type:"radio",name:"card_id",value:t.id,onChange:n}),(0,e.createElement)("label",{htmlFor:`card-${t.id}`},(0,e.createElement)("strong",null,t.brand)," xxxx ",t.last_digits))))),(0,e.createElement)("input",{id:"new_card_info",type:"radio",name:"card_id",value:"",onChange:n}),(0,e.createElement)("label",{id:"label-new_card_info",htmlFor:"new_card_info"},(0,e.createElement)("h3",null,(0,t.__)("Create a charge using new card","omise")))),i=t=>{const{settings:n}=t,{existing_cards:a,description:i}=n,l=(0,s.useRef)(null),o=(0,s.useRef)(!1),m=(0,s.useRef)(null),d=(0,s.useRef)(null),u=(0,s.useRef)(null),[p,_]=(0,s.useState)(a&&a.length>0),{eventRegistration:E,emitResponse:g}=t,{onPaymentSetup:y,onCheckoutValidation:h}=E;return(0,s.useEffect)((()=>{var e;p||showOmiseEmbeddedCardForm({element:l.current,publicKey:n.public_key,hideRememberCard:!n.user_logged_in,locale:n.lcoale,theme:null!==(e=n.card_form_theme)&&void 0!==e?e:"light",design:n.form_design,brandIcons:n.card_brand_icons,onSuccess:e=>{e.remember&&(o.current=e.remember),m.current=e.token},onError:e=>{u.current=e}})}),[p]),(0,s.useEffect)((()=>{if(!p)return h((()=>(OmiseCard.requestCardToken(),!0)))}),[h,p]),(0,s.useEffect)((()=>{const e=y((async()=>await new Promise(((e,t)=>{const n=setInterval((()=>{if(d.current&&""!==d.current.value){clearInterval(n);try{const t={type:g.responseTypes.SUCCESS,meta:{paymentMethodData:{card_id:d.current.value}}};e(t)}catch(e){const n={type:g.responseTypes.ERROR,message:e.message};t(n)}}else if(m.current&&""!==m.current.value){clearInterval(n);try{const t={type:g.responseTypes.SUCCESS,meta:{paymentMethodData:{omise_save_customer_card:o.current.value,omise_token:m.current}}};e(t)}catch(e){const n={type:g.responseTypes.ERROR,message:e.message};t(n)}}else if(u.current){clearInterval(n);const e={type:g.responseTypes.ERROR,message:u.current};t(e)}}),1e3)}))));return()=>e()}),[g.responseTypes.ERROR,g.responseTypes.SUCCESS,y]),(0,e.createElement)(e.Fragment,null,a&&a.length>0&&(0,e.createElement)(c,{existingCards:a,onChange:e=>{const t=e.target;_(""!==t.value),d.current=t}}),!p&&(0,e.createElement)("p",null,(0,r.decodeEntities)(i||"")),(0,e.createElement)("div",{ref:l,id:"omise-card",style:{width:"100%",display:p?"none":"block"}}),!p&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("input",{type:"hidden",name:"omise_save_customer_card",id:"omise_save_customer_card"}),(0,e.createElement)("input",{type:"hidden",className:"omise_token",name:"omise_token"})))},l=(0,a.getSetting)("omise_data",{}),o=(0,t.__)("Credit/Debit card","omise"),m=(0,r.decodeEntities)(l.title)||o;window.OMISE_CUSTOM_FONT_OTHER="Other";const d=t=>(0,e.createElement)(i,{...t,settings:l});(0,n.registerPaymentMethod)({name:l.name||"",label:(0,e.createElement)((t=>{const{PaymentMethodLabel:n}=t.components;return(0,e.createElement)(n,{text:m})}),null),content:(0,e.createElement)(d,{settings:l}),edit:(0,e.createElement)(d,{settings:l}),canMakePayment:()=>!0,ariaLabel:m,supports:{features:l.supports}})})(); \ No newline at end of file +(()=>{"use strict";const e=window.React,t=window.wp.i18n,n=window.wc.wcBlocksRegistry,r=window.wp.htmlEntities,a=window.wc.wcSettings,s=window.wp.element,c=({onChange:n,existingCards:r})=>(0,e.createElement)(e.Fragment,null,(0,e.createElement)("h3",null,(0,t.__)("Use an existing card","omise")),(0,e.createElement)("ul",{className:"omise-customer-card-list"},r.map(((t,r)=>(0,e.createElement)("li",{key:t.id,className:"item"},(0,e.createElement)("input",{defaultChecked:0===r,id:`card-${t.id}`,type:"radio",name:"card_id",value:t.id,onChange:n}),(0,e.createElement)("label",{htmlFor:`card-${t.id}`},(0,e.createElement)("strong",null,t.brand)," xxxx ",t.last_digits))))),(0,e.createElement)("input",{id:"new_card_info",type:"radio",name:"card_id",value:"",onChange:n}),(0,e.createElement)("label",{id:"label-new_card_info",htmlFor:"new_card_info"},(0,e.createElement)("h3",null,(0,t.__)("Create a charge using new card","omise")))),i=t=>{const{settings:n}=t,{existing_cards:a,description:i}=n,l=(0,s.useRef)(null),o=(0,s.useRef)(!1),m=(0,s.useRef)(null),d=(0,s.useRef)(null),u=(0,s.useRef)(null),[p,_]=(0,s.useState)(a&&a.length>0),{eventRegistration:g,emitResponse:E}=t,{onPaymentSetup:y,onCheckoutValidation:h}=g;return(0,s.useEffect)((()=>{var e;p||showOmiseEmbeddedCardForm({element:l.current,publicKey:n.public_key,hideRememberCard:!n.user_logged_in,locale:n.lcoale,theme:null!==(e=n.card_form_theme)&&void 0!==e?e:"light",design:n.form_design,brandIcons:n.card_brand_icons,onSuccess:e=>{e.remember&&(o.current=e.remember),m.current=e.token},onError:e=>{u.current=e}})}),[p]),(0,s.useEffect)((()=>{if(!p)return h((()=>(OmiseCard.requestCardToken(),!0)))}),[h,p]),(0,s.useEffect)((()=>{const e=y((async()=>await new Promise(((e,t)=>{const n=setInterval((()=>{if(d.current&&""!==d.current.value){clearInterval(n);try{const t={type:E.responseTypes.SUCCESS,meta:{paymentMethodData:{card_id:d.current.value}}};e(t)}catch(e){const n={type:E.responseTypes.ERROR,message:e.message};t(n)}}else if(m.current&&""!==m.current.value){clearInterval(n);try{const t={type:E.responseTypes.SUCCESS,meta:{paymentMethodData:{omise_save_customer_card:o.current.value,omise_token:m.current}}};e(t)}catch(e){const n={type:E.responseTypes.ERROR,message:e.message};t(n)}}else if(u.current){clearInterval(n);const e={type:E.responseTypes.ERROR,message:u.current};t(e)}}),1e3)}))));return()=>e()}),[E.responseTypes.ERROR,E.responseTypes.SUCCESS,y]),(0,e.createElement)(e.Fragment,null,a&&a.length>0&&(0,e.createElement)(c,{existingCards:a,onChange:e=>{const t=e.target;_(""!==t.value),d.current=t}}),!p&&(0,e.createElement)("p",null,(0,r.decodeEntities)(i||"")),(0,e.createElement)("div",{ref:l,id:"omise-card",style:{width:"100%",display:p?"none":"block"}}),!p&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("input",{type:"hidden",name:"omise_save_customer_card",id:"omise_save_customer_card"}),(0,e.createElement)("input",{type:"hidden",className:"omise_token",name:"omise_token"})))},l=(0,a.getSetting)("omise_data",{}),o=(0,t.__)("Credit/Debit card","omise"),m=(0,r.decodeEntities)(l.title)||o;window.OMISE_CUSTOM_FONT_OTHER="Other",console.log({settings:l});const d=t=>(0,e.createElement)(i,{...t,settings:l});(0,n.registerPaymentMethod)({name:l.name||"",label:(0,e.createElement)((t=>{const{PaymentMethodLabel:n}=t.components;return(0,e.createElement)(n,{text:m})}),null),content:(0,e.createElement)(d,{settings:l}),edit:(0,e.createElement)(d,{settings:l}),canMakePayment:()=>l.is_active,ariaLabel:m,supports:{features:l.supports}})})(); \ No newline at end of file diff --git a/includes/blocks/assets/js/build/omise-mobilebanking.asset.php b/includes/blocks/assets/js/build/omise-mobilebanking.asset.php index 03cf21c2..d321bb8e 100644 --- a/includes/blocks/assets/js/build/omise-mobilebanking.asset.php +++ b/includes/blocks/assets/js/build/omise-mobilebanking.asset.php @@ -1 +1 @@ - array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '8300bb1e0ea5db8412514a952f045a85'); \ No newline at end of file + array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '1c1381978da7eeae827a289aa53203d9'); \ No newline at end of file diff --git a/includes/blocks/assets/js/build/omise-mobilebanking.js b/includes/blocks/assets/js/build/omise-mobilebanking.js index 4e01793b..b7ef921b 100644 --- a/includes/blocks/assets/js/build/omise-mobilebanking.js +++ b/includes/blocks/assets/js/build/omise-mobilebanking.js @@ -1 +1 @@ -(()=>{"use strict";const e=window.React,t=window.wp.element,n=window.wp.i18n,a=window.wp.htmlEntities,l=window.wc.wcBlocksRegistry,i=(0,window.wc.wcSettings.getSetting)("omise_mobilebanking_data",{}),s=(0,a.decodeEntities)(i.title)||"No title set",m=l=>{const{eventRegistration:s,emitResponse:m}=l,{onPaymentSetup:r}=s,o=(0,a.decodeEntities)(i.description||""),c=i.data.backends,d=(0,n.__)("There are no payment methods available.","omise"),p=(0,t.useRef)({}),u=e=>{p.current=e.target.value};return(0,t.useEffect)((()=>{const e=r((async()=>{try{return{type:m.responseTypes.SUCCESS,meta:{paymentMethodData:{"omise-offsite":p.current}}}}catch(e){return{type:m.responseTypes.ERROR,message:e.message}}}));return()=>e()}),[r]),(0,e.createElement)(e.Fragment,null,o&&(0,e.createElement)("p",null,o),0==c.length?(0,e.createElement)("p",null,d):(0,e.createElement)("fieldset",{key:"omise-form-mobilebanking"+c.length,id:"omise-form-mobilebanking"},(0,e.createElement)("ul",{className:"omise-banks-list"},c.map(((t,n)=>(0,e.createElement)("li",{key:t._id+n,className:"item mobile-banking"},(0,e.createElement)("div",null,(0,e.createElement)("input",{id:t._id,type:"radio",name:"omise-offsite",value:t._id,onChange:u}),(0,e.createElement)("label",{htmlFor:t._id},(0,e.createElement)("div",{className:`mobile-banking-logo ${t.provider_logo}`}),(0,e.createElement)("div",{className:"mobile-banking-label"},(0,e.createElement)("span",{className:"title"},t.provider_name),(0,e.createElement)("br",null))))))))))};(0,l.registerPaymentMethod)({name:i.name||"",label:(0,e.createElement)((t=>{const{PaymentMethodLabel:n}=t.components;return(0,e.createElement)(n,{text:s})}),null),content:(0,e.createElement)(m,null),edit:(0,e.createElement)(m,null),canMakePayment:()=>!0,ariaLabel:s,supports:{features:i.supports}})})(); \ No newline at end of file +(()=>{"use strict";const e=window.React,t=window.wp.element,n=window.wp.i18n,a=window.wp.htmlEntities,l=window.wc.wcBlocksRegistry,i=(0,window.wc.wcSettings.getSetting)("omise_mobilebanking_data",{}),s=(0,a.decodeEntities)(i.title)||"No title set",m=l=>{const{eventRegistration:s,emitResponse:m}=l,{onPaymentSetup:r}=s,o=(0,a.decodeEntities)(i.description||""),c=i.data.backends,d=(0,n.__)("There are no payment methods available.","omise"),p=(0,t.useRef)({}),u=e=>{p.current=e.target.value};return(0,t.useEffect)((()=>{const e=r((async()=>{try{return{type:m.responseTypes.SUCCESS,meta:{paymentMethodData:{"omise-offsite":p.current}}}}catch(e){return{type:m.responseTypes.ERROR,message:e.message}}}));return()=>e()}),[r]),(0,e.createElement)(e.Fragment,null,o&&(0,e.createElement)("p",null,o),0==c.length?(0,e.createElement)("p",null,d):(0,e.createElement)("fieldset",{key:"omise-form-mobilebanking"+c.length,id:"omise-form-mobilebanking"},(0,e.createElement)("ul",{className:"omise-banks-list"},c.map(((t,n)=>(0,e.createElement)("li",{key:t._id+n,className:"item mobile-banking"},(0,e.createElement)("div",null,(0,e.createElement)("input",{id:t._id,type:"radio",name:"omise-offsite",value:t._id,onChange:u}),(0,e.createElement)("label",{htmlFor:t._id},(0,e.createElement)("div",{className:`mobile-banking-logo ${t.provider_logo}`}),(0,e.createElement)("div",{className:"mobile-banking-label"},(0,e.createElement)("span",{className:"title"},t.provider_name),(0,e.createElement)("br",null))))))))))};(0,l.registerPaymentMethod)({name:i.name||"",label:(0,e.createElement)((t=>{const{PaymentMethodLabel:n}=t.components;return(0,e.createElement)(n,{text:s})}),null),content:(0,e.createElement)(m,null),edit:(0,e.createElement)(m,null),canMakePayment:()=>i.is_active,ariaLabel:s,supports:{features:i.supports}})})(); \ No newline at end of file diff --git a/includes/blocks/assets/js/build/omise-one-click-apms.asset.php b/includes/blocks/assets/js/build/omise-one-click-apms.asset.php index a658be8a..e86a5de5 100644 --- a/includes/blocks/assets/js/build/omise-one-click-apms.asset.php +++ b/includes/blocks/assets/js/build/omise-one-click-apms.asset.php @@ -1 +1 @@ - array('react', 'wc-blocks-registry', 'wc-settings', 'wp-html-entities', 'wp-i18n'), 'version' => '9e361f14bcb633d57aec2bede0ca58f2'); \ No newline at end of file + array('react', 'wc-blocks-registry', 'wc-settings', 'wp-html-entities', 'wp-i18n'), 'version' => 'e6fac6c16b43d5aef4854d8cb63f068d'); \ No newline at end of file diff --git a/includes/blocks/assets/js/build/omise-one-click-apms.js b/includes/blocks/assets/js/build/omise-one-click-apms.js index 9839276b..8787b1ed 100644 --- a/includes/blocks/assets/js/build/omise-one-click-apms.js +++ b/includes/blocks/assets/js/build/omise-one-click-apms.js @@ -1 +1 @@ -(()=>{"use strict";window.wp.i18n;const a=window.wp.htmlEntities,e=window.React,t=window.wc.wcBlocksRegistry;function o({settings:o,label:i}){const n=()=>(0,a.decodeEntities)(o.description||"");(0,t.registerPaymentMethod)({name:o.name||"",label:(0,e.createElement)((a=>{const{PaymentMethodLabel:t}=a.components;return(0,e.createElement)(t,{text:i})}),null),content:(0,e.createElement)(n,null),edit:(0,e.createElement)(n,null),canMakePayment:()=>!0,ariaLabel:i,supports:{features:o.supports}})}const i=window.wc.wcSettings,n=["omise_alipay_data","omise_alipay_cn_data","omise_alipay_hk_data","omise_dana_data","omise_gcash_data","omise_kakaopay_data","omise_promptpay_data","omise_touch_n_go_data","omise_billpayment_tesco_data","omise_shopeepay_data","omise_wechat_pay_data","omise_grabpay_data","omise_paynow_data","omise_ocbc_data","omise_fpx_data","omise_maybank_qr_data","omise_duitnow_qr_data","omise_paypay_data","omise_rabbit_linepay_data"];for(const e of n){const t=(0,i.getSetting)(e,{});t.name&&o({settings:t,label:(0,a.decodeEntities)(t.title)||"No title set"})}})(); \ No newline at end of file +(()=>{"use strict";window.wp.i18n;const a=window.wp.htmlEntities,e=window.React,t=window.wc.wcBlocksRegistry;function i({settings:i,label:o}){const s=()=>(0,a.decodeEntities)(i.description||"");(0,t.registerPaymentMethod)({name:i.name||"",label:(0,e.createElement)((a=>{const{PaymentMethodLabel:t}=a.components;return(0,e.createElement)(t,{text:o})}),null),content:(0,e.createElement)(s,null),edit:(0,e.createElement)(s,null),canMakePayment:()=>i.is_active,ariaLabel:o,supports:{features:i.supports}})}const o=window.wc.wcSettings,s=["omise_alipay_data","omise_alipay_cn_data","omise_alipay_hk_data","omise_dana_data","omise_gcash_data","omise_kakaopay_data","omise_promptpay_data","omise_touch_n_go_data","omise_billpayment_tesco_data","omise_shopeepay_data","omise_wechat_pay_data","omise_grabpay_data","omise_paynow_data","omise_ocbc_data","omise_fpx_data","omise_maybank_qr_data","omise_duitnow_qr_data","omise_paypay_data","omise_rabbit_linepay_data"];for(const e of s){const t=(0,o.getSetting)(e,{});t.name&&i({settings:t,label:(0,a.decodeEntities)(t.title)||"No title set"})}})(); \ No newline at end of file diff --git a/includes/blocks/assets/js/build/omise_atome.asset.php b/includes/blocks/assets/js/build/omise_atome.asset.php index ab8704b3..f666f34c 100644 --- a/includes/blocks/assets/js/build/omise_atome.asset.php +++ b/includes/blocks/assets/js/build/omise_atome.asset.php @@ -1 +1 @@ - array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '338c1cd6b30d199b030020d82f9fae92'); \ No newline at end of file + array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '038fdf4e9f72acd0b7ba55de2c3b74a8'); \ No newline at end of file diff --git a/includes/blocks/assets/js/build/omise_atome.js b/includes/blocks/assets/js/build/omise_atome.js index ea21ffae..a65c80be 100644 --- a/includes/blocks/assets/js/build/omise_atome.js +++ b/includes/blocks/assets/js/build/omise_atome.js @@ -1 +1 @@ -(()=>{"use strict";const e=window.React,t=window.wp.element,n=window.wp.i18n,a=window.wp.htmlEntities,o=window.wc.wcBlocksRegistry,s=(0,window.wc.wcSettings.getSetting)("omise_atome_data",{}),m=(0,a.decodeEntities)(s.title)||"No title set",r=o=>{const{eventRegistration:m,emitResponse:r}=o,{onPaymentSetup:l}=m,i=(0,a.decodeEntities)(s.description||""),{status:p,message:c}=s.data,[u,d]=(0,t.useState)(!1),[_,w]=(0,t.useState)(!0),[E,h]=(0,t.useState)("");return(0,t.useEffect)((()=>{const e=l((async()=>{if(!_&&0===E.length)return{type:r.responseTypes.ERROR,message:"Enter a phone number"};try{return{type:r.responseTypes.SUCCESS,meta:{paymentMethodData:{omise_atome_phone_default:(_?1:0).toString(),omise_atome_phone_number:E}}}}catch(e){return{type:r.responseTypes.ERROR,message:e.message}}}));return()=>e()}),[l,r.responseTypes.ERROR,r.responseTypes.SUCCESS,_,E]),(0,e.createElement)(e.Fragment,null,i&&(0,e.createElement)("p",null,i),p?(0,e.createElement)("fieldset",{id:"omise-form-atome"},(0,n.__)("Atome phone number","omise"),(0,e.createElement)("br",null),(0,e.createElement)("p",{className:"form-row form-row-wide omise-label-inline"},(0,e.createElement)("input",{id:"omise_atome_phone_default",type:"checkbox",name:"omise_atome_phone_default",value:_,defaultChecked:!0,onChange:e=>{w(!_),d(!u),_&&h("")}}),(0,e.createElement)("label",{htmlFor:"omise_atome_phone_default"},(0,n.__)("Same as Billing Detail","omise"))),(0,e.createElement)("p",{id:"omise_atome_phone_field",className:"form-row form-row-wide",style:{display:u?"block":"none"}},(0,e.createElement)("span",{className:"woocommerce-input-wrapper"},(0,e.createElement)("input",{id:"omise_atome_phone_number",className:"input-text",name:"omise_atome_phone_number",type:"tel",autoComplete:"off",placeholder:"+66123456789",onChange:e=>{h(e.target.value)}}))),(0,e.createElement)("p",{className:"omise-secondary-text"},(0,n.__)("The phone number will be used for creating Atome charge","omise"))):(0,e.createElement)("p",null,c))};(0,o.registerPaymentMethod)({name:s.name||"",label:(0,e.createElement)((t=>{const{PaymentMethodLabel:n}=t.components;return(0,e.createElement)(n,{text:m})}),null),content:(0,e.createElement)(r,null),edit:(0,e.createElement)(r,null),canMakePayment:()=>!0,ariaLabel:m,supports:{features:s.supports}})})(); \ No newline at end of file +(()=>{"use strict";const e=window.React,t=window.wp.element,n=window.wp.i18n,a=window.wp.htmlEntities,o=window.wc.wcBlocksRegistry,s=(0,window.wc.wcSettings.getSetting)("omise_atome_data",{}),m=(0,a.decodeEntities)(s.title)||"No title set",r=o=>{const{eventRegistration:m,emitResponse:r}=o,{onPaymentSetup:l}=m,i=(0,a.decodeEntities)(s.description||""),{status:c,message:p}=s.data,[u,d]=(0,t.useState)(!1),[_,w]=(0,t.useState)(!0),[E,h]=(0,t.useState)("");return(0,t.useEffect)((()=>{const e=l((async()=>{if(!_&&0===E.length)return{type:r.responseTypes.ERROR,message:"Enter a phone number"};try{return{type:r.responseTypes.SUCCESS,meta:{paymentMethodData:{omise_atome_phone_default:(_?1:0).toString(),omise_atome_phone_number:E}}}}catch(e){return{type:r.responseTypes.ERROR,message:e.message}}}));return()=>e()}),[l,r.responseTypes.ERROR,r.responseTypes.SUCCESS,_,E]),(0,e.createElement)(e.Fragment,null,i&&(0,e.createElement)("p",null,i),c?(0,e.createElement)("fieldset",{id:"omise-form-atome"},(0,n.__)("Atome phone number","omise"),(0,e.createElement)("br",null),(0,e.createElement)("p",{className:"form-row form-row-wide omise-label-inline"},(0,e.createElement)("input",{id:"omise_atome_phone_default",type:"checkbox",name:"omise_atome_phone_default",value:_,defaultChecked:!0,onChange:e=>{w(!_),d(!u),_&&h("")}}),(0,e.createElement)("label",{htmlFor:"omise_atome_phone_default"},(0,n.__)("Same as Billing Detail","omise"))),(0,e.createElement)("p",{id:"omise_atome_phone_field",className:"form-row form-row-wide",style:{display:u?"block":"none"}},(0,e.createElement)("span",{className:"woocommerce-input-wrapper"},(0,e.createElement)("input",{id:"omise_atome_phone_number",className:"input-text",name:"omise_atome_phone_number",type:"tel",autoComplete:"off",placeholder:"+66123456789",onChange:e=>{h(e.target.value)}}))),(0,e.createElement)("p",{className:"omise-secondary-text"},(0,n.__)("The phone number will be used for creating Atome charge","omise"))):(0,e.createElement)("p",null,p))};(0,o.registerPaymentMethod)({name:s.name||"",label:(0,e.createElement)((t=>{const{PaymentMethodLabel:n}=t.components;return(0,e.createElement)(n,{text:m})}),null),content:(0,e.createElement)(r,null),edit:(0,e.createElement)(r,null),canMakePayment:()=>s.is_active,ariaLabel:m,supports:{features:s.supports}})})(); \ No newline at end of file diff --git a/includes/blocks/assets/js/build/omise_duitnow_obw.asset.php b/includes/blocks/assets/js/build/omise_duitnow_obw.asset.php index da247044..28f44fb9 100644 --- a/includes/blocks/assets/js/build/omise_duitnow_obw.asset.php +++ b/includes/blocks/assets/js/build/omise_duitnow_obw.asset.php @@ -1 +1 @@ - array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '6ae37be8bb705c7421530c7338e22bca'); \ No newline at end of file + array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '9895ac689bce188c4a74717ce7c149c5'); \ No newline at end of file diff --git a/includes/blocks/assets/js/build/omise_duitnow_obw.js b/includes/blocks/assets/js/build/omise_duitnow_obw.js index 8fb8c993..02028bd0 100644 --- a/includes/blocks/assets/js/build/omise_duitnow_obw.js +++ b/includes/blocks/assets/js/build/omise_duitnow_obw.js @@ -1 +1 @@ -(()=>{"use strict";const e=window.React,t=window.wp.element,n=(window.wp.i18n,window.wp.htmlEntities),a=window.wc.wcBlocksRegistry,s=(0,window.wc.wcSettings.getSetting)("omise_duitnow_obw_data",{}),l=(0,n.decodeEntities)(s.title)||"No title set",o=a=>{const{eventRegistration:l,emitResponse:o}=a,{onPaymentSetup:c}=l,r=(0,n.decodeEntities)(s.description||""),{banks:i}=s.data,[m,p]=(0,t.useState)(null);return(0,t.useEffect)((()=>{const e=c((async()=>{if(!m)return{type:o.responseTypes.ERROR,message:"Select a bank"};try{return{type:o.responseTypes.SUCCESS,meta:{paymentMethodData:{bank:m}}}}catch(e){return{type:o.responseTypes.ERROR,message:e.message}}}));return()=>e()}),[o.responseTypes.ERROR,o.responseTypes.SUCCESS,c,m]),(0,e.createElement)(e.Fragment,null,r&&(0,e.createElement)("p",null,r),(0,e.createElement)("fieldset",{id:"omise-form-installment"},(0,e.createElement)("div",{className:"fpx-select-bank"},(0,e.createElement)("label",{htmlFor:"fpx-select-bank"},"Select Bank"),(0,e.createElement)("select",{className:"fpx-bank-logo default",id:"duitnow-obw-select-bank",name:"source[bank]",defaultValue:"",onChange:e=>{p(e.target.value)}},(0,e.createElement)("option",{value:"",disabled:!0},"-- Select your option --"),i.map((t=>(0,e.createElement)("option",{key:t.code,className:t.code,value:t.code},t.name)))))))};(0,a.registerPaymentMethod)({name:s.name||"",label:(0,e.createElement)((t=>{const{PaymentMethodLabel:n}=t.components;return(0,e.createElement)(n,{text:l})}),null),content:(0,e.createElement)(o,null),edit:(0,e.createElement)(o,null),canMakePayment:()=>!0,ariaLabel:l,supports:{features:s.supports}})})(); \ No newline at end of file +(()=>{"use strict";const e=window.React,t=window.wp.element,n=(window.wp.i18n,window.wp.htmlEntities),a=window.wc.wcBlocksRegistry,s=(0,window.wc.wcSettings.getSetting)("omise_duitnow_obw_data",{}),l=(0,n.decodeEntities)(s.title)||"No title set",o=a=>{const{eventRegistration:l,emitResponse:o}=a,{onPaymentSetup:c}=l,r=(0,n.decodeEntities)(s.description||""),{banks:i}=s.data,[m,p]=(0,t.useState)(null);return(0,t.useEffect)((()=>{const e=c((async()=>{if(!m)return{type:o.responseTypes.ERROR,message:"Select a bank"};try{return{type:o.responseTypes.SUCCESS,meta:{paymentMethodData:{bank:m}}}}catch(e){return{type:o.responseTypes.ERROR,message:e.message}}}));return()=>e()}),[o.responseTypes.ERROR,o.responseTypes.SUCCESS,c,m]),(0,e.createElement)(e.Fragment,null,r&&(0,e.createElement)("p",null,r),(0,e.createElement)("fieldset",{id:"omise-form-installment"},(0,e.createElement)("div",{className:"fpx-select-bank"},(0,e.createElement)("label",{htmlFor:"fpx-select-bank"},"Select Bank"),(0,e.createElement)("select",{className:"fpx-bank-logo default",id:"duitnow-obw-select-bank",name:"source[bank]",defaultValue:"",onChange:e=>{p(e.target.value)}},(0,e.createElement)("option",{value:"",disabled:!0},"-- Select your option --"),i.map((t=>(0,e.createElement)("option",{key:t.code,className:t.code,value:t.code},t.name)))))))};(0,a.registerPaymentMethod)({name:s.name||"",label:(0,e.createElement)((t=>{const{PaymentMethodLabel:n}=t.components;return(0,e.createElement)(n,{text:l})}),null),content:(0,e.createElement)(o,null),edit:(0,e.createElement)(o,null),canMakePayment:()=>s.is_active,ariaLabel:l,supports:{features:s.supports}})})(); \ No newline at end of file diff --git a/includes/blocks/assets/js/build/omise_fpx.asset.php b/includes/blocks/assets/js/build/omise_fpx.asset.php index 20499093..ec0b321f 100644 --- a/includes/blocks/assets/js/build/omise_fpx.asset.php +++ b/includes/blocks/assets/js/build/omise_fpx.asset.php @@ -1 +1 @@ - array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '449ba1e9fbdfe36ffe11aee7d7ddd2b7'); \ No newline at end of file + array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => 'c0c1739fc2507037807a1361ff76059e'); \ No newline at end of file diff --git a/includes/blocks/assets/js/build/omise_fpx.js b/includes/blocks/assets/js/build/omise_fpx.js index 39c796af..f7c261e9 100644 --- a/includes/blocks/assets/js/build/omise_fpx.js +++ b/includes/blocks/assets/js/build/omise_fpx.js @@ -1 +1 @@ -(()=>{"use strict";const e=window.React,t=window.wp.element,n=window.wp.i18n,a=window.wp.htmlEntities,s=window.wc.wcBlocksRegistry,l=(0,window.wc.wcSettings.getSetting)("omise_fpx_data",{}),r=(0,a.decodeEntities)(l.title)||"No title set",c=s=>{const{eventRegistration:r,emitResponse:c}=s,{onPaymentSetup:o}=r,i=(0,a.decodeEntities)(l.description||""),{bank_list:m}=l.data,p=(0,n.__)("FPX is currently not available.","omise"),d=(0,t.useRef)(null);return(0,t.useEffect)((()=>{const e=o((async()=>{if(!d.current)return{type:c.responseTypes.ERROR,message:"Select a bank"};try{return{type:c.responseTypes.SUCCESS,meta:{paymentMethodData:{bank:d.current}}}}catch(e){return{type:c.responseTypes.ERROR,message:e.message}}}));return()=>e()}),[c.responseTypes.ERROR,c.responseTypes.SUCCESS,o]),(0,e.createElement)(e.Fragment,null,i&&(0,e.createElement)("p",null,i),0==m.length?(0,e.createElement)("p",null,p):(0,e.createElement)("fieldset",{id:"omise-form-installment"},(0,e.createElement)("div",{className:"fpx-select-bank"},(0,e.createElement)("label",{htmlFor:"fpx-select-bank"},"Select Bank"),(0,e.createElement)("select",{className:"fpx-bank-logo default",id:"fpx-select-bank",name:"source[bank]",defaultValue:"",onChange:e=>{d.current=e.target.value}},(0,e.createElement)("option",{value:"",disabled:!0},"-- Select your option --"),m.map((t=>(0,e.createElement)("option",{key:t.code,className:t.code,value:t.code,disabled:"1"===t.active},t.name,!t.active&&" (offline)"))))),(0,e.createElement)("div",{className:"fpx-terms-and-conditions-block"},(0,e.createElement)("span",null,"By clicking on the ",(0,e.createElement)("b",null,'"Place Order"')," button, you agree to FPX's",(0,e.createElement)("a",{href:"https://www.mepsfpx.com.my/FPXMain/termsAndConditions.jsp",target:"_blank"},"Terms and Conditions")))))};(0,s.registerPaymentMethod)({name:l.name||"",label:(0,e.createElement)((t=>{const{PaymentMethodLabel:n}=t.components;return(0,e.createElement)(n,{text:r})}),null),content:(0,e.createElement)(c,null),edit:(0,e.createElement)(c,null),canMakePayment:()=>!0,ariaLabel:r,supports:{features:l.supports}})})(); \ No newline at end of file +(()=>{"use strict";const e=window.React,t=window.wp.element,n=window.wp.i18n,a=window.wp.htmlEntities,s=window.wc.wcBlocksRegistry,l=(0,window.wc.wcSettings.getSetting)("omise_fpx_data",{}),r=(0,a.decodeEntities)(l.title)||"No title set",c=s=>{const{eventRegistration:r,emitResponse:c}=s,{onPaymentSetup:o}=r,i=(0,a.decodeEntities)(l.description||""),{bank_list:m}=l.data,p=(0,n.__)("FPX is currently not available.","omise"),d=(0,t.useRef)(null);return(0,t.useEffect)((()=>{const e=o((async()=>{if(!d.current)return{type:c.responseTypes.ERROR,message:"Select a bank"};try{return{type:c.responseTypes.SUCCESS,meta:{paymentMethodData:{bank:d.current}}}}catch(e){return{type:c.responseTypes.ERROR,message:e.message}}}));return()=>e()}),[c.responseTypes.ERROR,c.responseTypes.SUCCESS,o]),(0,e.createElement)(e.Fragment,null,i&&(0,e.createElement)("p",null,i),0==m.length?(0,e.createElement)("p",null,p):(0,e.createElement)("fieldset",{id:"omise-form-installment"},(0,e.createElement)("div",{className:"fpx-select-bank"},(0,e.createElement)("label",{htmlFor:"fpx-select-bank"},"Select Bank"),(0,e.createElement)("select",{className:"fpx-bank-logo default",id:"fpx-select-bank",name:"source[bank]",defaultValue:"",onChange:e=>{d.current=e.target.value}},(0,e.createElement)("option",{value:"",disabled:!0},"-- Select your option --"),m.map((t=>(0,e.createElement)("option",{key:t.code,className:t.code,value:t.code,disabled:"1"===t.active},t.name,!t.active&&" (offline)"))))),(0,e.createElement)("div",{className:"fpx-terms-and-conditions-block"},(0,e.createElement)("span",null,"By clicking on the ",(0,e.createElement)("b",null,'"Place Order"')," button, you agree to FPX's",(0,e.createElement)("a",{href:"https://www.mepsfpx.com.my/FPXMain/termsAndConditions.jsp",target:"_blank"},"Terms and Conditions")))))};(0,s.registerPaymentMethod)({name:l.name||"",label:(0,e.createElement)((t=>{const{PaymentMethodLabel:n}=t.components;return(0,e.createElement)(n,{text:r})}),null),content:(0,e.createElement)(c,null),edit:(0,e.createElement)(c,null),canMakePayment:()=>l.is_active,ariaLabel:r,supports:{features:l.supports}})})(); \ No newline at end of file diff --git a/includes/blocks/assets/js/build/omise_googlepay.asset.php b/includes/blocks/assets/js/build/omise_googlepay.asset.php index 254f4278..19396d37 100644 --- a/includes/blocks/assets/js/build/omise_googlepay.asset.php +++ b/includes/blocks/assets/js/build/omise_googlepay.asset.php @@ -1 +1 @@ - array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => 'bd8de8fe88d6de8afc3a7b89d8afcd23'); \ No newline at end of file + array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '77916390d59105c488920c81e3010814'); \ No newline at end of file diff --git a/includes/blocks/assets/js/build/omise_googlepay.js b/includes/blocks/assets/js/build/omise_googlepay.js index b9d61312..4b6e32a2 100644 --- a/includes/blocks/assets/js/build/omise_googlepay.js +++ b/includes/blocks/assets/js/build/omise_googlepay.js @@ -1 +1 @@ -(()=>{var e={21:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function o(e,t,n,o){return new(n||(n=Promise))((function(i,a){function s(e){try{l(o.next(e))}catch(e){a(e)}}function r(e){try{l(o.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,r)}l((o=o.apply(e,t||[])).next())}))}let i={};class a{constructor(e){this.handleClick=e=>o(this,void 0,void 0,(function*(){const t=this.config;if(!t)throw new Error("google-pay-button: Missing configuration");const n=this.createLoadPaymentDataRequest(t);try{if(t.onClick&&t.onClick(e),e.defaultPrevented)return;const o=yield this.client.loadPaymentData(n);t.onLoadPaymentData&&t.onLoadPaymentData(o)}catch(e){"CANCELED"===e.statusCode?t.onCancel&&t.onCancel(e):t.onError?t.onError(e):console.error(e)}})),this.options=e}getElement(){return this.element}isGooglePayLoaded(){var e,t;return"google"in(window||n.g)&&!!(null===(t=null===(e=null===google||void 0===google?void 0:google.payments)||void 0===e?void 0:e.api)||void 0===t?void 0:t.PaymentsClient)}mount(e){var t;return o(this,void 0,void 0,(function*(){if(!this.isGooglePayLoaded())try{yield function(e){const t=i[e];if(t)return t;const n=new Promise(((t,n)=>{const o=document.createElement("script");o.src=e,o.async=!0;const a=()=>{t()},s=()=>{o.removeEventListener("load",a),o.removeEventListener("error",s),delete i[e],o.remove(),n(new Error(`Unable to load script ${e}`))};o.addEventListener("load",a),o.addEventListener("error",s),document.body.appendChild(o)}));return i[e]=n,n}("https://pay.google.com/gp/p/js/pay.js")}catch(e){return void((null===(t=this.config)||void 0===t?void 0:t.onError)?this.config.onError(e):console.error(e))}this.element=e,e&&(this.appendStyles(),this.config&&this.updateElement())}))}unmount(){this.element=void 0}configure(e){let t;return this.config=e,this.oldInvalidationValues&&!this.isClientInvalidated(e)||(t=this.updateElement()),this.oldInvalidationValues=this.getInvalidationValues(e),null!=t?t:Promise.resolve()}createClientOptions(e){const t={environment:e.environment,merchantInfo:this.createMerchantInfo(e)};return(e.onPaymentDataChanged||e.onPaymentAuthorized)&&(t.paymentDataCallbacks={},e.onPaymentDataChanged&&(t.paymentDataCallbacks.onPaymentDataChanged=t=>e.onPaymentDataChanged(t)||{}),e.onPaymentAuthorized&&(t.paymentDataCallbacks.onPaymentAuthorized=t=>e.onPaymentAuthorized(t)||{})),t}createIsReadyToPayRequest(e){const t=e.paymentRequest;return{apiVersion:t.apiVersion,apiVersionMinor:t.apiVersionMinor,allowedPaymentMethods:t.allowedPaymentMethods,existingPaymentMethodRequired:e.existingPaymentMethodRequired}}createLoadPaymentDataRequest(e){return Object.assign(Object.assign({},e.paymentRequest),{merchantInfo:this.createMerchantInfo(e)})}createMerchantInfo(e){const t=Object.assign({},e.paymentRequest.merchantInfo);return t.softwareInfo||(t.softwareInfo={id:this.options.softwareInfoId,version:this.options.softwareInfoVersion}),t}isMounted(){return null!=this.element&&!1!==this.element.isConnected}removeButton(){if(this.element instanceof ShadowRoot||this.element instanceof Element)for(const e of Array.from(this.element.children))"STYLE"!==e.tagName&&e.remove()}updateElement(){return o(this,void 0,void 0,(function*(){if(!this.isMounted())return;const e=this.getElement();if(!this.config)throw new Error("google-pay-button: Missing configuration");this.removeButton();try{this.client=new google.payments.api.PaymentsClient(this.createClientOptions(this.config))}catch(e){return void(this.config.onError?this.config.onError(e):console.error(e))}const t={buttonType:this.config.buttonType,buttonColor:this.config.buttonColor,buttonRadius:this.config.buttonRadius,buttonSizeMode:this.config.buttonSizeMode,buttonLocale:this.config.buttonLocale,onClick:this.handleClick,allowedPaymentMethods:this.config.paymentRequest.allowedPaymentMethods},n=e.getRootNode();n instanceof ShadowRoot&&(t.buttonRootNode=n);const o=this.client.createButton(t);this.setClassName(e,[e.className,"not-ready"]),e.appendChild(o);let i,a=!1;try{i=yield this.client.isReadyToPay(this.createIsReadyToPayRequest(this.config)),a=i.result&&!this.config.existingPaymentMethodRequired||i.result&&i.paymentMethodPresent&&this.config.existingPaymentMethodRequired||!1}catch(e){this.config.onError?this.config.onError(e):console.error(e)}if(this.isMounted()){if(a){try{this.client.prefetchPaymentData(this.createLoadPaymentDataRequest(this.config))}catch(e){console.log("Error with prefetch",e)}this.setClassName(e,(e.className||"").split(" ").filter((e=>e&&"not-ready"!==e)))}if((this.isReadyToPay!==(null==i?void 0:i.result)||this.paymentMethodPresent!==(null==i?void 0:i.paymentMethodPresent))&&(this.isReadyToPay=!!(null==i?void 0:i.result),this.paymentMethodPresent=null==i?void 0:i.paymentMethodPresent,this.config.onReadyToPayChange)){const e={isButtonVisible:a,isReadyToPay:this.isReadyToPay};this.paymentMethodPresent&&(e.paymentMethodPresent=this.paymentMethodPresent),this.config.onReadyToPayChange(e)}}}))}setClassName(e,t){const n=t.filter((e=>e)).join(" ");n?e.className=n:e.removeAttribute("class")}appendStyles(){var e,t,n;if("undefined"==typeof document)return;const o=null===(e=this.element)||void 0===e?void 0:e.getRootNode(),i=`default-google-style-${this.options.cssSelector.replace(/[^\w-]+/g,"")}-${null===(t=this.config)||void 0===t?void 0:t.buttonLocale}`;if(o&&!(null===(n=o.getElementById)||void 0===n?void 0:n.call(o,i))){const e=document.createElement("style");e.id=i,e.type="text/css",e.innerHTML=`\n ${this.options.cssSelector} {\n display: inline-block;\n }\n ${this.options.cssSelector}.not-ready {\n width: 0;\n height: 0;\n overflow: hidden;\n }\n `,o instanceof Document&&o.head?o.head.appendChild(e):o.appendChild(e)}}isClientInvalidated(e){return!this.oldInvalidationValues||this.getInvalidationValues(e).some(((e,t)=>JSON.stringify(e)!==JSON.stringify(this.oldInvalidationValues[t])))}getInvalidationValues(e){var t,n;return[e.environment,e.existingPaymentMethodRequired,!!e.onPaymentDataChanged,!!e.onPaymentAuthorized,e.buttonType,e.buttonColor,e.buttonRadius,e.buttonLocale,e.buttonSizeMode,e.paymentRequest.merchantInfo.merchantId,e.paymentRequest.merchantInfo.merchantName,null===(t=e.paymentRequest.merchantInfo.softwareInfo)||void 0===t?void 0:t.id,null===(n=e.paymentRequest.merchantInfo.softwareInfo)||void 0===n?void 0:n.version,e.paymentRequest.allowedPaymentMethods]}}const s="google-pay-button-container";class r extends t.default.Component{constructor(){super(...arguments),this.manager=new a({cssSelector:`.${s}`,softwareInfoId:"@google-pay/button-react",softwareInfoVersion:"3.1.0"}),this.elementRef=t.default.createRef()}componentDidMount(){return o(this,void 0,void 0,(function*(){const e=this.elementRef.current;e&&(yield this.manager.configure(this.props),yield this.manager.mount(e))}))}componentWillUnmount(){this.manager.unmount()}componentDidUpdate(){this.manager.configure(this.props)}render(){return t.default.createElement("div",{ref:this.elementRef,className:[s,this.props.className].filter((e=>e)).join(" "),style:this.props.style})}}return r}(n(609))},609:e=>{"use strict";e.exports=window.React}},t={};function n(o){var i=t[o];if(void 0!==i)return i.exports;var a=t[o]={exports:{}};return e[o].call(a.exports,a,a.exports,n),a.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e=n(609);const t=window.wp.element,o=window.wp.i18n,i=window.wp.htmlEntities,a=window.wc.wcBlocksRegistry,s=window.wc.wcSettings;var r=n(21),l=n.n(r);const d=(0,s.getSetting)("omise_googlepay_data",{}),c=(0,i.decodeEntities)(d.title)||"No title set",u=n=>{const a=(0,i.decodeEntities)(d.description||""),{data:s}=d,{eventRegistration:r,emitResponse:c,onSubmit:u}=n,{onPaymentSetup:h}=r,[m,y]=(0,t.useState)(null),[p,f]=(0,t.useState)(null);return(0,t.useEffect)((()=>{const e=h((async()=>m?{type:c.responseTypes.SUCCESS,meta:{paymentMethodData:{omise_token:m}}}:p?{type:c.responseTypes.ERROR,message:p}:void 0));return()=>e()}),[c.responseTypes.ERROR,c.responseTypes.SUCCESS,h,m,p]),(0,e.createElement)(e.Fragment,null,a&&(0,e.createElement)("p",null,a),(0,e.createElement)("fieldset",{id:"omise-form-googlepay"},(0,e.createElement)("div",{id:"googlepay-button-container"},(0,e.createElement)(l(),{environment:s.environment,paymentRequest:{apiVersion:s.api_version,apiVersionMinor:s.api_version_minor,allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:s.allowed_auth_methods,allowedCardNetworks:s.allowed_card_networks,billingAddressRequired:s.billing_address_required,billingAddressParameters:{format:"FULL",phoneNumberRequired:s.phone_number_required}},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"omise",gatewayMerchantId:s.public_key}}}],merchantInfo:{merchantId:s.merchant_id},transactionInfo:{totalPriceStatus:s.price_status,currencyCode:s.currency}},onLoadPaymentData:e=>{const{paymentMethodData:t}=e,n={method:"googlepay",data:JSON.stringify(JSON.parse(t.tokenizationData.token))},o=t.info?.billingAddress;o&&(n={...n,billing_name:o.name,billing_city:o.locality,billing_country:o.countryCode,billing_postal_code:o.postalCode,billing_state:o.administrativeArea,billing_street1:o.address1,billing_street2:[o.address2,o.address3].filter((e=>e)).join(" "),billing_phone_number:o.phoneNumber}),Omise.setPublicKey(s.public_key),Omise.createToken("tokenization",n,((e,t)=>{200==e?(f(null),y(t.id),u()):(f(t.message),console.error({response:t}))}))}})),(0,e.createElement)("p",{id:"googlepay-text",className:"omise-secondary-text"},(0,o.__)("You will be prompted to select a credit card stored in your Google Account.","omise"))))};(0,a.registerPaymentMethod)({name:d.name||"",label:(0,e.createElement)((t=>{const{PaymentMethodLabel:n}=t.components;return(0,e.createElement)(n,{text:c})}),null),content:(0,e.createElement)(u,null),edit:(0,e.createElement)(u,null),canMakePayment:()=>!0,ariaLabel:c,supports:{features:d.supports}})})()})(); \ No newline at end of file +(()=>{var e={21:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function o(e,t,n,o){return new(n||(n=Promise))((function(i,a){function s(e){try{l(o.next(e))}catch(e){a(e)}}function r(e){try{l(o.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,r)}l((o=o.apply(e,t||[])).next())}))}let i={};class a{constructor(e){this.handleClick=e=>o(this,void 0,void 0,(function*(){const t=this.config;if(!t)throw new Error("google-pay-button: Missing configuration");const n=this.createLoadPaymentDataRequest(t);try{if(t.onClick&&t.onClick(e),e.defaultPrevented)return;const o=yield this.client.loadPaymentData(n);t.onLoadPaymentData&&t.onLoadPaymentData(o)}catch(e){"CANCELED"===e.statusCode?t.onCancel&&t.onCancel(e):t.onError?t.onError(e):console.error(e)}})),this.options=e}getElement(){return this.element}isGooglePayLoaded(){var e,t;return"google"in(window||n.g)&&!!(null===(t=null===(e=null===google||void 0===google?void 0:google.payments)||void 0===e?void 0:e.api)||void 0===t?void 0:t.PaymentsClient)}mount(e){var t;return o(this,void 0,void 0,(function*(){if(!this.isGooglePayLoaded())try{yield function(e){const t=i[e];if(t)return t;const n=new Promise(((t,n)=>{const o=document.createElement("script");o.src=e,o.async=!0;const a=()=>{t()},s=()=>{o.removeEventListener("load",a),o.removeEventListener("error",s),delete i[e],o.remove(),n(new Error(`Unable to load script ${e}`))};o.addEventListener("load",a),o.addEventListener("error",s),document.body.appendChild(o)}));return i[e]=n,n}("https://pay.google.com/gp/p/js/pay.js")}catch(e){return void((null===(t=this.config)||void 0===t?void 0:t.onError)?this.config.onError(e):console.error(e))}this.element=e,e&&(this.appendStyles(),this.config&&this.updateElement())}))}unmount(){this.element=void 0}configure(e){let t;return this.config=e,this.oldInvalidationValues&&!this.isClientInvalidated(e)||(t=this.updateElement()),this.oldInvalidationValues=this.getInvalidationValues(e),null!=t?t:Promise.resolve()}createClientOptions(e){const t={environment:e.environment,merchantInfo:this.createMerchantInfo(e)};return(e.onPaymentDataChanged||e.onPaymentAuthorized)&&(t.paymentDataCallbacks={},e.onPaymentDataChanged&&(t.paymentDataCallbacks.onPaymentDataChanged=t=>e.onPaymentDataChanged(t)||{}),e.onPaymentAuthorized&&(t.paymentDataCallbacks.onPaymentAuthorized=t=>e.onPaymentAuthorized(t)||{})),t}createIsReadyToPayRequest(e){const t=e.paymentRequest;return{apiVersion:t.apiVersion,apiVersionMinor:t.apiVersionMinor,allowedPaymentMethods:t.allowedPaymentMethods,existingPaymentMethodRequired:e.existingPaymentMethodRequired}}createLoadPaymentDataRequest(e){return Object.assign(Object.assign({},e.paymentRequest),{merchantInfo:this.createMerchantInfo(e)})}createMerchantInfo(e){const t=Object.assign({},e.paymentRequest.merchantInfo);return t.softwareInfo||(t.softwareInfo={id:this.options.softwareInfoId,version:this.options.softwareInfoVersion}),t}isMounted(){return null!=this.element&&!1!==this.element.isConnected}removeButton(){if(this.element instanceof ShadowRoot||this.element instanceof Element)for(const e of Array.from(this.element.children))"STYLE"!==e.tagName&&e.remove()}updateElement(){return o(this,void 0,void 0,(function*(){if(!this.isMounted())return;const e=this.getElement();if(!this.config)throw new Error("google-pay-button: Missing configuration");this.removeButton();try{this.client=new google.payments.api.PaymentsClient(this.createClientOptions(this.config))}catch(e){return void(this.config.onError?this.config.onError(e):console.error(e))}const t={buttonType:this.config.buttonType,buttonColor:this.config.buttonColor,buttonRadius:this.config.buttonRadius,buttonSizeMode:this.config.buttonSizeMode,buttonLocale:this.config.buttonLocale,onClick:this.handleClick,allowedPaymentMethods:this.config.paymentRequest.allowedPaymentMethods},n=e.getRootNode();n instanceof ShadowRoot&&(t.buttonRootNode=n);const o=this.client.createButton(t);this.setClassName(e,[e.className,"not-ready"]),e.appendChild(o);let i,a=!1;try{i=yield this.client.isReadyToPay(this.createIsReadyToPayRequest(this.config)),a=i.result&&!this.config.existingPaymentMethodRequired||i.result&&i.paymentMethodPresent&&this.config.existingPaymentMethodRequired||!1}catch(e){this.config.onError?this.config.onError(e):console.error(e)}if(this.isMounted()){if(a){try{this.client.prefetchPaymentData(this.createLoadPaymentDataRequest(this.config))}catch(e){console.log("Error with prefetch",e)}this.setClassName(e,(e.className||"").split(" ").filter((e=>e&&"not-ready"!==e)))}if((this.isReadyToPay!==(null==i?void 0:i.result)||this.paymentMethodPresent!==(null==i?void 0:i.paymentMethodPresent))&&(this.isReadyToPay=!!(null==i?void 0:i.result),this.paymentMethodPresent=null==i?void 0:i.paymentMethodPresent,this.config.onReadyToPayChange)){const e={isButtonVisible:a,isReadyToPay:this.isReadyToPay};this.paymentMethodPresent&&(e.paymentMethodPresent=this.paymentMethodPresent),this.config.onReadyToPayChange(e)}}}))}setClassName(e,t){const n=t.filter((e=>e)).join(" ");n?e.className=n:e.removeAttribute("class")}appendStyles(){var e,t,n;if("undefined"==typeof document)return;const o=null===(e=this.element)||void 0===e?void 0:e.getRootNode(),i=`default-google-style-${this.options.cssSelector.replace(/[^\w-]+/g,"")}-${null===(t=this.config)||void 0===t?void 0:t.buttonLocale}`;if(o&&!(null===(n=o.getElementById)||void 0===n?void 0:n.call(o,i))){const e=document.createElement("style");e.id=i,e.type="text/css",e.innerHTML=`\n ${this.options.cssSelector} {\n display: inline-block;\n }\n ${this.options.cssSelector}.not-ready {\n width: 0;\n height: 0;\n overflow: hidden;\n }\n `,o instanceof Document&&o.head?o.head.appendChild(e):o.appendChild(e)}}isClientInvalidated(e){return!this.oldInvalidationValues||this.getInvalidationValues(e).some(((e,t)=>JSON.stringify(e)!==JSON.stringify(this.oldInvalidationValues[t])))}getInvalidationValues(e){var t,n;return[e.environment,e.existingPaymentMethodRequired,!!e.onPaymentDataChanged,!!e.onPaymentAuthorized,e.buttonType,e.buttonColor,e.buttonRadius,e.buttonLocale,e.buttonSizeMode,e.paymentRequest.merchantInfo.merchantId,e.paymentRequest.merchantInfo.merchantName,null===(t=e.paymentRequest.merchantInfo.softwareInfo)||void 0===t?void 0:t.id,null===(n=e.paymentRequest.merchantInfo.softwareInfo)||void 0===n?void 0:n.version,e.paymentRequest.allowedPaymentMethods]}}const s="google-pay-button-container";class r extends t.default.Component{constructor(){super(...arguments),this.manager=new a({cssSelector:`.${s}`,softwareInfoId:"@google-pay/button-react",softwareInfoVersion:"3.1.0"}),this.elementRef=t.default.createRef()}componentDidMount(){return o(this,void 0,void 0,(function*(){const e=this.elementRef.current;e&&(yield this.manager.configure(this.props),yield this.manager.mount(e))}))}componentWillUnmount(){this.manager.unmount()}componentDidUpdate(){this.manager.configure(this.props)}render(){return t.default.createElement("div",{ref:this.elementRef,className:[s,this.props.className].filter((e=>e)).join(" "),style:this.props.style})}}return r}(n(609))},609:e=>{"use strict";e.exports=window.React}},t={};function n(o){var i=t[o];if(void 0!==i)return i.exports;var a=t[o]={exports:{}};return e[o].call(a.exports,a,a.exports,n),a.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e=n(609);const t=window.wp.element,o=window.wp.i18n,i=window.wp.htmlEntities,a=window.wc.wcBlocksRegistry,s=window.wc.wcSettings;var r=n(21),l=n.n(r);const d=(0,s.getSetting)("omise_googlepay_data",{}),c=(0,i.decodeEntities)(d.title)||"No title set",u=n=>{const a=(0,i.decodeEntities)(d.description||""),{data:s}=d,{eventRegistration:r,emitResponse:c,onSubmit:u}=n,{onPaymentSetup:h}=r,[m,y]=(0,t.useState)(null),[p,f]=(0,t.useState)(null);return(0,t.useEffect)((()=>{const e=h((async()=>m?{type:c.responseTypes.SUCCESS,meta:{paymentMethodData:{omise_token:m}}}:p?{type:c.responseTypes.ERROR,message:p}:void 0));return()=>e()}),[c.responseTypes.ERROR,c.responseTypes.SUCCESS,h,m,p]),(0,e.createElement)(e.Fragment,null,a&&(0,e.createElement)("p",null,a),(0,e.createElement)("fieldset",{id:"omise-form-googlepay"},(0,e.createElement)("div",{id:"googlepay-button-container"},(0,e.createElement)(l(),{environment:s.environment,paymentRequest:{apiVersion:s.api_version,apiVersionMinor:s.api_version_minor,allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:s.allowed_auth_methods,allowedCardNetworks:s.allowed_card_networks,billingAddressRequired:s.billing_address_required,billingAddressParameters:{format:"FULL",phoneNumberRequired:s.phone_number_required}},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"omise",gatewayMerchantId:s.public_key}}}],merchantInfo:{merchantId:s.merchant_id},transactionInfo:{totalPriceStatus:s.price_status,currencyCode:s.currency}},onLoadPaymentData:e=>{const{paymentMethodData:t}=e,n={method:"googlepay",data:JSON.stringify(JSON.parse(t.tokenizationData.token))},o=t.info?.billingAddress;o&&(n={...n,billing_name:o.name,billing_city:o.locality,billing_country:o.countryCode,billing_postal_code:o.postalCode,billing_state:o.administrativeArea,billing_street1:o.address1,billing_street2:[o.address2,o.address3].filter((e=>e)).join(" "),billing_phone_number:o.phoneNumber}),Omise.setPublicKey(s.public_key),Omise.createToken("tokenization",n,((e,t)=>{200==e?(f(null),y(t.id),u()):(f(t.message),console.error({response:t}))}))}})),(0,e.createElement)("p",{id:"googlepay-text",className:"omise-secondary-text"},(0,o.__)("You will be prompted to select a credit card stored in your Google Account.","omise"))))};(0,a.registerPaymentMethod)({name:d.name||"",label:(0,e.createElement)((t=>{const{PaymentMethodLabel:n}=t.components;return(0,e.createElement)(n,{text:c})}),null),content:(0,e.createElement)(u,null),edit:(0,e.createElement)(u,null),canMakePayment:()=>d.is_active,ariaLabel:c,supports:{features:d.supports}})})()})(); \ No newline at end of file diff --git a/includes/blocks/assets/js/build/omise_installment.asset.php b/includes/blocks/assets/js/build/omise_installment.asset.php index 686cafac..a14ba683 100644 --- a/includes/blocks/assets/js/build/omise_installment.asset.php +++ b/includes/blocks/assets/js/build/omise_installment.asset.php @@ -1 +1 @@ - array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '0870d052051799446a862b643aaa00a1'); \ No newline at end of file + array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => 'd2a1602f618f3b67fe3f74ab703c2398'); \ No newline at end of file diff --git a/includes/blocks/assets/js/build/omise_installment.js b/includes/blocks/assets/js/build/omise_installment.js index 4ad69253..598eb37a 100644 --- a/includes/blocks/assets/js/build/omise_installment.js +++ b/includes/blocks/assets/js/build/omise_installment.js @@ -1 +1 @@ -(()=>{"use strict";const e=window.React,t=window.wp.element,n=window.wp.i18n,a=window.wp.htmlEntities,l=window.wc.wcBlocksRegistry,r=(0,window.wc.wcSettings.getSetting)("omise_installment_data",{}),s=(0,a.decodeEntities)(r.title)||"No title set",m=l=>{const{eventRegistration:s,emitResponse:m}=l,{onPaymentSetup:i}=s,c=(0,a.decodeEntities)(r.description||""),{installment_backends:o,is_zero_interest:u}=r.data,p=(0,n.__)("Purchase Amount is lower than the monthly minimum payment amount.","omise"),_=(0,t.useRef)(null),d=(0,t.useRef)(null),E=e=>{_.current=e.target.value,d.current=null},y=e=>{d.current=e.target.value};return(0,t.useEffect)((()=>{const e=i((async()=>{if(!_.current||!d.current)return{type:m.responseTypes.ERROR,message:"Select a bank and term"};try{return{type:m.responseTypes.SUCCESS,meta:{paymentMethodData:{source:_.current,[`${_.current}_installment_terms`]:d.current}}}}catch(e){return{type:m.responseTypes.ERROR,message:e.message}}}));return()=>e()}),[i]),(0,e.createElement)(e.Fragment,null,c&&(0,e.createElement)("p",null,c),0==o.length?(0,e.createElement)("p",null,p):(0,e.createElement)("fieldset",{id:"omise-form-installment"},(0,e.createElement)("ul",{className:"omise-banks-list"},o.map(((t,a)=>(0,e.createElement)("li",{key:t._id+a,className:"item"},(0,e.createElement)("input",{id:t._id,type:"radio",name:"source[type]",value:t._id,onChange:E}),(0,e.createElement)("label",{htmlFor:t._id},(0,e.createElement)("div",{className:`bank-logo ${t.provider_code}`}),(0,e.createElement)("div",{className:"bank-label"},(0,e.createElement)("span",{className:"title"},t.provider_name),(0,e.createElement)("br",null),(0,e.createElement)("select",{id:`${t._id}_installment_terms`,name:`${t._id}_installment_terms`,className:"installment-term-select-box",onChange:y},(0,e.createElement)("option",null,"Select term"),t.available_plans.map(((t,a)=>(0,e.createElement)("option",{key:`${t.term_length}_${t.monthly_amount}_${a}`,value:t.term_length},(0,n.__)(`${t.term_length} months`,"omise"),(0,e.createElement)(e.Fragment,null," "),"(",(0,n.__)(`${t.monthly_amount} / months`,"omise"),")")))),u&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("br",null),(0,e.createElement)("span",{className:"omise-installment-interest-rate"},(0,n.__)(`( interest ${t.interest_rate} )`,"omise")))))))))))};(0,l.registerPaymentMethod)({name:r.name||"",label:(0,e.createElement)((t=>{const{PaymentMethodLabel:n}=t.components;return(0,e.createElement)(n,{text:s})}),null),content:(0,e.createElement)(m,null),edit:(0,e.createElement)(m,null),canMakePayment:()=>!0,ariaLabel:s,supports:{features:r.supports}})})(); \ No newline at end of file +(()=>{"use strict";const e=window.React,t=window.wp.element,n=window.wp.i18n,a=window.wp.htmlEntities,l=window.wc.wcBlocksRegistry,r=(0,window.wc.wcSettings.getSetting)("omise_installment_data",{}),s=(0,a.decodeEntities)(r.title)||"No title set",m=l=>{const{eventRegistration:s,emitResponse:m}=l,{onPaymentSetup:i}=s,c=(0,a.decodeEntities)(r.description||""),{installment_backends:o,is_zero_interest:u}=r.data,_=(0,n.__)("Purchase Amount is lower than the monthly minimum payment amount.","omise"),p=(0,t.useRef)(null),d=(0,t.useRef)(null),E=e=>{p.current=e.target.value,d.current=null},y=e=>{d.current=e.target.value};return(0,t.useEffect)((()=>{const e=i((async()=>{if(!p.current||!d.current)return{type:m.responseTypes.ERROR,message:"Select a bank and term"};try{return{type:m.responseTypes.SUCCESS,meta:{paymentMethodData:{source:p.current,[`${p.current}_installment_terms`]:d.current}}}}catch(e){return{type:m.responseTypes.ERROR,message:e.message}}}));return()=>e()}),[i]),(0,e.createElement)(e.Fragment,null,c&&(0,e.createElement)("p",null,c),0==o.length?(0,e.createElement)("p",null,_):(0,e.createElement)("fieldset",{id:"omise-form-installment"},(0,e.createElement)("ul",{className:"omise-banks-list"},o.map(((t,a)=>(0,e.createElement)("li",{key:t._id+a,className:"item"},(0,e.createElement)("input",{id:t._id,type:"radio",name:"source[type]",value:t._id,onChange:E}),(0,e.createElement)("label",{htmlFor:t._id},(0,e.createElement)("div",{className:`bank-logo ${t.provider_code}`}),(0,e.createElement)("div",{className:"bank-label"},(0,e.createElement)("span",{className:"title"},t.provider_name),(0,e.createElement)("br",null),(0,e.createElement)("select",{id:`${t._id}_installment_terms`,name:`${t._id}_installment_terms`,className:"installment-term-select-box",onChange:y},(0,e.createElement)("option",null,"Select term"),t.available_plans.map(((t,a)=>(0,e.createElement)("option",{key:`${t.term_length}_${t.monthly_amount}_${a}`,value:t.term_length},(0,n.__)(`${t.term_length} months`,"omise"),(0,e.createElement)(e.Fragment,null," "),"(",(0,n.__)(`${t.monthly_amount} / months`,"omise"),")")))),u&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("br",null),(0,e.createElement)("span",{className:"omise-installment-interest-rate"},(0,n.__)(`( interest ${t.interest_rate} )`,"omise")))))))))))};(0,l.registerPaymentMethod)({name:r.name||"",label:(0,e.createElement)((t=>{const{PaymentMethodLabel:n}=t.components;return(0,e.createElement)(n,{text:s})}),null),content:(0,e.createElement)(m,null),edit:(0,e.createElement)(m,null),canMakePayment:()=>r.is_active,ariaLabel:s,supports:{features:r.supports}})})(); \ No newline at end of file diff --git a/includes/blocks/assets/js/build/omise_internetbanking.asset.php b/includes/blocks/assets/js/build/omise_internetbanking.asset.php index c86e6b44..83aa7b4c 100644 --- a/includes/blocks/assets/js/build/omise_internetbanking.asset.php +++ b/includes/blocks/assets/js/build/omise_internetbanking.asset.php @@ -1 +1 @@ - array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '5a7c1ca9a881b022e773ff44a4c3f27c'); \ No newline at end of file + array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => 'c801bb1c9f7a7c3d6f9048be28066278'); \ No newline at end of file diff --git a/includes/blocks/assets/js/build/omise_internetbanking.js b/includes/blocks/assets/js/build/omise_internetbanking.js index 5fc44ba5..3d845156 100644 --- a/includes/blocks/assets/js/build/omise_internetbanking.js +++ b/includes/blocks/assets/js/build/omise_internetbanking.js @@ -1 +1 @@ -(()=>{"use strict";const e=window.React,t=window.wp.element,n=window.wp.i18n,a=window.wp.htmlEntities,s=window.wc.wcBlocksRegistry,l=(0,window.wc.wcSettings.getSetting)("omise_internetbanking_data",{}),i=(0,a.decodeEntities)(l.title)||"No title set",r=s=>{const{eventRegistration:i,emitResponse:r}=s,{onPaymentSetup:m}=i,o=(0,a.decodeEntities)(l.description||""),[c,b]=(0,t.useState)(null),p=e=>{b(e.target.value)};return(0,t.useEffect)((()=>{const e=m((async()=>{if(!c)return{type:r.responseTypes.ERROR,message:"Select a bank"};try{return{type:r.responseTypes.SUCCESS,meta:{paymentMethodData:{"omise-offsite":c}}}}catch(e){return{type:r.responseTypes.ERROR,message:e.message}}}));return()=>e()}),[r.responseTypes.ERROR,r.responseTypes.SUCCESS,m,c]),(0,e.createElement)(e.Fragment,null,o&&(0,e.createElement)("p",null,o),(0,e.createElement)("fieldset",{id:"omise-form-internetbanking"},(0,e.createElement)("ul",{className:"omise-banks-list"},(0,e.createElement)("li",{className:"item"},(0,e.createElement)("input",{id:"internet_banking_bay",type:"radio",name:"omise-offsite",value:"internet_banking_bay",onChange:p}),(0,e.createElement)("label",{htmlFor:"internet_banking_bay"},(0,e.createElement)("div",{className:"bank-logo bay"}),(0,e.createElement)("div",{className:"bank-label"},(0,e.createElement)("span",{className:"title"},(0,n.__)("Krungsri Bank","omise")),(0,e.createElement)("br",null),(0,e.createElement)("span",{className:"omise-secondary-text"},(0,n.__)("Fee: 15 THB (same zone), 15 THB (out zone)","omise"))))),(0,e.createElement)("li",{className:"item"},(0,e.createElement)("input",{id:"internet_banking_bbl",type:"radio",name:"omise-offsite",value:"internet_banking_bbl",onChange:p}),(0,e.createElement)("label",{htmlFor:"internet_banking_bbl"},(0,e.createElement)("div",{className:"bank-logo bbl"}),(0,e.createElement)("div",{className:"bank-label"},(0,e.createElement)("span",{className:"title"},(0,n.__)("Bangkok Bank","omise")),(0,e.createElement)("br",null),(0,e.createElement)("span",{className:"omise-secondary-text"},(0,n.__)("Fee: 10 THB (same zone), 20 THB (out zone)","omise"))))))))};(0,s.registerPaymentMethod)({name:l.name||"",label:(0,e.createElement)((t=>{const{PaymentMethodLabel:n}=t.components;return(0,e.createElement)(n,{text:i})}),null),content:(0,e.createElement)(r,null),edit:(0,e.createElement)(r,null),canMakePayment:()=>!0,ariaLabel:i,supports:{features:l.supports}})})(); \ No newline at end of file +(()=>{"use strict";const e=window.React,t=window.wp.element,n=window.wp.i18n,a=window.wp.htmlEntities,s=window.wc.wcBlocksRegistry,l=(0,window.wc.wcSettings.getSetting)("omise_internetbanking_data",{}),i=(0,a.decodeEntities)(l.title)||"No title set",r=s=>{const{eventRegistration:i,emitResponse:r}=s,{onPaymentSetup:m}=i,o=(0,a.decodeEntities)(l.description||""),[c,b]=(0,t.useState)(null),p=e=>{b(e.target.value)};return(0,t.useEffect)((()=>{const e=m((async()=>{if(!c)return{type:r.responseTypes.ERROR,message:"Select a bank"};try{return{type:r.responseTypes.SUCCESS,meta:{paymentMethodData:{"omise-offsite":c}}}}catch(e){return{type:r.responseTypes.ERROR,message:e.message}}}));return()=>e()}),[r.responseTypes.ERROR,r.responseTypes.SUCCESS,m,c]),(0,e.createElement)(e.Fragment,null,o&&(0,e.createElement)("p",null,o),(0,e.createElement)("fieldset",{id:"omise-form-internetbanking"},(0,e.createElement)("ul",{className:"omise-banks-list"},(0,e.createElement)("li",{className:"item"},(0,e.createElement)("input",{id:"internet_banking_bay",type:"radio",name:"omise-offsite",value:"internet_banking_bay",onChange:p}),(0,e.createElement)("label",{htmlFor:"internet_banking_bay"},(0,e.createElement)("div",{className:"bank-logo bay"}),(0,e.createElement)("div",{className:"bank-label"},(0,e.createElement)("span",{className:"title"},(0,n.__)("Krungsri Bank","omise")),(0,e.createElement)("br",null),(0,e.createElement)("span",{className:"omise-secondary-text"},(0,n.__)("Fee: 15 THB (same zone), 15 THB (out zone)","omise"))))),(0,e.createElement)("li",{className:"item"},(0,e.createElement)("input",{id:"internet_banking_bbl",type:"radio",name:"omise-offsite",value:"internet_banking_bbl",onChange:p}),(0,e.createElement)("label",{htmlFor:"internet_banking_bbl"},(0,e.createElement)("div",{className:"bank-logo bbl"}),(0,e.createElement)("div",{className:"bank-label"},(0,e.createElement)("span",{className:"title"},(0,n.__)("Bangkok Bank","omise")),(0,e.createElement)("br",null),(0,e.createElement)("span",{className:"omise-secondary-text"},(0,n.__)("Fee: 10 THB (same zone), 20 THB (out zone)","omise"))))))))};(0,s.registerPaymentMethod)({name:l.name||"",label:(0,e.createElement)((t=>{const{PaymentMethodLabel:n}=t.components;return(0,e.createElement)(n,{text:i})}),null),content:(0,e.createElement)(r,null),edit:(0,e.createElement)(r,null),canMakePayment:()=>l.is_active,ariaLabel:i,supports:{features:l.supports}})})(); \ No newline at end of file diff --git a/includes/blocks/assets/js/build/omise_truemoney.asset.php b/includes/blocks/assets/js/build/omise_truemoney.asset.php index 82fd43bc..db6c507e 100644 --- a/includes/blocks/assets/js/build/omise_truemoney.asset.php +++ b/includes/blocks/assets/js/build/omise_truemoney.asset.php @@ -1 +1 @@ - array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '1f611dbfd6dc2d235ba16ce16a77cf92'); \ No newline at end of file + array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '37bff72b2040207c7c2e0297db0b9219'); \ No newline at end of file diff --git a/includes/blocks/assets/js/build/omise_truemoney.js b/includes/blocks/assets/js/build/omise_truemoney.js index fd531f07..e1037e3a 100644 --- a/includes/blocks/assets/js/build/omise_truemoney.js +++ b/includes/blocks/assets/js/build/omise_truemoney.js @@ -1 +1 @@ -(()=>{"use strict";const e=window.React,t=window.wp.element,n=window.wp.i18n,o=window.wp.htmlEntities,s=window.wc.wcBlocksRegistry,a=(0,window.wc.wcSettings.getSetting)("omise_truemoney_data",{}),m=(0,o.decodeEntities)(a.title)||"No title set",r=({content:s,...m})=>{const{eventRegistration:r,emitResponse:l}=m,{onPaymentSetup:i}=r,p=(0,o.decodeEntities)(a.description.trim()||""),{is_wallet:c}=a.data,[u,d]=(0,t.useState)(!1),[_,w]=(0,t.useState)(!0),[E,h]=(0,t.useState)("");return(0,t.useEffect)((()=>{const e=i((async()=>{if(!_&&0===E.length)return{type:l.responseTypes.ERROR,message:"Enter a phone number"};try{return{type:l.responseTypes.SUCCESS,meta:{paymentMethodData:{omise_phone_number_default:(_?1:0).toString(),omise_phone_number:E}}}}catch(e){return{type:l.responseTypes.ERROR,message:e.message}}}));return()=>e()}),[i,l.responseTypes.ERROR,l.responseTypes.SUCCESS,_,E]),(0,e.createElement)(e.Fragment,null,p&&(0,e.createElement)("p",null,p),c&&(0,e.createElement)("fieldset",{id:"omise-form-truemoney"},(0,n.__)("TrueMoney phone number","omise"),(0,e.createElement)("br",null),(0,e.createElement)("p",{id:"omise_phone_number_default_field",className:"form-row form-row-wide omise-label-inline"},(0,e.createElement)("input",{id:"omise_phone_number_default",type:"checkbox",name:"omise_phone_number_default",value:_,defaultChecked:!0,onChange:e=>{w(!_),d(!u),_&&h("")}}),(0,e.createElement)("label",{htmlFor:"omise_phone_number_default"},(0,n.__)("Same as Billing Detail","omise"))),(0,e.createElement)("p",{id:"omise_phone_number_field",className:"form-row form-row-wide",style:{display:u?"block":"none"}},(0,e.createElement)("span",{className:"woocommerce-input-wrapper"},(0,e.createElement)("input",{id:"omise_phone_number",className:"input-text",name:"omise_phone_number",type:"tel",autoComplete:"off",onChange:e=>{h(e.target.value)}}))),(0,e.createElement)("p",{className:"omise-secondary-text"},(0,n.__)("One-Time Password (OTP) will be sent to the phone number above","omise"))))};(0,s.registerPaymentMethod)({name:a.name||"",label:(0,e.createElement)((t=>{const{PaymentMethodLabel:n}=t.components;return(0,e.createElement)(n,{text:m})}),null),content:(0,e.createElement)(r,null),edit:(0,e.createElement)(r,null),canMakePayment:()=>!0,ariaLabel:m,supports:{features:a.supports}})})(); \ No newline at end of file +(()=>{"use strict";const e=window.React,t=window.wp.element,n=window.wp.i18n,o=window.wp.htmlEntities,s=window.wc.wcBlocksRegistry,a=(0,window.wc.wcSettings.getSetting)("omise_truemoney_data",{}),m=(0,o.decodeEntities)(a.title)||"No title set",r=({content:s,...m})=>{const{eventRegistration:r,emitResponse:i}=m,{onPaymentSetup:l}=r,p=(0,o.decodeEntities)(a.description.trim()||""),{is_wallet:c}=a.data,[u,d]=(0,t.useState)(!1),[_,w]=(0,t.useState)(!0),[E,h]=(0,t.useState)("");return(0,t.useEffect)((()=>{const e=l((async()=>{if(!_&&0===E.length)return{type:i.responseTypes.ERROR,message:"Enter a phone number"};try{return{type:i.responseTypes.SUCCESS,meta:{paymentMethodData:{omise_phone_number_default:(_?1:0).toString(),omise_phone_number:E}}}}catch(e){return{type:i.responseTypes.ERROR,message:e.message}}}));return()=>e()}),[l,i.responseTypes.ERROR,i.responseTypes.SUCCESS,_,E]),(0,e.createElement)(e.Fragment,null,p&&(0,e.createElement)("p",null,p),c&&(0,e.createElement)("fieldset",{id:"omise-form-truemoney"},(0,n.__)("TrueMoney phone number","omise"),(0,e.createElement)("br",null),(0,e.createElement)("p",{id:"omise_phone_number_default_field",className:"form-row form-row-wide omise-label-inline"},(0,e.createElement)("input",{id:"omise_phone_number_default",type:"checkbox",name:"omise_phone_number_default",value:_,defaultChecked:!0,onChange:e=>{w(!_),d(!u),_&&h("")}}),(0,e.createElement)("label",{htmlFor:"omise_phone_number_default"},(0,n.__)("Same as Billing Detail","omise"))),(0,e.createElement)("p",{id:"omise_phone_number_field",className:"form-row form-row-wide",style:{display:u?"block":"none"}},(0,e.createElement)("span",{className:"woocommerce-input-wrapper"},(0,e.createElement)("input",{id:"omise_phone_number",className:"input-text",name:"omise_phone_number",type:"tel",autoComplete:"off",onChange:e=>{h(e.target.value)}}))),(0,e.createElement)("p",{className:"omise-secondary-text"},(0,n.__)("One-Time Password (OTP) will be sent to the phone number above","omise"))))};(0,s.registerPaymentMethod)({name:a.name||"",label:(0,e.createElement)((t=>{const{PaymentMethodLabel:n}=t.components;return(0,e.createElement)(n,{text:m})}),null),content:(0,e.createElement)(r,null),edit:(0,e.createElement)(r,null),canMakePayment:()=>a.is_active,ariaLabel:m,supports:{features:a.supports}})})(); \ No newline at end of file diff --git a/includes/blocks/assets/js/common.js b/includes/blocks/assets/js/common.js index 0a627f92..261584b3 100644 --- a/includes/blocks/assets/js/common.js +++ b/includes/blocks/assets/js/common.js @@ -17,7 +17,7 @@ export function registerOmisePaymentMethod({settings, label}) { label: ) -} \ No newline at end of file +} diff --git a/includes/blocks/assets/js/omise-atome.js b/includes/blocks/assets/js/omise-atome.js index 4bb8e9cb..9a08d12d 100644 --- a/includes/blocks/assets/js/omise-atome.js +++ b/includes/blocks/assets/js/omise-atome.js @@ -111,7 +111,7 @@ registerPaymentMethod( { label: