From 1faa9d8231f439b7ebc9f00f1a32a48ab48ad364 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 11 Aug 2022 16:29:55 +0200 Subject: [PATCH] add hook to complete payment --- htdocs/takepos/pay.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index 24ca8cc782b..af6a4f79d71 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -130,7 +130,7 @@ if ($invoiceid > 0) { if ($invoice->type != $invoice::TYPE_CREDIT_NOTE) { if (empty($conf->global->$keyforstripeterminalbank)) { ?> const config = {simulated: global->STRIPE_TERMINAL_SIMULATED)) { ?> true false - global->STRIPE_LOCATION)) { ?>, location: 'global->STRIPE_LOCATION; ?>'} + global->STRIPE_LOCATION)) { ?>, location: 'global->STRIPE_LOCATION; ?>'} terminal.discoverReaders(config).then(function(discoverResult) { if (discoverResult.error) { console.log('Failed to discover: ', discoverResult.error); @@ -141,7 +141,7 @@ if ($invoiceid > 0) { // cashier here and let them select which to connect to (see below). selectedReader = discoverResult.discoveredReaders[0]; //console.log('terminal.discoverReaders', selectedReader); // only active for development - + terminal.connectReader(selectedReader).then(function(connectResult) { if (connectResult.error) { document.getElementById("card-present-alert").innerHTML = '
'+connectResult.error.message+'
'; @@ -160,7 +160,7 @@ if ($invoiceid > 0) { terminal.connectReader(getSelectedReader($conf->global->$keyforstripeterminalbank, $stripeacc, $servicestatus)); ?>).then(function(connectResult) { if (connectResult.error) { - document.getElementById("card-present-alert").innerHTML = '
'+connectResult.error.message+'
'; + document.getElementById("card-present-alert").innerHTML = '
'+connectResult.error.message+'
'; console.log('Failed to connect: ', connectResult.error); } else { document.getElementById("card-present-alert").innerHTML = ''; @@ -388,7 +388,7 @@ if ($conf->global->TAKEPOS_NUMPAD == 0) { global->STRIPE_TERMINAL_SIMULATED)) { ?> terminal.setSimulatorConfiguration({testCardNumber: 'global->STRIPE_TERMINAL_SIMULATED; ?>'}); - document.getElementById("card-present-alert").innerHTML = '
trans('PaymentSendToStripeTerminal'); ?>
'; + document.getElementById("card-present-alert").innerHTML = '
trans('PaymentSendToStripeTerminal'); ?>
'; terminal.collectPaymentMethod(client_secret).then(function(result) { if (result.error) { // Placeholder for handling result.error @@ -398,7 +398,7 @@ if ($conf->global->TAKEPOS_NUMPAD == 0) { console.log('terminal.collectPaymentMethod', result.paymentIntent); terminal.processPayment(result.paymentIntent).then(function(result) { if (result.error) { - document.getElementById("card-present-alert").innerHTML = '
'+result.error.message+'
'; + document.getElementById("card-present-alert").innerHTML = '
'+result.error.message+'
'; console.log(result.error) } else if (result.paymentIntent) { paymentIntentId = result.paymentIntent.id; @@ -409,7 +409,7 @@ if ($conf->global->TAKEPOS_NUMPAD == 0) { document.getElementById("card-present-alert").innerHTML = '
'+result.error.message+'
'; console.log("error when capturing paymentIntent", result.error); } else { - document.getElementById("card-present-alert").innerHTML = '
trans('PaymentValidated'); ?>
'; + document.getElementById("card-present-alert").innerHTML = '
trans('PaymentValidated'); ?>
'; console.log("Capture paymentIntent successfull "+paymentIntentId); parent.$("#poslines").load("invoice.php?place=&action=valid&pay=CB&amount="+amountpayed+"&excess="+excess+"&invoiceid="+invoiceid+"&accountid="+accountid, function() { if (amountpayed > || amountpayed == || amountpayed==0 ) { @@ -423,7 +423,7 @@ if ($conf->global->TAKEPOS_NUMPAD == 0) { }); } - }); + }); } }); } @@ -669,6 +669,14 @@ if ($conf->global->TAKEPOS_DELAYED_PAYMENT) { print ''; } ?> + +executeHooks('completePayment', $parameters, $invoice); +print $hookmanager->resPrint; +?> +