Update with the API in the main project
This commit is contained in:
parent
ea96709cec
commit
8ea09dde35
@ -65,7 +65,7 @@ repository.
|
|||||||
return "Pending, Reference: ". $response->getTransactionReference();
|
return "Pending, Reference: ". $response->getTransactionReference();
|
||||||
} else {
|
} else {
|
||||||
// payment failed: display message to customer
|
// payment failed: display message to customer
|
||||||
return "Error " .$response->getCode() . ': ' . $response->getMessage();
|
return "Error " .$response->getError();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/**
|
/**
|
||||||
@ -74,10 +74,9 @@ repository.
|
|||||||
// Check the status
|
// Check the status
|
||||||
$response = $gateway->completePurchase()->send();
|
$response = $gateway->completePurchase()->send();
|
||||||
if ($response->isSuccessful()) {
|
if ($response->isSuccessful()) {
|
||||||
$reference = $response->getTransactionReference(); // TODO; Check the reference/id with your database
|
$transaction = $response->getTransaction();
|
||||||
return "Transaction '" . $response->getTransactionId() . "' succeeded!";
|
|
||||||
} else {
|
} else {
|
||||||
return "Error " .$response->getCode() . ': ' . $response->getMessage();
|
return "Error " .$response->getError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -16,4 +16,9 @@ abstract class AbstractResponse extends BaseAbstractResponse
|
|||||||
$this->error = (string) $this->data->error;
|
$this->error = (string) $this->data->error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getError()
|
||||||
|
{
|
||||||
|
return $this->error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ class CompletePurchaseRequest extends AbstractRequest
|
|||||||
protected function generateSignature()
|
protected function generateSignature()
|
||||||
{
|
{
|
||||||
return sha1(
|
return sha1(
|
||||||
$this->getTransactionReference() . $this->getClientId() . $this->getClientSecret()
|
$this->getTransactionReference() . $this->getClientSecret()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,14 +20,13 @@ class CompletePurchaseRequest extends AbstractRequest
|
|||||||
|
|
||||||
public function getData()
|
public function getData()
|
||||||
{
|
{
|
||||||
$this->validate('merchantId', 'merchantKey');
|
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
"clientId" => $this->getClientId(),
|
"clientId" => $this->getClientId(),
|
||||||
"clientSecret" => $this->getClientSecret(),
|
|
||||||
"transactionId" => $this->getTransactionReference(),
|
"transactionId" => $this->getTransactionReference(),
|
||||||
"sha1" => $this->generateSignature()
|
"sha1" => $this->generateSignature()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendData($data)
|
public function sendData($data)
|
||||||
|
@ -14,8 +14,8 @@ class CompletePurchaseResponse extends PurchaseResponse
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStatus()
|
public function getTransaction()
|
||||||
{
|
{
|
||||||
return $this->data->transaction->status;
|
return $this->data->transaction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ class PurchaseRequest extends AbstractRequest
|
|||||||
protected function generateSignature()
|
protected function generateSignature()
|
||||||
{
|
{
|
||||||
return sha1(
|
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(
|
$data = array(
|
||||||
"clientId" => $this->getClientId(),
|
"clientId" => $this->getClientId(),
|
||||||
"clientSecret" => $this->getClientSecret(),
|
|
||||||
"transactionId" => $this->getTransactionId(),
|
"transactionId" => $this->getTransactionId(),
|
||||||
"amount" => $this->getAmountInteger(),
|
"amount" => $this->getAmountInteger(),
|
||||||
"description" => $this->getDescription(),
|
"description" => $this->getDescription(),
|
||||||
"returnUrl" => $this->getReturnUrl(),
|
"returnUrl" => $this->getReturnUrl(),
|
||||||
"sha1" => $this->generateSignature()
|
"sha1" => $this->generateSignature()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendData($data)
|
public function sendData($data)
|
||||||
|
@ -13,7 +13,7 @@ class PurchaseResponse extends AbstractResponse implements RedirectResponseInter
|
|||||||
|
|
||||||
public function isRedirect()
|
public function isRedirect()
|
||||||
{
|
{
|
||||||
return is_null($this->error);
|
return is_null($this->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isPending()
|
public function isPending()
|
||||||
|
Reference in New Issue
Block a user