Fundraising/Data and flow/PSP integrations/Braintree

From Wikitech
Braintree
Original Name Braintree
Our Name Braintree
Current Name Braintree
Payment Methods PayPal
Countries ?
Documentation https://graphql.braintreepayments.com/
Production Console https://www.braintreegateway.com/login
Test Console https://sandbox.braintreegateway.com/
Contact ?

Overview

Braintree is supposed to replace PayPal Express Checkout, but has been delayed because it requires an extra click from donors to make payments.

We used GraphQL first time as our API, As Google pay and apple pay from Adyen, Braintree PayPal render a button in our payments page and we now only collect the employ field, encrypting the data before submitting it to our server.

All calls to the Braintree API are routed through the SmashPig library. There are PaymentProcessor subclasses for each payment method.

Braintree Graphql API Explorer

Based on their graphql schema, we store graphql querys under Smashpig box PaymentProviders/Braintree/Queries

  • we used `ping` to test the connection;
  • we used `chargePaymentMethod` to create payments;
  • we used `search` to get all transactions for audit parse;
  • we used `report` to get Venmo reports;

Local

Production

Payment Methods

https://graphql.braintreepayments.com/guides/concepts/#payment-methods

Paypal

https://developer.paypal.com/braintree/docs/guides/paypal/client-side

https://developer.paypal.com/braintree/docs/guides/paypal/vault

Since we want to have recurring and monthly convert, we choose the vault:

Vaulting a PayPal account will allow you to charge the account in the future without requiring your customer to be present during the transaction or re-authenticate with PayPal when they are present during the transaction.

Venmo

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






For non-us devs need to create a sandbox venmo account to test, and all donation will have user-name as venmojoe, which production env will have real user name shown.

sandbox account do not detect refund more than remaining venmo donation balance, but production have this.

we use password instead of barcode, since it's easier to be used from desktop

since we enable recurring and MC, we have vault for venmo as we have for paypal

https://developer.paypal.com/braintree/docs/guides/venmo/client-side/javascript/v3/

we first need to enable merchant account venmo to start working locally

Recurring

Recurring Braintree donations are tokenized and are charged on our schedule by the SmashPig Civi extension's recurring payment charge job.

https://developer.paypal.com/braintree/docs/guides/recurring-billing/overview

IPN messages

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

Audits

Braintree generates json files from the search queries for PayPal, and Venmo potentially.

We generate the report with process-control yaml file, daily and the maintaince script is SearchYesterdayTransactions

could generate report manually by inside the civi box, then run `php ./vendor/wikimedia/smash-pig/PaymentProviders/Braintree/Maintenance/SearchTransactions.php --r=90 --t=refund` (it will get the refund report from 90 hrs till now) types are (report, refund, chargeback) and the report will be stored under 'drupal/sites/default/files/wmf_audit/braintree/incoming' folder.

We process them with the wmf_audits drupal module that calls functions from SmashPig to parse the Json reports as run `drush parse-audit braintree` from /srv/civi-sites/wmff/drupal.

Pending Table

Jobs Queue

For overall payment queue can go to server, then run `drush --user=1 -v -r /srv/civi-sites/wmff/drupal qc` to consume the queues

Testing

Fundraising/Development tools/Testing#Braintree