From 0ff082173d1b67ad2b0dad9ae99ef09dc29ab9bc Mon Sep 17 00:00:00 2001 From: Sebastian Pape Date: Tue, 4 Oct 2022 12:20:27 +0200 Subject: [PATCH] fix checkout uuid match --- dist/checkout.js | 2 +- includes/class-depay-wc-payments-gateway.php | 2 +- src/checkout.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/checkout.js b/dist/checkout.js index 8c73d2d..7784cb3 100644 --- a/dist/checkout.js +++ b/dist/checkout.js @@ -1 +1 @@ -!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";window.addEventListener("hashchange",(async()=>{if(window.location.hash.startsWith("#wc-depay-checkout-")){let e=window.location.hash.match(/wc-depay-checkout-(.*?)$/)[1],t=JSON.parse(await wp.apiRequest({path:`/depay/wc/checkouts/${e}`}));DePayWidgets.Payment({accept:t,fee:{amount:"1.5%",receiver:"0x9Db58B260EfAa2d6a94bEb7E219d073dF51cc7Bb"},closed:()=>{window.jQuery("form.woocommerce-checkout").removeClass("processing").unblock()},track:{method:t=>new Promise(((a,c)=>{wp.apiRequest({path:`/depay/wc/checkouts/${e}/track`,method:"POST",data:t}).done((e=>a({status:200}))).fail(((e,t)=>c(t)))})),poll:{method:()=>fetch("/index.php?rest_route=/depay/wc/release",{method:"POST",body:JSON.stringify({checkout_id:e}),headers:{"Content-Type":"application/json"}})}}})}}))})); +!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";window.addEventListener("hashchange",(async()=>{if(window.location.hash.startsWith("#wc-depay-checkout-")){let e=window.location.hash.match(/wc-depay-checkout-(.*?)@/)[1],t=JSON.parse(await wp.apiRequest({path:`/depay/wc/checkouts/${e}`}));DePayWidgets.Payment({accept:t,fee:{amount:"1.5%",receiver:"0x9Db58B260EfAa2d6a94bEb7E219d073dF51cc7Bb"},closed:()=>{window.jQuery("form.woocommerce-checkout").removeClass("processing").unblock()},track:{method:t=>new Promise(((a,c)=>{wp.apiRequest({path:`/depay/wc/checkouts/${e}/track`,method:"POST",data:t}).done((e=>a({status:200}))).fail(((e,t)=>c(t)))})),poll:{method:()=>fetch("/index.php?rest_route=/depay/wc/release",{method:"POST",body:JSON.stringify({checkout_id:e}),headers:{"Content-Type":"application/json"}})}}})}}))})); diff --git a/includes/class-depay-wc-payments-gateway.php b/includes/class-depay-wc-payments-gateway.php index a0857cc..2452c75 100644 --- a/includes/class-depay-wc-payments-gateway.php +++ b/includes/class-depay-wc-payments-gateway.php @@ -43,7 +43,7 @@ public function process_payment( $order_id ) { return( [ 'result' => 'success', - 'redirect' => '#wc-depay-checkout-' . $checkout_id . '-' . time() + 'redirect' => '#wc-depay-checkout-' . $checkout_id . '@' . time() ] ); } else { $order->payment_complete(); diff --git a/src/checkout.js b/src/checkout.js index a781c3a..7cdc1d5 100644 --- a/src/checkout.js +++ b/src/checkout.js @@ -1,6 +1,6 @@ window.addEventListener( 'hashchange', async()=> { if ( window.location.hash.startsWith( '#wc-depay-checkout-' ) ) { - let checkoutId = window.location.hash.match(/wc-depay-checkout-(.*?)$/)[1] + let checkoutId = window.location.hash.match(/wc-depay-checkout-(.*?)@/)[1] let accept = JSON.parse(await wp.apiRequest({ path: `/depay/wc/checkouts/${checkoutId}` })) DePayWidgets.Payment({ accept,