From a0ab203f93b0db1599f1dfe85e4c3a6fb5b08bfe Mon Sep 17 00:00:00 2001 From: Christiaan Goossens Date: Sun, 2 Apr 2017 11:54:34 +0200 Subject: [PATCH] Finialized plugin --- README.md | 7 ++++++- src/Message/AbstractResponse.php | 2 +- src/Message/CompletePurchaseRequest.php | 6 +++--- src/Message/CompletePurchaseResponse.php | 2 +- src/Message/PurchaseRequest.php | 6 +++--- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6100692..da979b9 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ repository. )); // Start the purchase - if (!isset($_GET['trxid'])) { + if (!isset($_GET['trxid']) && !isset($_GET['error'])) { $url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; $response = $gateway->purchase(array( 'amount' => "1.50", @@ -67,6 +67,8 @@ repository. // payment failed: display message to customer return "Error " .$response->getError(); } + } elseif (isset($_GET['error'])) { + echo "Error " . $_GET['error']; } else { /** * Because the 'status' GET parameter is present, this is a return URL request and the purchase should be completed. @@ -81,6 +83,9 @@ repository. } ``` +## Server response +After sending the purchaseRequest, the server at Inforbank will return a POST body with the redirect URL. After redirecting to the redirect URL, the user will interact with Inforbank. Inforbank will then, depending on user interaction and configuration, return to your application with either ?trxid={ID} or ?error={ERRORMESSAGE}. + ## Support If you are having general issues with Omnipay, we suggest posting on diff --git a/src/Message/AbstractResponse.php b/src/Message/AbstractResponse.php index 4356665..c65ab22 100644 --- a/src/Message/AbstractResponse.php +++ b/src/Message/AbstractResponse.php @@ -19,6 +19,6 @@ abstract class AbstractResponse extends BaseAbstractResponse public function getError() { - return $this['error']; + return $this->error; } } diff --git a/src/Message/CompletePurchaseRequest.php b/src/Message/CompletePurchaseRequest.php index 32d2a99..6365db2 100644 --- a/src/Message/CompletePurchaseRequest.php +++ b/src/Message/CompletePurchaseRequest.php @@ -4,11 +4,11 @@ namespace Omnipay\Inforbank\Message; class CompletePurchaseRequest extends AbstractRequest { - protected $endpoint = "http://localhost:8080/api/statusRequest"; + protected $endpoint = "http://sgni.nl/~113004/index.php/api/statusRequest"; protected function generateSignature() { - return sha1( + return hash("sha256", $this->getTransactionReference() . $this->getClientSecret() ); } @@ -23,7 +23,7 @@ class CompletePurchaseRequest extends AbstractRequest $data = array( "clientId" => $this->getClientId(), "transactionId" => $this->getTransactionReference(), - "sha1" => $this->generateSignature() + "hash" => $this->generateSignature() ); return $data; diff --git a/src/Message/CompletePurchaseResponse.php b/src/Message/CompletePurchaseResponse.php index 7672bb6..ae9cfdf 100644 --- a/src/Message/CompletePurchaseResponse.php +++ b/src/Message/CompletePurchaseResponse.php @@ -6,7 +6,7 @@ class CompletePurchaseResponse extends PurchaseResponse { public function isSuccessful() { - return ($this->data['transaction']['status'] === "Success"); + return ($this->data['transaction']['status'] === 2); } public function isRedirect() diff --git a/src/Message/PurchaseRequest.php b/src/Message/PurchaseRequest.php index c9e0442..b83cf6c 100644 --- a/src/Message/PurchaseRequest.php +++ b/src/Message/PurchaseRequest.php @@ -4,11 +4,11 @@ namespace Omnipay\Inforbank\Message; class PurchaseRequest extends AbstractRequest { - protected $endpoint = "http://localhost:8080/api/transactionRequest"; + protected $endpoint = "http://sgni.nl/~113004/index.php/api/transactionRequest"; protected function generateSignature() { - return sha1( + return hash("sha256", $this->getTransactionId() . $this->getAmountInteger() . $this->getClientSecret() ); } @@ -27,7 +27,7 @@ class PurchaseRequest extends AbstractRequest "amount" => $this->getAmountInteger(), "description" => $this->getDescription(), "returnUrl" => $this->getReturnUrl(), - "sha1" => $this->generateSignature() + "hash" => $this->generateSignature() ); return $data;