Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 858cece

Browse files
committed
feat(Payment): add method 'cancel' to cancel pre-authorized payments
1 parent 32d70e7 commit 858cece

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

tests/Resource/PaymentTest.php

+32
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,36 @@ public function testCapturePreAuthorizedMultiPayment()
121121

122122
$this->assertEquals('AUTHORIZED', $captured_payment->getStatus());
123123
}
124+
125+
public function testCancelPreAuthorizedMultiPayment()
126+
{
127+
$this->mockHttpSession($this->body_multiorder);
128+
$order = $this->createMultiorder()->create();
129+
$this->mockHttpSession($this->body_cc_multipay);
130+
$payment = $order->multipayments()
131+
->setCreditCard(5, 2018, '4012001037141112', 123, $this->createCustomer())
132+
->setDelayCapture(true)
133+
->execute();
134+
135+
$this->mockHttpSession($this->body_cancel_multipay);
136+
$cancelled_payment = $payment->cancel();
137+
138+
$this->assertEquals('CANCELLED', $cancelled_payment->getStatus());
139+
}
140+
141+
public function testCancelPreAuthorizedPayment()
142+
{
143+
$this->mockHttpSession($this->body_order);
144+
$order = $this->createOrder()->create();
145+
$this->mockHttpSession($this->body_cc_delay_capture);
146+
$payment = $order->payments()
147+
->setCreditCard(5, 2018, '5555666677778884', 123, $this->createCustomer(), false)
148+
->setDelayCapture(true)
149+
->execute();
150+
151+
$this->mockHttpSession($this->body_cancel_pay);
152+
$cancelled_payment = $payment->cancel();
153+
154+
$this->assertEquals('CANCELLED', $cancelled_payment->getStatus());
155+
}
124156
}

tests/TestCase.php

+4
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ public function __construct()
167167
$this->body_capture_pay = $this->readJsonFile('jsons/payment/capture');
168168

169169
$this->body_capture_multipay = $this->readJsonFile('jsons/multipayment/capture');
170+
171+
$this->body_cancel_pay = $this->readJsonFile('jsons/payment/cancel_pre_authorized');
172+
173+
$this->body_cancel_multipay = $this->readJsonFile('jsons/multipayment/cancel_pre_authorized');
170174
}
171175

172176
/**

0 commit comments

Comments
 (0)