You are browsing a read-only backup copy of Wikitech. The live site can be found at wikitech.wikimedia.org

Fundraising/Development tools/Testing

From Wikitech-static
Jump to navigation Jump to search

Overview

There are many different software stacks and configurations involved with testing WMF fundraising code and its interactions with external services.

Unit Tests

Resources

Fundraising/Data and flow/Queues/Testing

Logging

PSP Specific Instructions

Adyen

Test Card Details

https://docs.adyen.com/development-resources/test-cards/test-card-numbers

Instant Payment Notifications(IPN) Messages - using wmcloud

1. Connect to your wmfcloud server [find the spreadsheet link]

2. Go to https://paymentsipntest4.wmcloud.org/adyen [replace with your sever number] you should see a SOAP Bad Request warning

3. In the adyen test console, set up a webhook matching your test server url (eg https://paymentsipntest4.wmcloud.org/adyen) and method set to SOAP

4. Send a test notification to the webhook, you should see a green SUCCEEDED in the Adyen console and see messages appear in your smashpig-syslog

iDEAL Recurring

iDEAL recurring uses the RECURRING_CONTRACT ipn to finish the original donation and setup the recurring donation.

Steps:

1. Create a new iDEAL recurring donation with country=NL, payment_method=rtbt, and currency=EUR https://localhost:9001/index.php?title=Special:AdyenCheckoutGateway&appeal=JimmyQuote&payment_method=rtbt&recurring=1&uselang=en&language=en&currency=EUR&amount=5.55&country=NL&ffname=adyen&first_name=Jimmy&last_name=Wales&street_address=1+Montgomery+Street&city=San+Francisco&state_province=CA&postal_code=94104&email=jwales%40example.com&debug=true

In Adyen's console the inital donation will be payment method iDEAL (subsequent recurrings will be SEPA Direct Debit) with Recurring contract=RECURRING,ONECLICK

2. Consume the pending queue, from the SmashPig container in `srv/smashpig` run `php maintenance/ConsumePendingQueue.php` This adds what was in the queue into SmashPig pending database

3. The incoming ipn messages are processed and put onto the jobs-adyen queue, you can consume that from the SmashPig container in `srv/smashpig` with `php Maintenance/QueueJobRunner.php --queue jobs-adyen --config-node adyen` The RECURRING_CONTRACT ipn does take ~1 minute to appear.

When the RECURRING_CONTRACT ipn is in the jobs-adyen queue, it will find the matching pending entry, create a donations queue message, and delete the pending entry.

Pending Resolver

pending resolver is been used when we got donation in pending table for review for fraud, and was not been captured yet, so want to run a job for donor relation team if donor got exist non-refund donation, will auto capture tnxs;

Steps:

1. Create a new adyen cc donation, (update the fraud score or force to skip the capture step from the code) to make sure it will not get captured after authorize.

2. Consume the pending queue, from the SmashPig container in `srv/smashpig` run `php maintenance/ConsumePendingQueue.php` This adds what was in the queue into SmashPig pending database

3. Run the PendingTable.consume as `drush cvapi PendingTable.consume version=4 gateway=adyen batch=1`

UML diagrams:

https://gitlab.wikimedia.org/repos/fundraising-tech/fr-tech-diagrams

Instant Payment Notifications(IPN) Messages - using ngrok

Adyen allows you to specify an endpoint to receive IPN messages generated in relation to transactions put through their https://test.adyen.com payment gateway. To allow Adyen to send IPNs to your local vagrant web server you need to give it a publicly accessible URL. You can do this with ngrok and capture the IPN messages locally using the following steps:

  1. Confirm your local payments-listener endpoint is working as expected by browsing to https://localhost:9006/adyen on your host machine (you should see a SOAP Bad Request warning when hitting that endpoint via a browser - which means the SoapServer is working)
  2. Signup, download & unzip ngrok to a location in your $PATH (e.g. /usr/local/bin)
  3. Launch ngrok on your host machine and point it to your local payments-listener endpoint using the following:
$ ngrok http https://localhost:9006
  1. Log into the Adyen Test console here https://ca-test.adyen.com/ca/ca/login.shtml
    1. Go to Accounts > Server Communication
    2. Add a new 'Standard Notification' profile (you should see existing profiles with URLs pointing to other test endpoints)
    3. Drop in your ngrok generated URL with the route for Adyen (e.g. http://6bb27a9c.ngrok.io/adyen)
    4. Set method to SOAP
    5. At this point you can scroll to the bottom and click the 'Test Configuration' button which should trigger a bunch of SOAP calls to your local payments listener via the ngrok URL. Check out the ngrok terminal display to see a list of received incoming requests e.g:
    6. If the above worked as expected. Save the configuration. You can also tweak the profile settings to suit your needs.
  2. Submit an Adyen test donation via your local Paymentswiki using the Test URL for vagrant users above. If you want to see the raw SOAP XML Adyen sends in the IPN after you donate, open a terminal window on your vagrant vm and drop in:
sudo tail -f /var/log/syslog | grep --color=always soap
  1. You should now have a message in your local redis jobs-adyen queue as a result of the IPN being received and processed. You can read more about the job messages generated and data flow of Adyen here
  2. (Optional Step) If the messages disappear from your queues too quickly for your liking it's because your Smashpig Adyen QueueJobRunner cron is processing those for you. Head over to /etc/cron.d/SmashPig and comment out the Adyen QueueJobRunner cron if you'd like to run it yourself and debug further. You can then run it manually by using:
/vagrant/srv/SmashPig$ php Maintenance/QueueJobRunner.php --queue jobs-adyen --config-node adyen

Amazon

TODO

Astropay

TODO

Test URL: http://payments.wiki.local.wmftest.net:8080/wiki/Special:AstroPayGateway?appeal=JimmyQuote&payment_method=cc&recurring=&uselang=en&language=en&currency_code=BRL&amount=100&country=BR&ffname=astropay

GlobalCollect (Legacy Ingenico)

You must use the full vpn because they whitelist the source IP. $wgGlobalCollectGatewayMerchantID must be set to the correct value and the API endpoint should be the one with the .nl TLD.

Test URL: http://payments.wiki.local.wmftest.net:8080/wiki/Special:GlobalCollectGateway?appeal=JimmyQuote&ffname=cc-vmad&recurring=&payment_method=cc&utm_key=&referrer=&language=en&country=US&returnto=Thank_You%2525252Fen&amountGiven=&currency_code=USD&frequency=onetime&amount=3&uselang=en

IDEAL BPay Test URL (Netherlands bank transfer): http://payments.wiki.local.wmftest.net:8080/wiki/Special:GlobalCollectGateway?appeal=JimmyQuote&recurring=&payment_method=obt&utm_key=&language=en&country=AU&returnto=Thank_You%252Fen&amountGiven=&currency_code=AUD&frequency=onetime&amount=3&uselang=en

Ingenico Connect

No VPN needed! Note that account configuration lives in the SmashPig yaml files rather than in LocalSettings.php.

PayPal Express Checkout

TODO

Test URL: http://payments.wiki.local.wmftest.net:8080/wiki/Special:PaypalExpressGateway?country=JP&amount=500&payment_method=paypal

Braintree

Sandbox Credential at line 328 config-private/payments/LocalSettings-private.php

Test Url:

https://localhost:9001/index.php?title=Special:BraintreeGateway&appeal=JimmyQuote&payment_method=paypal&recurring=0&uselang=en&language=en&currency=USD&amount=10&country=US&debug=true

  • test connection by ping the api, if see pong as response then api is connected:
    • go inside smashpig box: then run `php PaymentProviders/Braintree/Maintenance/TestApi.php`
  • unit test for audit parse reports
    • go inside civi box
      • run `./vendor/bin/phpunit --group Braintree` from /srv/civi-sites/wmff
    • go to smashpig box
      • run `./vendor/bin/phpunit --group Braintree`
  • test get reports and then audit parse reports:
    • go inside civi wmff box
      • run `php ./vendor/wikimedia/smash-pig/PaymentProviders/Braintree/Maintenance/SearchTransactions.php` to save default yesterday's transactions reports (report, refund, chargeback) under 'drupal/sites/default/files/wmf_audit/braintree/incoming' folder with name as `settlement_batch_report_<dispute/refund>_<date>
      • hint: can add hrs and type at the end of SearchTransactions.php as `php ./vendor/wikimedia/smash-pig/PaymentProviders/Braintree/Maintenance/SearchTransactions.php --r=90 --t=refund` then it will get the refund report from 90 hrs till now.
  • test parse reports from civi
    • go inside civi box
      • run `drush parse-audit braintree` from /srv/civi-sites/wmff/drupal