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

Commit

Permalink
feat(Payment): add method 'cancel' to cancel pre-authorized payments
Browse files Browse the repository at this point in the history
  • Loading branch information
caiogaspar committed Oct 2, 2017
1 parent 32d70e7 commit 858cece
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/Resource/PaymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,36 @@ public function testCapturePreAuthorizedMultiPayment()

$this->assertEquals('AUTHORIZED', $captured_payment->getStatus());
}

public function testCancelPreAuthorizedMultiPayment()
{
$this->mockHttpSession($this->body_multiorder);
$order = $this->createMultiorder()->create();
$this->mockHttpSession($this->body_cc_multipay);
$payment = $order->multipayments()
->setCreditCard(5, 2018, '4012001037141112', 123, $this->createCustomer())
->setDelayCapture(true)
->execute();

$this->mockHttpSession($this->body_cancel_multipay);
$cancelled_payment = $payment->cancel();

$this->assertEquals('CANCELLED', $cancelled_payment->getStatus());
}

public function testCancelPreAuthorizedPayment()
{
$this->mockHttpSession($this->body_order);
$order = $this->createOrder()->create();
$this->mockHttpSession($this->body_cc_delay_capture);
$payment = $order->payments()
->setCreditCard(5, 2018, '5555666677778884', 123, $this->createCustomer(), false)
->setDelayCapture(true)
->execute();

$this->mockHttpSession($this->body_cancel_pay);
$cancelled_payment = $payment->cancel();

$this->assertEquals('CANCELLED', $cancelled_payment->getStatus());
}
}
4 changes: 4 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ public function __construct()
$this->body_capture_pay = $this->readJsonFile('jsons/payment/capture');

$this->body_capture_multipay = $this->readJsonFile('jsons/multipayment/capture');

$this->body_cancel_pay = $this->readJsonFile('jsons/payment/cancel_pre_authorized');

$this->body_cancel_multipay = $this->readJsonFile('jsons/multipayment/cancel_pre_authorized');
}

/**
Expand Down

0 comments on commit 858cece

Please sign in to comment.