User:Katie Horn/TODO new gateway create documentation

From Wikitech
Jump to navigation Jump to search

This is intended to (eventually) be a guide to adding a new gateway implementation to DonationInterface.

  1. Create the files. These usually live under DonationInterface/[new_gateway]_gateway/. You will need to create the following:
    • The gateway adapter child object (extending GatewayAdapter) - [new_gateway].adapter.php
    • the gateway-specific special page that will instantiate the gateway adapter object and load the correct form(s) - [new_gateway]_gateway.body.php
  2. In DonationInterface.php: Add all the required gateway include information. ***this is way weirder than most extensions***
    • $optionalParts will need a [new_gateway] key.
    • Conditional class includes. Include statements for the files you need, contained in a block that looks like if ( $optionalParts['new_gateway'] === true ){
    • Conditional gateway-specific globals. Contains things like account-specific details and contact URLs, that can be overridden by identically-named globals in LocalSettings.php
    • Conditional gateway-specific i18n references. Same deal.
  3. In LocalSettings.php
    • Turn the gateway on by setting $wgDonationInterfaceEnable[new_gateway] = true;
    • Add all specific account information overrides, after the DonationInterface include statement.
  4. Just for fun, go to your http://localhost/index.php/Special:[new_gateway]Gateway and verify that it's telling you something like: "Fatal error: Class [new_gateway]Adapter contains 15 abstract methods and must therefore be declared abstract or implement the remaining methods (GatewayType::getResponseStatus, GatewayType::getResponseErrors, GatewayType::getResponseData, ...) in /srv/mw_extensions/DonationInterface/[new_gateway]_gateway/[new_gateway].adapter.php on line 23". This is actually a good thing.
  5. Implement the abstract methods that are being complained about, in your gateway adapter class.
  6. Add a constructor test.
    • Clone one of the less complicated directories in DonationInterface/tests/Adapter/.
    • Rename everything in that directory to reflect that the test is for [new_gateway].
    • Alter the AllTests.php file inside the new directory, to reference your new gateway instead of the old one.
    • Alter the AllTests.php file one level up, to reference the new directory.
    • Cuss a bit at how lame this process is, and put an angry @TODO somewhere that swears to rip the whole thing out someday.
    • Add a new test adapter that extends the adapter you want to test, in DonationInterface/tests/includes/test.adapter.php
    • Alter the Test Case for the new adapter in all appropriate ways (don't forget the @group)
    • run php phpunit.php --group [new_adapter] and verify that the right test is running