Skip to content

Commit

Permalink
Merge pull request #3 from digitickets/Use_transaction_id_for_descrip…
Browse files Browse the repository at this point in the history
…tion

Setting description to transaction id
  • Loading branch information
rquadling authored Oct 23, 2018
2 parents b403b05 + 469b93a commit b3c8d9b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 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
2 changes: 1 addition & 1 deletion tests/Messages/PurchaseRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function testGetData()
]
);
$ref = "Hello Ma!";
$request->setTransactionReference($ref);
$request->setTransactionId($ref);
$request->setFundCode(8);
$request->setItems(
[
Expand Down

0 comments on commit b3c8d9b

Please sign in to comment.