diff --git a/README.md b/README.md index b40e37e..6100692 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ repository. return "Pending, Reference: ". $response->getTransactionReference(); } else { // payment failed: display message to customer - return "Error " .$response->getCode() . ': ' . $response->getMessage(); + return "Error " .$response->getError(); } } else { /** @@ -74,10 +74,9 @@ repository. // Check the status $response = $gateway->completePurchase()->send(); if ($response->isSuccessful()) { - $reference = $response->getTransactionReference(); // TODO; Check the reference/id with your database - return "Transaction '" . $response->getTransactionId() . "' succeeded!"; + $transaction = $response->getTransaction(); } else { - return "Error " .$response->getCode() . ': ' . $response->getMessage(); + return "Error " .$response->getError(); } } ``` diff --git a/src/Message/AbstractResponse.php b/src/Message/AbstractResponse.php index 307f88e..4b1bc97 100644 --- a/src/Message/AbstractResponse.php +++ b/src/Message/AbstractResponse.php @@ -16,4 +16,9 @@ abstract class AbstractResponse extends BaseAbstractResponse $this->error = (string) $this->data->error; } } + + public function getError() + { + return $this->error; + } } diff --git a/src/Message/CompletePurchaseRequest.php b/src/Message/CompletePurchaseRequest.php index a36c223..9f91724 100644 --- a/src/Message/CompletePurchaseRequest.php +++ b/src/Message/CompletePurchaseRequest.php @@ -9,7 +9,7 @@ class CompletePurchaseRequest extends AbstractRequest protected function generateSignature() { return sha1( - $this->getTransactionReference() . $this->getClientId() . $this->getClientSecret() + $this->getTransactionReference() . $this->getClientSecret() ); } @@ -20,14 +20,13 @@ class CompletePurchaseRequest extends AbstractRequest public function getData() { - $this->validate('merchantId', 'merchantKey'); - $data = array( "clientId" => $this->getClientId(), - "clientSecret" => $this->getClientSecret(), "transactionId" => $this->getTransactionReference(), "sha1" => $this->generateSignature() ); + + return $data; } public function sendData($data) diff --git a/src/Message/CompletePurchaseResponse.php b/src/Message/CompletePurchaseResponse.php index 309f2f9..c7b4164 100644 --- a/src/Message/CompletePurchaseResponse.php +++ b/src/Message/CompletePurchaseResponse.php @@ -14,8 +14,8 @@ class CompletePurchaseResponse extends PurchaseResponse return false; } - public function getStatus() + public function getTransaction() { - return $this->data->transaction->status; + return $this->data->transaction; } } diff --git a/src/Message/PurchaseRequest.php b/src/Message/PurchaseRequest.php index 7c07228..a3391a6 100644 --- a/src/Message/PurchaseRequest.php +++ b/src/Message/PurchaseRequest.php @@ -9,7 +9,7 @@ class PurchaseRequest extends AbstractRequest protected function generateSignature() { return sha1( - $this->getTransactionId() . $this->getAmountInteger() . $this->getClientId() . $this->getClientSecret() + $this->getTransactionId() . $this->getAmountInteger() . $this->getClientSecret() ); } @@ -23,13 +23,14 @@ class PurchaseRequest extends AbstractRequest $data = array( "clientId" => $this->getClientId(), - "clientSecret" => $this->getClientSecret(), "transactionId" => $this->getTransactionId(), "amount" => $this->getAmountInteger(), "description" => $this->getDescription(), "returnUrl" => $this->getReturnUrl(), "sha1" => $this->generateSignature() ); + + return $data; } public function sendData($data) diff --git a/src/Message/PurchaseResponse.php b/src/Message/PurchaseResponse.php index b2e72e0..e40255c 100644 --- a/src/Message/PurchaseResponse.php +++ b/src/Message/PurchaseResponse.php @@ -13,7 +13,7 @@ class PurchaseResponse extends AbstractResponse implements RedirectResponseInter public function isRedirect() { - return is_null($this->error); + return is_null($this->getError()); } public function isPending()