paypal / ipn-code-samples

Other
562 stars 486 forks source link

Update PHP to allow caller to set curl options #139

Closed tzs closed 6 years ago

tzs commented 6 years ago

Many production environments restrict outgoing network access on their servers that deal with payments, only allowing such access through proxies that vet the destinations before allowing access. This patch provides an option for the caller of verifyIPN() to provide the curl object for verifyIPN() to use instead of allocating its own curl object. This allows the caller to set any proxy options, or other options, that may be required in order to allow the connection back to Paypal to work.

I first tried adding methods to the PaypalIPN class for setting proxy options, but PHP curl has a very large number of proxy settings. The majority of cases in practice could probably be handled with only two or three options, but the approach proposed in this pull request handles all the cases, so I abandoned the other approach. If anyone wants to see that approach, it is on a branch in my clone of this repository, available here

tzs commented 6 years ago

Good idea on doing it in a constructor. I'll withdraw this pull request and submit another one that takes that approach, essentially exactly as you suggested except it will be curl_handler instead of curlHandler, because the existing code seem to use snake_case for member and local variables rather than camelCase.