Skip to content

Commit b084de6

Browse files
author
Honza Machala
committed
Added pending transactions flag
1 parent bbc7d81 commit b084de6

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

examples/test-finish.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
$gateway = GatewayFactory::createInstance($posId, $secondKey, $oAuthClientSecret, true);
1616

1717
try {
18-
$completeRequest = ['transactionId' => 'J9R4JP3F2G160825GUEST000P01'];
18+
$completeRequest = ['transactionReference' => 'J9R4JP3F2G160825GUEST000P01'];
1919
$response = $gateway->completePurchase($completeRequest);
2020

2121
echo "Is Successful: " . $response->isSuccessful() . PHP_EOL;

src/Messages/CompletePurchaseRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function sendData($data)
3636
'Content-Type' => 'application/json',
3737
'Authorization' => $data['accessToken']
3838
];
39-
$url = $data['apiUrl'] . '/api/v2_1/orders/' . urlencode($this->getTransactionId());
39+
$url = $data['apiUrl'] . '/api/v2_1/orders/' . urlencode($this->getTransactionReference());
4040
$httpRequest = $this->httpClient->get($url, $headers);
4141
$httpResponse = $httpRequest->send();
4242

src/Messages/CompletePurchaseResponse.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,23 @@ class CompletePurchaseResponse extends AbstractResponse
1111
*/
1212
public function isSuccessful()
1313
{
14-
return 'SUCCESS' === $this->data['status']['statusCode'] ? true : false;
14+
return 'SUCCESS' === $this->data['status']['statusCode'];
1515
}
1616

1717
/**
18-
* @return string
18+
* @return string|null
1919
*/
2020
public function getTransactionId()
2121
{
22-
return (string) $this->data['orders'][0]['extOrderId'];
22+
if (isset($this->data['orders'][0]['extOrderId'])) {
23+
return (string) $this->data['orders'][0]['extOrderId'];
24+
}
25+
return null;
26+
}
27+
28+
public function isCancelled()
29+
{
30+
return 'CANCELED' === $this->data['status']['statusCode'];
2331
}
2432

2533
/**
@@ -51,4 +59,8 @@ public function getCode()
5159
return $this->data['orders'][0]['status'];
5260
}
5361

62+
public function isPending()
63+
{
64+
return 'PENDING' === $this->data['status']['statusCode'];
65+
}
5466
}

0 commit comments

Comments
 (0)