thephpleague / omnipay-payflow

Payflow driver for the Omnipay PHP payment processing library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

is getCardReference() deprecated?

voveson opened this issue · comments

In the documentation at the top of src/message/CreateCardRequest, we have the following example:

// Create a credit card object
// This card can be used for testing.
$card = new CreditCard(array(
            'firstName'    => 'Example',
            'lastName'     => 'Customer',
            'number'       => '4242424242424242',
            'expiryMonth'  => '01',
            'expiryYear'   => '2020',
            'cvv'          => '123',
));

// Do a create card transaction on the gateway
$transaction = $gateway->createCard(array(
    'card'                     => $card,
));

$response = $transaction->send();

if ($response->isSuccessful()) {
    echo "Create Card transaction was successful!\n";
    $card_id = $response->getCardReference();
    echo "Card reference = " . $card_id . "\n";
}

However, calling getCardReference() on the successful response results in the following exception:

[Symfony\Component\Debug\Exception\FatalThrowableError]                        
Call to undefined method Omnipay\Payflow\Message\Response::getCardReference()

Has this method been deprecated? If so, what is the appropriate replacement that can be used to get the card reference?

commented

No, in fact it's a bug. The documentation states what should happen but nobody has ever implemented the getCardReference() method on the Response class. TBH I'm not sure where to get the card reference from the response data so if you know how to do it then perhaps submit a PR.

The card reference is the PNREF that is returned. Before this method existed we had to run a $1 authorization to store a card, and then do sale transactions using the PNREF from the authorization (it's good for a year, though PayPal had told us it wouldn't expire when they originally advised this path).

I could map the getCardReference to the PNREF but that call is only really valid on a CreateCard "L" or Authorization "A" transaction. In any case, it's a synonym for getTransactionReference().

I'll do a PR and see what you think.

commented

Merged PRs so this should be fixed now.