samerton / Nameless-Resources

Resources module for NamelessMC v2
MIT License
10 stars 13 forks source link

Adjust PayPal integration in some environments #47

Closed PikaMug closed 3 years ago

PikaMug commented 3 years ago

This PR is two-part. First is the solution to the current problem mentioned in #43:

[2021-07-01, 09:11:23] /home/user/public_html/site/modules/Resources/pages/resources/listener.php(33): Call to undefined function getallheaders()

According to this SO post, the getallheaders method does not exist in all environments. I'm using Pebblehost (a NamelessMC partner), so I hope you agree this solution is desirable. However, it's still not enough to get PayPal integration working.

It turns out that the PayPal headers are also invalid. For example, instead of expected PAYPAL-CERT-URL the webhook returns HTTP_PAYPAL_CERT_URL instead. I suspect this is because PayPal thinks we're using the Python SDK, but I couldn't find a way to specify otherwise (and besides v1 is deprecated). I hope you'll find the solution in my final commit acceptable.

PikaMug commented 3 years ago

Some closing notes:

partydragen commented 3 years ago

The paypal integration is working fine And there is no way to update webhook yet within NamelessMC so only way to modify is from Paypal developer portal

PikaMug commented 3 years ago

The paypal integration is working fine And there is no way to update webhook yet within NamelessMC so only way to modify is from Paypal developer portal

Current PayPal integration works fine if the server environment supports the getallheaders method, which not all do (Nginx, PHP-FPM, FastCGI). This PR will resolve those situations without modifying behavior of already supported environments.

Of course control over the webhook is limited but there's no way to specify SDK type in the Developer Portal as far as I could tell. You can set the events tracked, but as far as specifying PHP over Python there's no obvious configuration.

This PR is live on my website. Feel free to reach out to me on the NamelessMC discord if you'd like to take a peek.

samerton commented 3 years ago

Thank you for this!