Skip to content

Commit 5e24d8f

Browse files
committed
Issue #3 Support isCancelled()
1 parent 925575c commit 5e24d8f

File tree

2 files changed

+51
-12
lines changed

2 files changed

+51
-12
lines changed

src/Traits/HasCompleteResponse.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ public function isSuccessful()
107107
return $status === Gateway::STATUS_SUCCESS || $status === Gateway::STATUS_ACCEPTED;
108108
}
109109

110+
/**
111+
* @return bool
112+
*/
113+
public function isCancelled()
114+
{
115+
$status = $this->getStatus();
116+
117+
return $status === Gateway::STATUS_CANCEL;
118+
}
119+
110120
/**
111121
* CHECKME: is the virtualCardno the same thing, but for specific payment methods?
112122
*

tests/Message/CompleteResponseTest.php

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function setUp()
1616
{
1717
parent::setUp();
1818

19-
$this->response = new CompleteResponse(
19+
$this->responseSuccess = new CompleteResponse(
2020
$this->getMockRequest(),
2121
[
2222
"merchantId" => "1100016000",
@@ -44,20 +44,49 @@ public function setUp()
4444
"expm" => "12",
4545
]
4646
);
47+
48+
$this->responseCancel = new CompleteResponse(
49+
$this->getMockRequest(),
50+
[
51+
"maskedCC" => "424242xxxxxx4242",
52+
"merchantId" => "1100016183",
53+
"aliasCC" => "70119122433810042",
54+
"uppTermsLink" => "https://example.co.uk/",
55+
"currency" => "GBP",
56+
"amount" => "2250",
57+
"uppReturnMaskedCC" => "yes",
58+
"uppWebResponseMethod" => "POST",
59+
"uppTransactionId" => "180820155020472779",
60+
"language" => "en",
61+
"theme" => "DT2015",
62+
"refno" => "134655588975",
63+
"testOnly" => "yes",
64+
"pmethod" => "VIS",
65+
"sign" => "66e480fd751555d707103fe0f66b7bfef8e55a416a57ff6f33f4d2daf58469d5",
66+
"status" => "cancel",
67+
"uppMsgType" => "web",
68+
]
69+
);
4770
}
4871

4972
public function testSuccess()
5073
{
51-
$this->assertSame('4242', $this->response->getNumberLastFour());
52-
$this->assertSame('XXXXXXXXXXXX4242', $this->response->getNumberMasked());
53-
$this->assertSame('424242xxxxxx4242', $this->response->getNumberMasked(null));
54-
$this->assertTrue($this->response->isSuccessful());
55-
$this->assertFalse($this->response->isRedirect());
56-
$this->assertSame(12, $this->response->getExpiryMonth());
57-
$this->assertSame(18, $this->response->getExpiryYear());
58-
$this->assertSame('12/18', $this->response->getExpiryDate('m/y'));
59-
$this->assertSame('e7e86bee-0ced-43b8-9ee9-e7fbb8d4ef31', $this->response->getTransactionId());
60-
$this->assertSame('180317175618647060', $this->response->getTransactionReference());
61-
$this->assertSame('VIS', $this->response->getUsedPaymentMethod());
74+
$this->assertSame('4242', $this->responseSuccess->getNumberLastFour());
75+
$this->assertSame('XXXXXXXXXXXX4242', $this->responseSuccess->getNumberMasked());
76+
$this->assertSame('424242xxxxxx4242', $this->responseSuccess->getNumberMasked(null));
77+
$this->assertTrue($this->responseSuccess->isSuccessful());
78+
$this->assertFalse($this->responseSuccess->isRedirect());
79+
$this->assertSame(12, $this->responseSuccess->getExpiryMonth());
80+
$this->assertSame(18, $this->responseSuccess->getExpiryYear());
81+
$this->assertSame('12/18', $this->responseSuccess->getExpiryDate('m/y'));
82+
$this->assertSame('e7e86bee-0ced-43b8-9ee9-e7fbb8d4ef31', $this->responseSuccess->getTransactionId());
83+
$this->assertSame('180317175618647060', $this->responseSuccess->getTransactionReference());
84+
$this->assertSame('VIS', $this->responseSuccess->getUsedPaymentMethod());
85+
}
86+
87+
public function testCancelled()
88+
{
89+
$this->assertFalse($this->responseCancel->isSuccessful());
90+
$this->assertTrue($this->responseCancel->isCancelled());
6291
}
6392
}

0 commit comments

Comments
 (0)