diff --git a/README.md b/README.md index dbb1eb7..c8d63af 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/Message/ExpressCompletePurchaseResponse.php b/src/Message/ExpressCompletePurchaseResponse.php index e0ff794..551c058 100644 --- a/src/Message/ExpressCompletePurchaseResponse.php +++ b/src/Message/ExpressCompletePurchaseResponse.php @@ -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(); + } }