Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit baf32e0

Browse files
committed
Fixed wrong attributes mapping
1 parent 6d79fdd commit baf32e0

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Message/CompletePurchaseResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function isSuccessful()
5555
*/
5656
public function getTransactionId()
5757
{
58-
return $this->data->getId();
58+
return $this->getPosData()['posData']['u'];
5959
}
6060

6161
/**

tests/unit/Message/CompletePurchaseResponseTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class CompletePurchaseResponseTest extends TestCase
1414

1515
private $token = '';
1616
private $description = 'Test Transaction long description';
17-
private $transactionId = 'S4hVo7z6XZQ3yDUyHyUJD7';
17+
private $transactionId = 'someTransactionId';
1818
private $transactionReference = 'S4hVo7z6XZQ3yDUyHyUJD7';
1919
private $status = InvoiceStatus::Complete;
2020
private $amount = '14.01';
@@ -41,9 +41,9 @@ public function testSuccess()
4141
$invoice = new Invoice($this->amount, $this->currency);
4242
$invoice->setFullNotifications(true);
4343
$invoice->setItemDesc($this->description);
44-
$invoice->setPosData(json_encode(['posData' => []]));
44+
$invoice->setPosData(json_encode(['posData' => ['u' => $this->transactionId]]));
4545
$invoice->setStatus($this->status);
46-
$invoice->setId($this->transactionId);
46+
$invoice->setId($this->transactionReference);
4747
$response = new CompletePurchaseResponse($this->request, $invoice);
4848

4949
$this->assertTrue($response->isSuccessful());
@@ -52,7 +52,7 @@ public function testSuccess()
5252
$this->assertSame($this->transactionId, $response->getTransactionId());
5353
$this->assertSame($this->transactionReference, $response->getTransactionReference());
5454
$this->assertSame('14.01', $response->getAmount());
55-
$this->assertStringContainsString($this->transactionId, $response->getPayer());
55+
$this->assertStringContainsString($this->transactionReference, $response->getPayer());
5656
$this->assertSame($this->currency, $response->getCurrency());
5757
}
5858
}

0 commit comments

Comments
 (0)