• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

How do I set up PayPal for automatic payments?

hardlink

New Pleskian
I am running Plesk 10.3.1 with CBM 10.3.0 on Centos 5.5.

I have read the manual for CBM 10.3.0 and it says...
Return URL. Enter your install url - https://your_install_dir/
Cancel URL. Enter your install url - https://your_install_dir/
However, there is no place on the CBM payment gateway config for me to enter these two?

I have got ID, Item Name, Test Mode, Display Logo, etc but no Return URL or Cancel URL?

The payment for paypal seems to be accepted and I have the correct hash from the "orderform user" in my gateway.php as instructed.

But there is no return page, and CBM hasn't recognized the payment (IPN url is there but how would I test that?)

Is PayPal supposed to tell my panel that the payment was successful?
How long should this take?
Should there be a Return/Cancel URL?

Does anyone have any advice on this please?
 
Hi, thanks for your suggestion.

I used paypal's sandbox test tool (Test IPN tool) but when I run it it returns...
IPN delivery failed. Unable to connect to the specified URL. Please verify the URL and try again.

I am using https://cp.mydomain.com:8443/plesk-billing/gw/paypal.php

I can connect to this if I type it in a browser it gives me a blank page (no errors). If I try http://cp.mydomain.com/plesk-billing/gw/paypal.php browser gives 404.

I have an SSL cert on my site which is from GoDaddy (valid to cp.mydomain.com) and I can see no ssl errors when visiting the gw script in internet explorer.

Any idea why PayPal cannot see the plesk-billing IPN script?

I really need this to work!
using Plesk 10.3.1 with CBM 10.3
 
Think I found the answer, now what?

A blogg...
http://www.blograndom.com/blog/2008/09/paypal-ipn-from-the-sandbox-not-working/

Says....
Matthew Fox

Posted October 22, 2011 at 11:17 pm | Permalink

Michael is right. Ensure your host runs on port 80 or port 443 before you try anything else. Paypal didn’t send me anything using the IPN simulator when my handler was on ports 8000 or 8080, but it worked fine on ports 80 or 443.

Parallels are using port 8443!

Please could you suggest a fix?
 
Hello, hardlink

Looks like there are two issues:
1. PayPal rejects to work over HTTPS protocol with custom port
2. You Web Server doesn't allow to connect to cp.mydomain.com over HTTP protocol with standard port.

I'll try to investigate the issue and solve this in software directly.

But for now you need to set up port forwarding manually - to forward https://cp.mydomain.com/ (actually https://cp.mydomain.com:443/) to https://cp.mydomain.com:8443/
If you do not know how to do this, you can try to set up own site in Panel - go there and create own (admin's) subscription with domain cp.domain.com and then put there a PHP file from this article - http://www.arolabs.com/php/paypal-ipn-postback-on-a-custom-port/
 
The proposed solution works for me.
What I did:
1. I created a subscription in Plesk with domain "domain.com", enabled debug mode in CBM using http://kb.parallels.com/en/9300

2. I created script paypal.php and log file paypal_ipn_log.txt in site root (httpdocs directory)
<?php

$log = fopen('paypal_ipn_log.txt', 'a');

$url = 'https://domain.com:8443/plesk-billing/gw/paypal.php';

$fields = $_POST;
fputs($log, "IPN received\n");

if (count($fields) > 0) {

//url-ify the data for the POST
foreach ( $fields as $key => $value ) {
fputs($log, "Field: ".$key."=".$value."\n");
$fields_string .= $key . '=' . $value . '&';
}
rtrim ( $fields_string, '&' );

//open connection
$ch = curl_init ();

//set the url, number of POST vars, POST data
curl_setopt ( $ch, CURLOPT_URL, $url );
curl_setopt ( $ch, CURLOPT_POST, count ( $fields ) );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $fields_string );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, FALSE ); //this because I have self-signed certificate
curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, FALSE ); //this because I have self-signed certificate

//execute post
fputs($log, "Forwarding request...\n");
fputs($log, $url."\n");
fputs($log, $fields_string."\n");
$result = curl_exec ( $ch );
fputs($log, "\n\nResult received: ".($result === true?"OK":curl_error($ch))."\n");

//close connection
curl_close ( $ch );

}

fputs($log, "END\n");
fclose($log);

?>

3. I checked that I can access "http://domain.com/paypal.php" via browser (new items in log). I checked that PayPal can access this URL using Sandbox IPN test tool (much more items in log. I checked that new item appeared in CBM debug log (/plesk-billing/gw/paypal.php - log of how CBM attempted to parse the PayPal message)

4. I configured PayPal gateway in CBM, specified IPN URL as "http://domain.com/paypal.php" and bought hosting in online store. IPN message was successfully delivered to CBM, parsed and corresponding invoice was marked as paid.

Hope this will help you.
 
Thank you EugeneL! (Detailed feedback...)

EugeneL,

Your script for the CURL SSL port redirect for Paypal IPN worked perfectly whereas mine didn't!
(Peeps: Don't forget to set permissions/owner on your paypal_ipn_log.txt log file so apache can write to it)

The difference was clear, your script ignores SSL verification.
My certificate however was not self signed, but a GoDaddy "Turbo SSL Certificate".

But when I tried your script without the two options for self signed certs, I had an error...
Result received: SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
END

The problem ended up being that I hadn't added my CA bundle chain file (gd_bundle.crt) to Plesk for the site to verify the certificate locally.
I re-installed my certificate.crt WITH the ca_bundle.crt using the Plesk SSL GUI panel.

That's it! My certificate now works.

Hope that this thread helps someone else in need!

EugeneL you are a star x
 
Last edited:
Thanks, hardlink

I'm happy to hear that your issue is solved.

Naturally you can remove all logging from the script (all lines with calls to fopen/fputs/fclose) because without configured log rotation but with active usage the log file can become quite large.
 
Back
Top