Redirect Paypal IPN API With a page rule - not working

#1

Hello,
My business uses paypal IPN send an API Callback to my billing system to tell it payments have been made. Long story, if you change your URL the paypal IPN still sends to the old URL and causes payment notifications to not be recieved which is bad for business. Paypal cannot help me so i’m trying to use a cloudflare page rule to the IPN API but it does not seem to be working…

I have a page rule set for:
https://www.example.com/whmcs/modules/gateways/callback/paypal.php

It is forwarding to:
https://portal.example.com/portal/modules/gateways/callback/paypal.php

However it does not appear that cloudflare is catching this as when i try to hit the old URL in my browser I should get a blank page if it correctly forwarded me to the paypal.php module however, it does not appear to be forwarding at all as i am simply getting a 404 error.

Does anyone have any thoughts or ideas on how i can fix or better accomplish this?
This is a fairly urgent issue as I am processing billing in 2 days so any help is greatly appreciated.
Thank You

#2

Doesnt IPN involve a callback URL that you configure at Paypal? In that case that would be something you need to configure at Paypal’s end. I am pretty sure they wont follow redirects.

#3

You would think that would be the solution however when you change the IPN callback URL on Paypal side only changes it for new customers that sign up going forward…so my 100+ customers that already have paypal subscriptions it still uses the old IPN callback address. Paypal advanced technical support is telling me this is as designed and they can’t do anything about change the IPN URL of my existing customer paypal subscriptions. That’s what led me to try to fix it on cloud flare end because i need it to re-write the URL if possible since paypal can’t do it

#4

So you are saying future transactions which are related to past transactions still go to the old URL? All right, I am afraid I cant comment on that but that sounds as if Paypal had something to fix :man_shrugging:t2: :slight_smile:

As for the redirect, which URL are we talking about?

#5

Hi Sandro, you are correct. That seems to me a major problem on Paypal end that they are refusing to address as an issue

The old URL IS:
https://www.example.com/whmcs/modules/gateways/callback/paypal.php

the correct URL IS:
https://portal.example.com/portal/modules/gateways/callback/paypal.php

Please let me know if you have any ideas.

#6

You need to post the actual URL.

#7

No problem, here are the actual URLs

The old URL IS:
https://www.hostmyapple.com/whmcs/modules/gateways/callback/paypal.php

the correct URL IS:
https://portal.hostmyapple.com/portal/modules/gateways/callback/paypal.php

#8

You www record is not proxied and hence does not go through Cloudflare’s systems. Because of that page rules wont have any effect. You need to switch the record to :orange: for that.

#9

Now i’m embarrassed, you are 100% correct, I’ve enabled the proxy on the WWW record and it appears to be redirecting with the page rule, i don’t know how i missed that!
So with the page rule set like this, you believe it will preserve the POST data from the IPN Call?

#10

I would not think so. Particularly with 301 and 302 POST data is not preserved, it is supposed to happen with 307 but I am not sure there’d be a guarantee either or even if Paypal will follow such a redirect. It should be really Paypal who provides some advice here.

#11

Hmm, okay well that’s not good as cloudflare only allows 301 or 302 redirects. I did read somewhere that a 307 redirect could resolve this paypal IPN issue.

Any thoughts on how i could re-direct it AND preserve the POST data?

#12

On Cloudflare either with a worker, or you send the redirect as a 307 straight from your server. But again, I wouldnt bet on that being a stable solution.

#13

so WHMCS actually provided me with a PHP file that serve’s as a perfect redirect to resolve the issue as they are familiar with it. It redirects and preserves the POST data. The issue is, I am hosted with webflow and they don’t allow uploading of php files so that doesn’t help me.

I’ve looked into the idea of using a worker to do it, i’m just not familiar with java and have no idea how to write it.

#14

https://developers.cloudflare.com/workers/ should get you started.

#15

I’m unfortunately not a programmer, it would likely take me weeks to figure this out :confused:

#16

Any idea where i could locate someone for hire that could build a 307 redirect cloudflare worker? My billing is about to run and it will become a real nightmare if i can’t fix by tomorrow.

#17

You could probably try https://www.freelancer.com/ or something alike.

closed #18

This topic was automatically closed after 14 days. New replies are no longer allowed.