Online payment system
Dolibarr provide native modules to make online payments of your invoices, orders, membership, registration to events...
The native payment modules are Paypal and Stripe.
From v20+, you can develop your own modules to support other payment services.
Main process
For this, you must create a module (Module_development) that implement the following hooks for the context "newpayment" that will manage the following hook methods:
- doValidatePayment
- doCheckStatus
- doAddButton
- doPayment
- isPaymentOK
Hook doValidatePayment
To return a code for your payment mode (used at different place of Application)
Hook doCheckStatus
Not usefull
Hook doAddButton
To define the button to add on the payment page /public/payments/newpayment.php
Hook doPayment
To show a form to show to make the payment. The form will be show after selecting your payment service on the page /public/payments/newpayment.php. This page must set the session variable $_SESSION['TRANSACTIONID'] (For example "YYYYMMDDHHMMSS-abc") and $_SESSION["FinalPaymentAmt"] (For example "123") and $_SESSION['currencyCodeType'] (for example "USD"). They will be used by the page called after payment /public/payment/paymentok.php
Hook isPaymentOK
to say if a payment is ok or not when entering the fallbackpage /public/payment/paymentok.php. If ok, the rest of common actions are done (payment registered, status of object modified), if not nothing is done except showing an error message.