Skip to content

Commit b3c8d9b

Browse files
authored
Merge pull request #3 from digitickets/Use_transaction_id_for_description
Setting description to transaction id
2 parents b403b05 + 469b93a commit b3c8d9b

File tree

5 files changed

+29
-14
lines changed

5 files changed

+29
-14
lines changed

src/AbstractPay360Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ protected function getEndpoint()
9090
protected function getCredentials()
9191
{
9292
$this->requestIdentification = new \scpService_requestIdentification();
93-
$this->requestIdentification->uniqueReference = 'DT'.date('U');
93+
$this->requestIdentification->uniqueReference = 'DT'.date('YmdHisu');
9494
$this->requestIdentification->timeStamp = (new DateTime('now', new DateTimeZone('UTC')))->format('YmdHis'); // Format: YYYYMMDDHHMMSS
9595

9696
$subject = new \scpService_subject();

src/Messages/CompletePurchaseRequest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function getData()
1919
public function sendData($data)
2020
{
2121
foreach ($this->getGateway()->getListeners() as $listener) {
22-
$listener->update('completeSend', $t);
22+
$listener->update('completeSend', $data);
2323
}
2424

2525
try {
@@ -44,8 +44,8 @@ public function sendData($data)
4444

4545
foreach ($this->getGateway()->getListeners() as $listener) {
4646
$listener->update('completeReceive', $scpSimpleQueryResponse);
47-
$listener->update('completeExceptionSend', $scpClient->__getLastRequest());
48-
$listener->update('completeExceptionRcv', $scpClient->__getLastResponse());
47+
$listener->update('completeSend', $scpClient->__getLastRequest());
48+
$listener->update('completeRcv', $scpClient->__getLastResponse());
4949
}
5050

5151
return $this->response = new CompletePurchaseResponse($this, $scpSimpleQueryResponse);

src/Messages/CompletePurchaseResponse.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,36 @@ public function getTransactionId()
1616

1717
public function getTransactionReference()
1818
{
19-
return $this->getData()->scpReference;
19+
if ($this->getData()) {
20+
return $this->getData()->scpReference;
21+
}
22+
23+
return '';
2024
}
2125

2226
public function getCode()
2327
{
24-
return $this->getData()->paymentResult->errorDetails->errorId;
28+
if ($this->getData() && $this->getData()->paymentResult && $this->getData()->paymentResult->errorDetails) {
29+
return $this->getData()->paymentResult->errorDetails->errorId;
30+
}
31+
return 0;
2532
}
2633

2734
public function getMessage()
2835
{
29-
return $this->getData()->paymentResult->errorDetails->errorMessage;
36+
if ($this->getData() && $this->getData()->paymentResult && $this->getData()->paymentResult->errorDetails) {
37+
return $this->getData()->paymentResult->errorDetails->errorMessage;
38+
}
39+
40+
return '';
3041
}
3142

3243
public function isSuccessful()
3344
{
34-
return $this->getData()->paymentResult->status == 'SUCCESS';
45+
if ($this->getData() && $this->getData()->paymentResult) {
46+
return $this->getData()->paymentResult->status == 'SUCCESS';
47+
}
48+
49+
return false;
3550
}
3651
}

src/Messages/PurchaseRequest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function getData()
6969
$routing->scpId = $this->getRoutingScpId();
7070

7171
$saleSummary = new \scpService_summaryData();
72-
$saleSummary->description = $this->getTransactionReference();
72+
$saleSummary->description = $this->getTransactionId();
7373
$saleSummary->amountInMinorUnits = $this->getAmountInteger();
7474

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

140140
foreach ($this->getGateway()->getListeners() as $listener) {
141141
$listener->update('purchaseReceive', $scpSimpleInvokeResponse);
142-
$listener->update('receiveExceptionSend', $scpClient->__getLastRequest());
143-
$listener->update('receiveExceptionRcv', $scpClient->__getLastResponse());
142+
$listener->update('purchaseSend', $scpClient->__getLastRequest());
143+
$listener->update('purchaseRcv', $scpClient->__getLastResponse());
144144
}
145145

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

tests/Messages/PurchaseRequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function testGetData()
2121
]
2222
);
2323
$ref = "Hello Ma!";
24-
$request->setTransactionReference($ref);
24+
$request->setTransactionId($ref);
2525
$request->setFundCode(8);
2626
$request->setItems(
2727
[

0 commit comments

Comments
 (0)