Skip to content

Commit

Permalink
Setting description to transaction id
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksnellockdt committed Oct 23, 2018
1 parent 19d2a85 commit 0776dec
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/AbstractPay360Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected function getEndpoint()
protected function getCredentials()
{
$this->requestIdentification = new \scpService_requestIdentification();
$this->requestIdentification->uniqueReference = 'DT'.date('U');
$this->requestIdentification->uniqueReference = 'DT'.date('YmdHisu');
$this->requestIdentification->timeStamp = (new DateTime('now', new DateTimeZone('UTC')))->format('YmdHis'); // Format: YYYYMMDDHHMMSS

$subject = new \scpService_subject();
Expand Down
6 changes: 3 additions & 3 deletions src/Messages/CompletePurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function getData()
public function sendData($data)
{
foreach ($this->getGateway()->getListeners() as $listener) {
$listener->update('completeSend', $t);
$listener->update('completeSend', $data);
}

try {
Expand All @@ -44,8 +44,8 @@ public function sendData($data)

foreach ($this->getGateway()->getListeners() as $listener) {
$listener->update('completeReceive', $scpSimpleQueryResponse);
$listener->update('completeExceptionSend', $scpClient->__getLastRequest());
$listener->update('completeExceptionRcv', $scpClient->__getLastResponse());
$listener->update('completeSend', $scpClient->__getLastRequest());
$listener->update('completeRcv', $scpClient->__getLastResponse());
}

return $this->response = new CompletePurchaseResponse($this, $scpSimpleQueryResponse);
Expand Down
23 changes: 19 additions & 4 deletions src/Messages/CompletePurchaseResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,36 @@ public function getTransactionId()

public function getTransactionReference()
{
return $this->getData()->scpReference;
if ($this->getData()) {
return $this->getData()->scpReference;
}

return '';
}

public function getCode()
{
return $this->getData()->paymentResult->errorDetails->errorId;
if ($this->getData() && $this->getData()->paymentResult && $this->getData()->paymentResult->errorDetails) {
return $this->getData()->paymentResult->errorDetails->errorId;
}
return 0;
}

public function getMessage()
{
return $this->getData()->paymentResult->errorDetails->errorMessage;
if ($this->getData() && $this->getData()->paymentResult && $this->getData()->paymentResult->errorDetails) {
return $this->getData()->paymentResult->errorDetails->errorMessage;
}

return '';
}

public function isSuccessful()
{
return $this->getData()->paymentResult->status == 'SUCCESS';
if ($this->getData() && $this->getData()->paymentResult) {
return $this->getData()->paymentResult->status == 'SUCCESS';
}

return false;
}
}
10 changes: 5 additions & 5 deletions src/Messages/PurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function getData()
$routing->scpId = $this->getRoutingScpId();

$saleSummary = new \scpService_summaryData();
$saleSummary->description = $this->getTransactionReference();
$saleSummary->description = $this->getTransactionId();
$saleSummary->amountInMinorUnits = $this->getAmountInteger();

/** @var \scpService_simpleItem[]|\scpService_items $items */
Expand Down Expand Up @@ -131,16 +131,16 @@ public function sendData($data)
} catch (\Throwable $t) {
error_log($t->getMessage().' '.$t->getTraceAsString());
foreach ($this->getGateway()->getListeners() as $listener) {
$listener->update('receiveExceptionSend', $scpClient->__getLastRequest());
$listener->update('receiveExceptionRcv', $scpClient->__getLastResponse());
$listener->update('purchaseExceptionSend', $scpClient->__getLastRequest());
$listener->update('purchaseExceptionRcv', $scpClient->__getLastResponse());
}
return $this->response = new PurchaseResponse($this, $t);
}

foreach ($this->getGateway()->getListeners() as $listener) {
$listener->update('purchaseReceive', $scpSimpleInvokeResponse);
$listener->update('receiveExceptionSend', $scpClient->__getLastRequest());
$listener->update('receiveExceptionRcv', $scpClient->__getLastResponse());
$listener->update('purchaseSend', $scpClient->__getLastRequest());
$listener->update('purchaseRcv', $scpClient->__getLastResponse());
}

return $this->response = new PurchaseResponse($this, $scpSimpleInvokeResponse);
Expand Down

0 comments on commit 0776dec

Please sign in to comment.