Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow running Credit transactions by referencing a Gateway Txn ID #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

uzlonewolf
Copy link

I submitted a project for certification by Heartland only to have it rejected because the Refund test case did not reference the original transaction. As the SDK did not allow these reference transactions, this patch adds support for it.

Although no additional data is required beyond the transactionId, the PaymentMethods/Credit class is protected so we needed to either remove the 'protected' keyword or create a new (empty) sub-class; I went with the latter and created PaymentMethods/CreditCardReference.

ITokenizable needed to be removed from PaymentMethods/Credit as otherwise Portico rejected the transaction due to <CardData><TokenRequest>N</TokenRequest></CardData> not being allowed when running transactions by the Gateway Txn ID without card data. ITokenizable was then added to PaymentMethods/CreditCardData and PaymentMethods/CreditTrackData so it's still sent when card data is present.

A new interface IReferencable was then created so we don't send <GatewayTxnId> with every transaction.

The withTransactionId() function in Builders/AuthorizationBuilder not only did not set $transactionId correctly, it also clobbered paymentMethod. This has been fixed.

To use, first either set $card = new CreditCardReference(); if you only have the Gateway Txn ID, or set $card = new CreditCardData(); and fill out the card data if you want to also pass the card number to the gateway. Then just
->withTransactionId( $gatewayTxnId ). Test case example:

    public function test034bCreditReturnByRef()
    {
        //$card = TestCards::masterCardManual();
        /* or */
        $card = new CreditCardReference();                                                                                                                                                            
        $response = $card->refund(15.15)
              ->withTransactionId( self::$gatewayTxnId )
	      ->withCurrency('USD')
              ->withInvoiceNumber('123456')
              ->withEcommerceInfo($this->ecommerceInfo)
              ->execute();

        $this->assertEquals(true, $response != null);
	$this->assertEquals('00', $response->responseCode);

    }

@slogsdon
Copy link
Contributor

@uzlonewolf Is there a need to include the card data in the refund request? When performing a refund, integrators typically reference a previous transaction or card data in the case of a blind return. This is mostly due to the fact that if both are supplied, the card number supplied in the refund request has to match the card number used in the original transaction, so there is typically no benefit to supply both.

If needed, here's an example of performing a refund when referencing a previous transaction:

Transaction::fromId($originaltransactionId)
    ->refund(10)
    ->execute();

@uzlonewolf
Copy link
Author

uzlonewolf commented Jul 29, 2021

@slogsdon No, it's not required, however Portico allows it if you would like to include it as a sanity check or something. This SDK did not allow it.

I initially tried several variations of that, however the spreadsheet I received which listed the test scripts I had to run listed "Invoice Number and Ship Date" as needed and the only way I found to include that information is with a Credit transaction type (trying with the above fromId() results in it blowing up with PHP Fatal error: Uncaught Error: Call to undefined method GlobalPayments\Api\Builders\ManagementBuilder::withEcommerceInfo()).

     	$response = Transaction::fromId('snip')
                  ->refund(10)
                  ->withCurrency('USD')
                  ->withInvoiceNumber('123456')
                  ->withEcommerceInfo($this->ecommerceInfo)
                  ->execute();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants