adrianmacneil/omnipay — pull request #111 by lfjeff (2013-08-06 21:12:18+00:00)
Title: Added cardReference and void support to Paypal Pro and Payflow

I made a few fixes to allow Paypal Pro and Payflow to support cardReference and void transactions.

Sometimes you may need to use the same credit card, but with a different billing address. This is useful when the original transaction may have failed because of a bad AVS match. If the transaction is resubmitted with the correct billing address, it will be approved.

Many ecommerce sites do an initial authorization when they accept an order. The authorization may be good, but the order is placed on hold because of an AVS billing address mismatch. Many times the problem can be fixed by contacting the customer and getting the correct billing address and running another authorization with the new address. Usually, you can just do an auth for a small amount (like $0.01). Many processors even allow you to submit a zero dollar authorization (which just does an AVS check).

Only a few of your supported gateways in Omnipay appear to support cardReference transactions and it did not look like any of them allow you to override the original parameters.

To solve this problem, I coded things to allow BOTH the "card" and "cardReference" variables. If the "card" object is set, it will override the settings for the original transaction. If not, the original transaction settings will be used. I've written similar interfaces for other gateways and if new variables are set, they will override the original ones.

Here's an example of how to do a new authorization with a different billing address:

$cardReference = '1234567XYZ';
$amount = '0.01';
$input[billingAddress] = '123 New Street';
$input[billingCity] = 'Chicago';
$input[billingPostcode] = '66666';
$input[billingState] = 'IL';

$card = new CreditCard($input);
$request = $gateway->authorize([
'amount' => $amount,
'cardReference' => $cardReference,
'card' => $card, // override original settings
]);

I also fixed a few minor problems I discovered.