diff --git a/CHANGELOG.md b/CHANGELOG.md index e72cd630..a46313c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # CHANGELOG +## [v6.0.1 _(Nov 12, 2024)_](https://github.com/omise/omise-woocommerce/releases/tag/v6.0.1) +- Resolve issue of payment failing on installment when total amount is updated after selecting payment. (PR: [#485](https://github.com/omise/omise-woocommerce/pull/485)) +- Fix Duitnow bank list issue. (PR: [#486](https://github.com/omise/omise-woocommerce/pull/486)) +- Resolve the issue where no payment methods are displayed when the browser's back button is clicked from an issuer page. (PR: [#487](https://github.com/omise/omise-woocommerce/pull/487)) + ## [v6.0.0 _(Nov 5, 2024)_](https://github.com/omise/omise-woocommerce/releases/tag/v6.0.0) - Support WooCommerce block. (PR: [#470](https://github.com/omise/omise-woocommerce/pull/470)) - Fix the loading issue in WooCommerce block cart. (PR: [#477](https://github.com/omise/omise-woocommerce/pull/477)) diff --git a/assets/javascripts/omise-payment-form-handler.js b/assets/javascripts/omise-payment-form-handler.js index 317537a2..db5a3970 100755 --- a/assets/javascripts/omise-payment-form-handler.js +++ b/assets/javascripts/omise-payment-form-handler.js @@ -257,7 +257,7 @@ showOmiseInstallmentForm({ element: omiseInstallmentElement, publicKey: omise_installment_params.key, - amount: omise_installment_params.amount, + amount: OMISE_UPDATED_CART_AMOUNT, locale: LOCALE, onSuccess: handleCreateOrder, onError: (error) => { 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 28f44fb9..aa42cd09 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' => '9895ac689bce188c4a74717ce7c149c5'); \ No newline at end of file + array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => 'b1a7ad893b10317f131d580cebf99812'); \ 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 02028bd0..de7d53fc 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:()=>s.is_active,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 --"),Object.values(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_installment.asset.php b/includes/blocks/assets/js/build/omise_installment.asset.php index 521aa0a0..5d88bbbf 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' => 'c95a8877d63c5c3bb2fda93273b0a81a'); \ No newline at end of file + array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => 'e2436da6ade36f0dc6835eb771337040'); \ 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 1c956852..84f607e0 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,s=window.wp.htmlEntities,a=window.wc.wcBlocksRegistry,l=(0,window.wc.wcSettings.getSetting)("omise_installment_data",{}),o=(0,s.decodeEntities)(l.title)||"No title set",r=a=>{const{eventRegistration:o,emitResponse:r}=a,{onPaymentSetup:c,onCheckoutValidation:i,onCheckoutFail:m}=o,u=(0,s.decodeEntities)(l.description||""),{installments_enabled:d,total_amount:w,public_key:p}=l.data,E=(0,n.__)("Purchase Amount is lower than the monthly minimum payment amount.","omise"),y=(0,t.useRef)(null),f=(0,t.useRef)(null),h=(0,t.useRef)(null),R=()=>{if(d){let e=l.locale.toLowerCase();e=["en","th","ja"].includes(e)?e:"en",showOmiseInstallmentForm({element:y.current,publicKey:p,amount:w,locale:e,onSuccess:e=>{f.current=e},onError:e=>{h.current=e}})}};return(0,t.useEffect)((()=>{R()}),[d]),(0,t.useEffect)((()=>i((()=>(OmiseCard.requestCardToken(),!0)))),[i]),(0,t.useEffect)((()=>m((()=>(f.current=null,R(),!0)))),[m]),(0,t.useEffect)((()=>{const e=c((async()=>await new Promise(((e,t)=>{const n=setInterval((()=>{if(f.current){clearInterval(n);try{const t={type:r.responseTypes.SUCCESS,meta:{paymentMethodData:{omise_source:f.current.source,omise_token:f.current.token}}};e(t)}catch(e){clearInterval(n);const s={type:r.responseTypes.ERROR,message:e.message};t(s)}}}),1e3)}))));return()=>e()}),[c]),(0,e.createElement)(e.Fragment,null,u&&(0,e.createElement)("p",null,u),d?(0,e.createElement)("div",{ref:y,id:"omise-installment",style:{width:"100%",maxWidth:"400px"}}):(0,e.createElement)("p",null,E))};(0,a.registerPaymentMethod)({name:l.name||"",label:(0,e.createElement)((t=>{const{PaymentMethodLabel:n}=t.components;return(0,e.createElement)(n,{text:o})}),null),content:(0,e.createElement)(r,null),edit:(0,e.createElement)(r,null),canMakePayment:()=>l.is_active,ariaLabel:o,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,r=(0,window.wc.wcSettings.getSetting)("omise_installment_data",{}),l=(0,a.decodeEntities)(r.title)||"No title set",{select:o,subscribe:c}=window.wp.data,i=window.wc.wcBlocksData.CART_STORE_KEY,u=s=>{const{eventRegistration:l,emitResponse:u}=s,{onPaymentSetup:m,onCheckoutValidation:w,onCheckoutFail:d}=l,p=(0,a.decodeEntities)(r.description||""),{installments_enabled:E,total_amount:f,public_key:y}=r.data,h=(0,n.__)("Purchase Amount is lower than the monthly minimum payment amount.","omise"),_=(0,t.useRef)(null),R=(0,t.useRef)(null),g=(0,t.useRef)(null),C=(0,t.useRef)(null),k=()=>{if(E){const e=o(i).getCartData();C.current=e.totals.total_price;let t=r.locale.toLowerCase();t=["en","th","ja"].includes(t)?t:"en",_.current.innerHTML="",showOmiseInstallmentForm({element:_.current,publicKey:y,amount:C.current,locale:t,onSuccess:e=>{R.current=e},onError:e=>{g.current=e}})}},b=()=>{const e=o(i).getCartData();C.current=e.totals.total_price,k()};return(0,t.useEffect)((()=>c(b,i)),[i]),(0,t.useEffect)((()=>{k()}),[E]),(0,t.useEffect)((()=>w((()=>(OmiseCard.requestCardToken(),!0)))),[w]),(0,t.useEffect)((()=>d((()=>(R.current=null,k(),!0)))),[d]),(0,t.useEffect)((()=>{const e=m((async()=>await new Promise(((e,t)=>{const n=setInterval((()=>{if(R.current){clearInterval(n);try{const t={type:u.responseTypes.SUCCESS,meta:{paymentMethodData:{omise_source:R.current.source,omise_token:R.current.token}}};e(t)}catch(e){clearInterval(n);const a={type:u.responseTypes.ERROR,message:e.message};t(a)}}}),1e3)}))));return()=>e()}),[m]),(0,e.createElement)(e.Fragment,null,p&&(0,e.createElement)("p",null,p),E?(0,e.createElement)("div",{ref:_,id:"omise-installment",style:{width:"100%",maxWidth:"400px"}}):(0,e.createElement)("p",null,h))};(0,s.registerPaymentMethod)({name:r.name||"",label:(0,e.createElement)((t=>{const{PaymentMethodLabel:n}=t.components;return(0,e.createElement)(n,{text:l})}),null),content:(0,e.createElement)(u,null),edit:(0,e.createElement)(u,null),canMakePayment:()=>r.is_active,ariaLabel:l,supports:{features:r.supports}})})(); \ No newline at end of file diff --git a/includes/blocks/assets/js/omise-duitnow-obw.js b/includes/blocks/assets/js/omise-duitnow-obw.js index 810ad9ae..f3bbad51 100644 --- a/includes/blocks/assets/js/omise-duitnow-obw.js +++ b/includes/blocks/assets/js/omise-duitnow-obw.js @@ -63,7 +63,7 @@ const DuitNowOBWPaymentMethod = (props) => { > { - banks.map((bank) => ( + Object.values(banks).map((bank) => (