Skip to content

Commit

Permalink
Fixed a bug where the transaction reference returned on a completePay…
Browse files Browse the repository at this point in the history
…ment repsonse was not obtaining the correct transaction ID.

Fixes #146
  • Loading branch information
lukeholder committed Nov 8, 2016
1 parent 0f894c6 commit 8c58fe1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ The following gateways are provided by this package:
For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay)
repository.

## Quirks

The transaction reference obtained from the purchase() response can't be used to refund a purchase. The transaction reference from the completePurchase() response is the one that should be used.

## Out Of Scope

Omnipay does not cover recurring payments or billing agreements, and so those features are not included in this package. Extensions to this gateway are always welcome.
Expand Down
24 changes: 24 additions & 0 deletions src/Message/ExpressCompletePurchaseResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,38 @@
*/
class ExpressCompletePurchaseResponse extends ExpressAuthorizeResponse
{
/*
* Is this complete purchase response successful? Will not be successful if it's a redirect response.
*
* @return bool
*/
public function isSuccessful()
{
$success = isset($this->data['ACK']) && in_array($this->data['ACK'], array('Success', 'SuccessWithWarning'));
return !$this->isRedirect() && $success;
}

/**
* The complete purchase response can be in error where it wants to have your customer return to paypal.
*
* @return bool
*/
public function isRedirect()
{
return isset($this->data['L_ERRORCODE0']) && in_array($this->data['L_ERRORCODE0'], array('10486'));
}

/**
* The transaction reference obtained from the purchase() call can't be used to refund a purchase.
*
* @return string
*/
public function getTransactionReference()
{
if ($this->isSuccessful() && isset($this->data['PAYMENTINFO_0_TRANSACTIONID'])) {
return $this->data['PAYMENTINFO_0_TRANSACTIONID'];
}

return parent::getTransactionReference();
}
}

0 comments on commit 8c58fe1

Please sign in to comment.