Page MenuHomePhabricator

Create IPN listener for Braintree
Closed, InvalidPublic

Description

Should handle at least payment capture confirmations, refunds, and chargebacks.

https://developer.paypal.com/braintree/docs/guides/webhooks/overview

Event Timeline

AnnWF removed AnnWF as the assignee of this task.Jun 15 2022, 9:45 PM
AnnWF moved this task from Doing to Backlog on the Fundraising Sprint Kermit hopping principle board.
AnnWF subscribed.

For getting test ipns from Braintree we need to fix this issue I think?
https://phabricator.wikimedia.org/T308361

Change 817357 had a related patch set uploaded (by Jgleeson; author: Jgleeson):

[wikimedia/fundraising/SmashPig@master] WIP: Create IPN listener for Braintree

https://gerrit.wikimedia.org/r/817357

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

  • Code:
  • Local Docker Updates: Update the Apache config on your fundraising-dev SmashPig container to listen for braintree traffic:
    • docker-compose exec -u root smashpig bash // you need to be root
    • open /etc/apache2/sites-enabled/000-default.conf in your preferred text editor and add the rule RewriteRule ^/braintree /smashpig_http_handler.php?p=braintree/listener [L,QSA] to the end of the RewriteRules list
    • whilst on the SmashPig container, run service apache2 reload 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
  • 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 jobs-braintree queue. An easy way to watch for this is to run docker-compose exec queues redis-cli monitor and this will open up your redis-cli and listen for queue traffic.

Thanks. Ping me if you have any problems.

Note: It was late when I wrote this. I hope it makes sense!

Hi! Thanks for all this, and for the detailed testing instructions. I'm able to get an IPN test through locally via the tunnel. The new Braintree code is indeed invoked, and I'm getting a "No matching public key" error in syslog, apparently from this line.

Ah also... I see both patches marked WIP... is that still their status?

Thanks again! :)

Change 817357 merged by jenkins-bot:

[wikimedia/fundraising/SmashPig@master] Create IPN listener for Braintree

https://gerrit.wikimedia.org/r/817357

jgleeson subscribed.
AKanji-WMF subscribed.

Will need to include this to enable Venmo work in Sprint O [FY2324]

Should handle at least payment capture confirmations, refunds, and chargebacks.

I don't think Braintree give us webhook notifications for Paypal and Venmo completed capture or refund events. I tried enabling every webhook and going through the full transaction flow right to settlement in the console and then also refunded transactions, and I'm not getting any webhook notifications. I checked up on the list of available notifications, and it doesn't mention notifications for successful capture or refunds. I do see dispute notifications, so that might be how we get notified about chargebacks, but I need to confirm that with Braintree. Even so, it's not obvious to me how we'd use that information as we don't currently report chargeback IPNs from other gateways to donor services unless I'm wrong on that.

image.png (961×1 px, 170 KB)

Local payment method notifications looked promising, but it turns out this isn't for Paypal or Venmo.

Local Payment Methods allow customers to pay with banks, wallets, or other means that operate only in specific regions of the world. For example, a customer in the Netherlands might want to pay using iDEAL, which is used by more than 60% of consumers in the Netherlands for online purchases, whereas a customer in Belgium on the same website might want to pay using Bancontact, a popular payment method there.

The only ones that stand out as immediately useful are the subscription notifications which I think will be related to our recurring donations. I'm gonna reach out to Braintree to see if there are any webhooks specific to PayPal and Venmo.

Braintree replied with

Webhooks are not available for transaction and refund events for PayPal and Venmo. In those cases, you would need to rely on the transaction result object for the details. The only webhook available would be the Payment Method event(s) for Venmo when a customer updates their Venmo profile, or revokes consent within the app.