Online Payment Module Architecture: Difference between revisions

m
Tag: 2017 source edit
Tag: 2017 source edit
Line 13: Line 13:


= Step 1 - The choice of the payment mode =
= Step 1 - The choice of the payment mode =
First step to make an online payment is done by calling the page  
First step to make an online payment is done by calling the public page  
/public/payment/newpayment.php
'''/public/payment/newpayment.php'''


This page is common to all payment mode.
This page is common to all payment mode.
It page accepts some parameters to know how to find the amount. This is a list of all possible url:
It page accepts some parameters to know how to find the amount. This is a list of all possible URLs:


URL to offer a Stripe online payment page of any amount with no existing object:


Following URLs are available to offer a page to a customer to make a payment on Dolibarr objects:
* URL to offer an online payment page of any amount with no existing object:


http://mydolibarrdomain/public/payment/newpayment.php?amount=9.99&tag=your_tag


* URL to offer an online payment page for a sales order:


* URL to offer a Stripe online payment page of any amount with no existing object:
http://mydolibarrdomain/public/payment/newpayment.php?source=order&ref=order_ref


http://localhostgit/dolibarr_12.0/htdocs/public/payment/newpayment.php?amount=9.99&tag=your_tag
* URL to offer an online payment page for a customer invoice:


* URL to offer a Stripe online payment page for a sales order:
http://mydolibarrdomain/public/payment/newpayment.php?source=invoice&ref=invoice_ref
 
http://localhostgit/dolibarr_12.0/htdocs/public/payment/newpayment.php?source=order&ref=order_ref
 
* URL to offer a Stripe online payment page for a customer invoice:
 
http://localhostgit/dolibarr_12.0/htdocs/public/payment/newpayment.php?source=invoice&ref=invoice_ref


* URL to offer a Stripe online payment page for a contract line:
* URL to offer a Stripe online payment page for a contract line:


http://localhostgit/dolibarr_12.0/htdocs/public/payment/newpayment.php?source=contractline&ref=contractline_ref
http://mydolibarrdomain/public/payment/newpayment.php?source=contractline&ref=contractline_ref


* URL to offer a Stripe online payment page for a member subscription:
* URL to offer a Stripe online payment page for a member subscription:


http://localhostgit/dolibarr_12.0/htdocs/public/payment/newpayment.php?source=membersubscription&ref=member_ref
http://mydolibarrdomain/public/payment/newpayment.php?source=membersubscription&ref=member_ref


* URL to offer a Stripe online payment page for payment of a donation:
* URL to offer a Stripe online payment page for payment of a donation:


http://localhostgit/dolibarr_12.0/htdocs/public/payment/newpayment.php?source=donation&ref=donation_ref
http://mydolibarrdomain/public/payment/newpayment.php?source=donation&ref=donation_ref
 


The parameter are used by the page to find the amount to ask for the payment from the object retrieved in URL.
Then the page makes a list of all available payment mode and suggest them as a different button "Pay using XXX".


The parameter are used by the page to find the amount to ask for the payment. Then the page makes a list of all available payment mode and suggest them as a different button "Pay using XXX".
* To include your own payment method in this list, your module must implement the hook '''doAddButton''' for the context "newpayment". Your hook must return an
array('yourpaymentcode' => 'Label to show')


=> You can already test your module by checking a new entry to pay appear on the payment page.


= Step 2 - User choose the payment mode  =
= Step 2 - User choose the payment mode  =