# External URL for Paypal Module

**URL:** <https://www.dolibarr.org/forum/t/external-url-for-paypal-module/29864>\
**Category:** Financial modules\
**Created:** [January 21, 2025, 9:07am UTC](https://www.dolibarr.org/forum/t/external-url-for-paypal-module/29864 "2025-01-21T09:07:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bastian](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/b/779978/32.png) [@Bastian](https://www.dolibarr.org/forum/u/Bastian)\
**Post date:** [January 21, 2025, 9:07am UTC](https://www.dolibarr.org/forum/t/external-url-for-paypal-module/29864/1 "2025-01-21T09:07:27Z")

</div>

Hi all,

I want to setup the Paypal module on my dolibarr installation.  
My dolibarr is hosted locally and not available on a public TLD.

I access my dolibarr like [dolibarr.mylan.net](http://dolibarr.mylan.net)  
The configured baseurl for dolibarr is `dolibarr.mylan.net`

I want to make the Paypal payment available publicly, so therefore I need to set a separate external url for the Paypal module.

I have added a subdomain like `https://payment.mytld.com` and routed it through a reverse proxy to a vhost on the dolibarr server.  
The apache2 serves the public payment interface on port 82

Using this method I can use the external url for the test scenario like:

```url
https://payment.mytld.com/newpayment.php?amount=10&tag=your_tag

```

I can also click on Pay with Paypal on this site.  
I’m redirected to Paypal and can do the payment.  
But now when I should be redirected back to the paypal module from Dolibarr I get a technical error due to a wrong url set in the token or in the response.  
The error seems to be that, when performing the payment, paypal wants to send me back to my internal URL:

[http://dolibarr.mylan.net/dolibarr/public/payment/paymentok.php](http://dolibarr.mylan.net/dolibarr/public/payment/paymentok.php)

instead of the correct external url:

[https://payment.mytld.com/paymentok.php](https://payment.mytld.com/paymentok.php)

For the Dolibarr Ticket System I can setup a separate URL for the public interface. Is this in any way possible for the paypal module as well?

Any help is appreciated!

Best regards  
Bastian

---

<div class="post-metadata">

**Author:** ![Bastian](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/b/779978/32.png) [@Bastian](https://www.dolibarr.org/forum/u/Bastian)\
**Post date:** [January 21, 2025, 9:16am UTC](https://www.dolibarr.org/forum/t/external-url-for-paypal-module/29864/2 "2025-01-21T09:16:49Z")

</div>

in the newpayment.php I found the following:

```auto
// Define $urlwithroot
//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.

$urlok = $urlwithroot.'/public/payment/paymentok.php?';
$urlko = $urlwithroot.'/public/payment/paymentko.php?';

// Complete urls for post treatment
$ref = $REF = GETPOST('ref', 'alpha');
$TAG = GETPOST("tag", 'alpha');
$FULLTAG = GETPOST("fulltag", 'alpha'); // fulltag is tag with more information

```

Which is the problem. Because the DOL\_MAIN\_URL\_ROOT is always used to build the requests

also the DOL\_URL\_ROOT seems to be related to the DOL\_MAIN\_URL\_ROOT according to the wiki entry [Link to wiki](https://wiki.dolibarr.org/index.php?title=Configuration_file)

Would it be advisable to introduce a new variable in the local config.php file?  
But even if so, I’d need to make sure to

- have the value in my config.php
- check where to load it into a php variable
- adjust the payment module manually to use the new variable

---

<div class="post-metadata">

**Author:** ![Bastian](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/b/779978/32.png) [@Bastian](https://www.dolibarr.org/forum/u/Bastian)\
**Post date:** [January 21, 2025, 9:35am UTC](https://www.dolibarr.org/forum/t/external-url-for-paypal-module/29864/3 "2025-01-21T09:35:08Z")

</div>

Oh and it would be also necessary to let the paypal Dolibarr module know about the separate URLs because of the automatically generated URLs on the invoices, etc.

So hardcoding a separate URL in the php files of the payment module will probably not be sufficient 😄
