Merge pull request #12512 from Mavyre/develop
NEW Added SumUp payment to TakePOS
This commit is contained in:
commit
5e5c1ac574
@ -81,7 +81,10 @@ if (GETPOST('action', 'alpha') == 'set')
|
||||
$res = dolibarr_set_const($db, "TAKEPOS_DIRECT_PAYMENT", GETPOST('TAKEPOS_DIRECT_PAYMENT', 'int'), 'int', 0, '', $conf->entity);
|
||||
$res = dolibarr_set_const($db, "TAKEPOS_CUSTOM_RECEIPT", GETPOST('TAKEPOS_CUSTOM_RECEIPT', 'int'), 'int', 0, '', $conf->entity);
|
||||
$res = dolibarr_set_const($db, "TAKEPOS_EMAIL_TEMPLATE_INVOICE", GETPOST('TAKEPOS_EMAIL_TEMPLATE_INVOICE', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (! empty($conf->global->TAKEPOS_ENABLE_SUMUP)) {
|
||||
$res = dolibarr_set_const($db, "TAKEPOS_SUMUP_AFFILIATE", GETPOST('TAKEPOS_SUMUP_AFFILIATE', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
$res = dolibarr_set_const($db, "TAKEPOS_SUMUP_APPID", GETPOST('TAKEPOS_SUMUP_APPID', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
if ($conf->global->TAKEPOS_ORDER_NOTES == 1)
|
||||
{
|
||||
$extrafields = new ExtraFields($db);
|
||||
@ -241,6 +244,20 @@ print '<td colspan="2">';
|
||||
print $form->selectyesno("TAKEPOS_DIRECT_PAYMENT", $conf->global->TAKEPOS_DIRECT_PAYMENT, 1);
|
||||
print "</td></tr>\n";
|
||||
|
||||
// Sumup options
|
||||
if ($conf->global->TAKEPOS_ENABLE_SUMUP) {
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("SumupAffiliate");
|
||||
print '<td colspan="2">';
|
||||
print '<input type="text" name="TAKEPOS_SUMUP_AFFILIATE" value="' . $conf->global->TAKEPOS_SUMUP_AFFILIATE . '"></input>';
|
||||
print "</td></tr>\n";
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("SumupAppId");
|
||||
print '<td colspan="2">';
|
||||
print '<input type="text" name="TAKEPOS_SUMUP_APPID" value="' . $conf->global->TAKEPOS_SUMUP_APPID . '"></input>';
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
|
||||
// Custom Receipt
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans('CustomReceipt');
|
||||
|
||||
@ -74,7 +74,10 @@ if (GETPOST('action', 'alpha') == 'set')
|
||||
$res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CASH".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
|
||||
$res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CHEQUE".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
|
||||
$res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CB".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
|
||||
foreach($paiements as $modep) {
|
||||
if (! empty($conf->global->TAKEPOS_ENABLE_SUMUP)) {
|
||||
$res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_SUMUP".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
foreach($paiements as $modep) {
|
||||
if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) continue;
|
||||
$name="CASHDESK_ID_BANKACCOUNT_".$modep->code.$terminaltouse;
|
||||
$res = dolibarr_set_const($db, $name, (GETPOST($name, 'alpha') > 0 ? GETPOST($name, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
|
||||
@ -151,6 +154,13 @@ if (! empty($conf->banque->enabled))
|
||||
$form->select_comptes($conf->global->{'CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse}, 'CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 0, "courant=1", 1);
|
||||
if (! empty($conf->global->{'CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse})) $atleastonefound++;
|
||||
print '</td></tr>';
|
||||
if ($conf->global->TAKEPOS_ENABLE_SUMUP) {
|
||||
print '<tr class="oddeven"><td>' . $langs->trans("CashDeskBankAccountForSumup") . '</td>';
|
||||
print '<td>';
|
||||
$form->select_comptes($conf->global->{'CASHDESK_ID_BANKACCOUNT_SUMUP' . $terminaltouse}, 'CASHDESK_ID_BANKACCOUNT_SUMUP' . $terminaltouse, 0, "courant=1", 1);
|
||||
if (!empty($conf->global->{'CASHDESK_ID_BANKACCOUNT_SUMUP' . $terminaltouse})) $atleastonefound++;
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
foreach($paiements as $modep) {
|
||||
if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) continue; // Already managed before
|
||||
|
||||
@ -176,6 +176,35 @@ else print "var received=0;";
|
||||
else location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
function ValidateSumup() {
|
||||
<?php $_SESSION['SMP_CURRENT_PAYMENT'] = "NEW" ?>
|
||||
var invoiceid = <?php echo($invoiceid > 0 ? $invoiceid : 0); ?>;
|
||||
var amountpayed = $("#change1").val();
|
||||
if (amountpayed > <?php echo $invoice->total_ttc; ?>) {
|
||||
amountpayed = <?php echo $invoice->total_ttc; ?>;
|
||||
}
|
||||
|
||||
// Starting sumup app
|
||||
window.open('sumupmerchant://pay/1.0?affiliate-key=<?php echo dolibarr_get_const($db, "TAKEPOS_SUMUP_AFFILIATE")?>&app-id=<?php echo dolibarr_get_const($db, "TAKEPOS_SUMUP_APPID")?>&total=' + amountpayed + '¤cy=EUR&title=' + invoiceid + '&callback=<?php echo DOL_MAIN_URL_ROOT ?>/takepos/smpcb.php');
|
||||
|
||||
var loop = window.setInterval(function () {
|
||||
$.ajax('/takepos/smpcb.php?status').done(function (data) {
|
||||
console.log(data);
|
||||
if (data === "SUCCESS") {
|
||||
parent.$("#poslines").load("invoice.php?place=<?php echo $place;?>&action=valid&pay=CB&amount=" + amountpayed + "&invoiceid=" + invoiceid, function () {
|
||||
//parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight);
|
||||
parent.$.colorbox.close();
|
||||
//parent.setFocusOnSearchField(); // This does not have effect
|
||||
});
|
||||
clearInterval(loop);
|
||||
} else if (data === "FAILED") {
|
||||
parent.$.colorbox.close();
|
||||
clearInterval(loop);
|
||||
}
|
||||
});
|
||||
}, 2500);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div style="position:absolute; top:2%; left:5%; height:30%; width:91%;">
|
||||
@ -269,6 +298,13 @@ while($i < count($paiements)){
|
||||
<?php
|
||||
$i=$i+1;
|
||||
}
|
||||
|
||||
if($conf->global->TAKEPOS_ENABLE_SUMUP && !empty(dolibarr_get_const($db, "CASHDESK_ID_BANKACCOUNT_SUMUP".$_SESSION["takeposterminal"]))) {
|
||||
?>
|
||||
<button type="button" class="calcbutton2" onclick="ValidateSumup();">Sumup</button>
|
||||
<?php
|
||||
}
|
||||
|
||||
$class=($i==3)?"calcbutton3":"calcbutton2";
|
||||
foreach($action_buttons as $button){
|
||||
$newclass = $class.($button["class"]?" ".$button["class"]:"");
|
||||
|
||||
35
htdocs/takepos/smpcb.php
Normal file
35
htdocs/takepos/smpcb.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
require '../main.inc.php';
|
||||
|
||||
if(isset($_GET['status'])) {
|
||||
die(strtoupper($_SESSION['SMP_CURRENT_PAYMENT']));
|
||||
}
|
||||
|
||||
if($_GET['smp-status']) {
|
||||
print '<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>The HTML5 Herald</title>
|
||||
<meta name="description" content="The HTML5 Herald">
|
||||
<meta name="author" content="SitePoint">
|
||||
|
||||
<link rel="stylesheet" href="css/styles.css?v=1.0">
|
||||
|
||||
</head>
|
||||
|
||||
<body>';
|
||||
$_SESSION['SMP_CURRENT_PAYMENT'] = $_GET['smp-status'];
|
||||
|
||||
print '<script type="application/javascript">
|
||||
window.onload = function() {
|
||||
window.close();
|
||||
};
|
||||
</script>';
|
||||
|
||||
print "Transaction status registered, you can close this";
|
||||
|
||||
die('</body></html>');
|
||||
}
|
||||
|
||||
print 'NOOP';
|
||||
Loading…
Reference in New Issue
Block a user