pear:packages:payment_process2

This is an old revision of the document!


Payment_Process2

A PHP5 rework of payment_process

Developers: doconnor, dbezborodow

Migrating

To migrate code which uses payment_process

  1. Find and replace Payment_Process to Payment_Process2
  2. Find and replace Payment/Process to Payment/Process2
  3. If you set up any driver specific options with curl, you will need to swap to injecting a preconfigured instance of HTTP_Request2.
$payment = Payment_Process::factory('MyDriver');
$payment->setOption('curl_options', array('monkeys' => true));

becomes

$adapter = new HTTP_Request2_Adapter_Curl();
$adapter->setOption('monkies', true);
 
$request = new HTTP_Request2($adapter);
 
$payment = Payment_Process2::factory('MyDriver', $request);

Implementing a driver

You need to implement two classes and some unit tests.

The first is Payment_Process2_YourDriver, which should implement all of the methods in the interfacePayment_Process2_Driver.

The second is Payment_Process2_Result_YourDriver, which should implement all of the methods in the interfacePayment_Process2_Result_Driver.

The interface documentation should provide more detail on this.

Testing a driver

You want to build a small script pointed at a test server which var_dump()s out results. This is used to quickly verify that it actually works. You take that test data and save it in tests/data/Driver/foo.html

To test the driver; implement coverage of:

  1. It calls the HTTP_Request object to send off a request via process()
  2. It reads the response from the server and makes a result object via process()
  3. It renders a request correctly via process()
  4. It builds any request data correctly via prepareRequestData()
public function testShouldSendPaymentsAndReturnResults() {
    $response = new HTTP_Request2_Response('HTTP/1.1 200 OK');
    $response->appendBody(file_get_contents(dirname(__FILE__) . '/tests/data/Driver/foo.html'));
 
    $adapter = new HTTP_Request2_Adapter_Mock();
    $adapter->addResponse($response);
 
    $request = new HTTP_Request2($adapter);
 
    $payment = Payment_Process2::factory('Driver', $request);
 
    $result = $payment->process();
 
    $this->assertSame($expected_code, $result->getCode());
    $this->assertSame($expected_message, $result->getMessage());
}

You also want very good coverage of your result object, which a variety of test cases like:

public function testShouldParseDataAndPopulateResultObject() {
    $data = file_get_contents(dirname(__FILE__) . '/tests/data/Driver/foo.html');
 
    $fake_driver = new Payment_Process2_YourDriver(new HTTP_Request2());
    $result = new Payment_Process2_Result_YourDriver($data, $fake_driver);
 
    $result->parse();
 
    $this->assertSame($expected_code, $result->getCode());
    $this->assertSame($expected_message, $result->getMessage());
}

Roadmap

0.1.0

  • Get approval for open sourcing work
  • Swap to PHP5, HTTP_Request2
  • Swap to Interfaces as needed
  • Unit test coverage (mocked out) for all drivers
    • Running into problems here with many providers
      • TrustCommerce - inprogress
      • Paypal - TBA
      • Transfirst - TBA
      • Linkpoint - TBA
      • Bibit - TBA
      • AuthorizeNet - TBA
    • Lots of errors and E_NOTICEs from existing drivers
    • Lots of failures in test coverage
    • Test coverage is not extensive!
    • Need to improve the test case loaders and what have you
  • Dropping Paycom/Epoch driver Dropped
    • Support people won't give access to test environment
    • doconnor has mailed other open source projects which provide paycom drivers to see if he can get test data
  • Swap to Exceptions as needed Done.

0.2.0

  • Add a new driver for an Australian Bank (Payment_Process2_ANZ) 1)
  • Add a new driver for Paygea (Payment_Process2_Paygea) Licences

0.3.0

1)
needs clearing
pear/packages/payment_process2.1235711424.txt.gz · Last modified: 2017/09/22 13:28 (external edit)