Skip to content

Commit

Permalink
Merge branch 'addHookPaymentMethod' of github.com:Tetras-Libre/doliba…
Browse files Browse the repository at this point in the history
…rr into sif-19
  • Loading branch information
dbeniamine committed Jan 2, 2025
1 parent b0fe6a0 commit df4673a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 36 deletions.
7 changes: 5 additions & 2 deletions htdocs/compta/facture/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,18 @@
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';

require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';

if (isModEnabled('commande')) {
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
}
Expand Down Expand Up @@ -5992,7 +5995,7 @@ function js_recalculate_revenuestamp(){


// Show online payment link
$useonlinepayment = (isModEnabled('paypal') || isModEnabled('stripe') || isModEnabled('paybox'));
$useonlinepayment = !empty(getValidOnlinePaymentMethods());

if ($object->statut != Facture::STATUS_DRAFT && $useonlinepayment) {
print '<br><!-- Link to pay -->'."\n";
Expand Down
21 changes: 8 additions & 13 deletions htdocs/custom/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
# DOLIBARR ERP & CRM custom directory for external modules
# DOLIBARR ERP & CRM custom directory for external modules.

This directory is dedicated to store external modules.
To use it, just copy here the directory of the module into this directory.

Note: On linux or MAC systems, it is better to unzip/store the external module directory into
Note: On linux or MAC systems, it is better to unzip/store the external module directory into
a different place than this directory and just adding a symbolic link here to the htdocs directory
of the module.

For example on Linux OS: Get the module from the command

`mkdir ~/git; cd ~/git`

`git clone https://git.framasoft.org/p/newmodule/newmodule.git`

For example on Linux OS: Get the module from the command
mkdir ~/git; cd ~/git
git clone https://git.framasoft.org/p/newmodule/newmodule.git
Then create the symbolic link

`ln -fs ~/git/newmodule/htdocs /path_to_dolibarr/htdocs/custom/newmodule`
ln -fs ~/git/newmodule/htdocs /path_to_dolibarr/htdocs/custom/newmodule

WARNING !!!
Check also that the /custom directory is active by adding into dolibarr `conf/conf.php` file the following
Check also that the /custom directory is active by adding into dolibarr conf/conf.php file the following
two lines, so dolibarr will also scan /custom directory to find external external modules:

```php
$dolibarr_main_url_root_alt='/custom';
$dolibarr_main_document_root_alt='/path_to_dolibarr/htdocs/custom/';
```

16 changes: 6 additions & 10 deletions htdocs/public/payment/paymentko.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($db);
$hookmanager->initHooks(array('paymentko'));



if (isModEnabled('paypal')) {
require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php';
Expand Down Expand Up @@ -95,16 +100,7 @@
}


$validpaymentmethod = array();
if (isModEnabled('paypal')) {
$validpaymentmethod['paypal'] = 'paypal';
}
if (isModEnabled('paybox')) {
$validpaymentmethod['paybox'] = 'paybox';
}
if (isModEnabled('stripe')) {
$validpaymentmethod['stripe'] = 'stripe';
}
$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);


// Security check
Expand Down
19 changes: 8 additions & 11 deletions htdocs/public/payment/paymentok.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';

include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($db);
$hookmanager->initHooks(array('paymentok'));

if (isModEnabled('paypal')) {
require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php';
require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php';
Expand Down Expand Up @@ -129,17 +134,7 @@
dol_syslog("***** paymentok.php is called paymentmethod=".$paymentmethod." FULLTAG=".$FULLTAG." REQUEST_URI=".$_SERVER["REQUEST_URI"], LOG_DEBUG, 0, '_payment');


$validpaymentmethod = array();
if (isModEnabled('paypal')) {
$validpaymentmethod['paypal'] = 'paypal';
}
if (isModEnabled('paybox')) {
$validpaymentmethod['paybox'] = 'paybox';
}
if (isModEnabled('stripe')) {
$validpaymentmethod['stripe'] = 'stripe';
}

$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
// Security check
if (empty($validpaymentmethod)) {
httponly_accessforbidden('No valid payment mode');
Expand Down Expand Up @@ -565,6 +560,7 @@
if ($paymentmethod == 'stripe') {
$accountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS;
}
$hookmanager->executeHooks('getBankAccountForPayements', $parameters, $paymentTypeId, $action);
if ($accountid < 0) {
$error++;
$errmsg = 'Setup of bank account to use for payment is not correctly done for payment method '.$paymentmethod;
Expand Down Expand Up @@ -902,6 +898,7 @@
} elseif ($paymentmethod == 'stripe') {
$bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS;
}
$hookmanager->executeHooks('getBankAccountForPayements', $parameters, $bankaccountid, $action);

if ($bankaccountid > 0) {
$label = '(CustomerInvoicePayment)';
Expand Down

0 comments on commit df4673a

Please sign in to comment.