Fundraising tech/IPN listener

Overview
Many payment processors send realtime updates on the state of payments to a listener endpoint on the merchant's servers. We refer to these messages as Instant Payment Notifications (IPNs), following PayPal's terminology. For some of our providers the IPNs are an essential part of the normal payments flow while for others they serve as a second opportunity to capture information about donations in case of problems sending the information from payments-wiki.

Adyen
Adyen sends us IPNs on card payment authorization and capture as well as when a new settlement report is available.

Amazon
TODO

Braintree
WIP

PayPal
Paypal sends us IPNs on Payment, Recurring, Refund, and Subscription transactions. The full list of IPN messages can be found here on Paypal's website. However, we only listen to a subset of the messages, you can find the list on Smashpig Paypal config yaml file under each message type.

Braintree
To test out receiving Braintree IPNs, you need to do the following:


 * Code:
 * pull down the latest on Smash0pig
 * pull down the latest on fundraising-dev
 * pull down the latest on config-private
 * Local Docker Updates: Update the Apache config on your fundraising-dev SmashPig container to listen for braintree traffic:
 * // you need to be root
 * open /etc/apache2/sites-enabled/000-default.conf in your preferred text editor and add the rule  to the end of the   list
 * whilst on the SmashPig container, run  to load in the config update.
 * navigate to http://localhost:9006/braintree, and you should have a blank page returning a 200 response if it worked. If that doesn't work as expected, try http://localhost:9006/adyen just to confirm the IPN server is running.
 * Enable remote tunnel Recieve IPNs from the Braintree sandbox
 * Check out your tunnel config here and switch yours on. Head to your https://paymentsipntest${tunneling_id}.wmcloud.org/braintree address. For me it's https://paymentsipntest2.wmcloud.org/braintree and confirm it's loading.
 * Perform an IPN test using the Braintree Sandbox console
 * Head over to https://sandbox.braintreegateway.com/merchants/ms9fqmw9gxrm2bp3/webhooks and create a webhook endpoint for your paymentsipntest URL. You should see the one I've been using, https://paymentsipntest2.wmcloud.org/braintree?XDEBUG_SESSION_START=PHPSTORM (the additional query param is to enable xdebug on demand)
 * Enable a few sample webhook notifications and then click Check URL to trigger an IPN message to be sent to your local machine.
 * To confirm, you can either xdebug the incoming request or you can also monitor your local redis queue. If the IPN is processed successfully, you should have a new queue message on the  queue. An easy way to watch for this is to run   and this will open up your redis-cli and listen for queue traffic.

PayPal
To test out receiving PayPal IPNs, you need to do the following:


 * Code:
 * pull down the latest on Smash-pig
 * pull down the latest on fundraising-dev
 * pull down the latest on config-private
 * Local Docker Updates: Update the Apache config on your fundraising-dev SmashPig container to listen for braintree traffic:
 * navigate to http://localhost:9006/paypal, and you should have a blank page returning a 200 response if it worked. If that doesn't work as expected, try http://localhost:9006/adyen just to confirm the IPN server is running.
 * Enable remote tunnel Recieve IPNs from the Braintree sandbox
 * Check out your tunnel config here and switch yours on using the proxy-forward script in fundraising-dev. Head to your  https://paymentsipntest${tunneling_id}.wmcloud.org/paypal  address.
 * Perform an IPN test using the Braintree Sandbox console
 * Head over to https://www.sandbox.paypal.com/cgi-bin/customerprofileweb?cmd=_profile-ipn-notify, login with the fr-tech-facilitator account and update the Notification URL with your paymentsipntest Paypal URL ( https://paymentsipntest${tunneling_id}.wmcloud.org/paypal  ).
 * To confirm, you can either xdebug the incoming request or you can also monitor your local redis queue. If the IPN is processed successfully, you should have a new queue message on the  queue. An easy way to watch for this is to run   and this will open up your redis-cli and listen for queue traffic.