Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
* Change debug logging of failed tests that depend on another one to work as expected.
* Several minor changes.

### Added
* Extended testing for Instalment payment type.

### Changed
* Remove PhpUnit 8 support.

## [1.1.1.0]

### Changed
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": ">6.5 <9.0",
"phpunit/phpunit": ">6.5 <8.0",
"friendsofphp/php-cs-fixer": "^2.0"
},
"suggest": {
Expand Down
71 changes: 67 additions & 4 deletions test/integration/PaymentTypes/InstallmentSecuredTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

use UnzerSDK\Constants\ApiResponseCodes;
use UnzerSDK\Exceptions\UnzerApiException;
use UnzerSDK\Resources\AbstractUnzerResource;
use UnzerSDK\Resources\Customer;
use UnzerSDK\Resources\CustomerFactory;
use UnzerSDK\Resources\EmbeddedResources\Address;
Expand Down Expand Up @@ -81,7 +82,7 @@ public function instalmentPlanShouldBeSelectable(): void
*
* @test
*/
public function hddTypeShouldBeFechable(): InstallmentSecured
public function hddTypeShouldBeFetchable(): InstallmentSecured
{
// Mock a hdd Type
$date = $this->getTodaysDateString();
Expand Down Expand Up @@ -130,17 +131,18 @@ public function hddTypeShouldBeFechable(): InstallmentSecured
* Verify fetched hdd type can be authorized and charged
*
* @test
* @depends hddTypeShouldBeFechable
* @depends hddTypeShouldBeFetchable
*
* @param InvoiceSecured $hddType fetched ins type.
* @param InstallmentSecured $hddType fetched ins type.
*
* @return AbstractUnzerResource|Charge
* @throws UnzerApiException
*/
public function hddTypeAuthorizeAndCharge(InstallmentSecured $hddType)
{
$customer = $this->getMaximumCustomer();
$basket = $this->createBasket();
/** @var Authorization $auth */

$auth = $hddType->authorize(119.00, 'EUR', 'https://unzer.com', $customer, null, null, $basket);
$charge = $auth->getPayment()->charge();
$this->assertNotNull($auth);
Expand Down Expand Up @@ -320,6 +322,67 @@ public function verifyPartlyCancelChargedInstallmentSecured(): void
$this->assertTrue($payment->isCompleted());
}

/**
* Verify full cancel of charged HP after shipment.
*
* @test
*
* @depends verifyChargingAnInitializedInstallmentSecured
*/
public function verifyChargeAndFullCancelAnInitializedInstallmentSecuredAfterShipment(): void
{
$yesterday = $this->getYesterdaysTimestamp();
$plans = $this->unzer->fetchInstallmentPlans(119.0, 'EUR', 4.99, $yesterday);
$this->assertGreaterThan(0, count($plans->getPlans()));

/** @var InstalmentPlan $selectedPlan */
$selectedPlan = $plans->getPlans()[0];
$ins = new InstallmentSecured($selectedPlan, 'DE89370400440532013000', 'Manuel Weißmann', $yesterday, 'COBADEFFXXX', $this->getTodaysDateString(), $this->getTomorrowsTimestamp());
$this->unzer->createPaymentType($ins);

$authorize = $ins->authorize(119.0, 'EUR', self::RETURN_URL, $this->getCustomer(), null, null, $basket = $this->createBasket());
$payment = $authorize->getPayment();

$hddCharge = $payment->charge();
$invoiceId = 'i' . self::generateRandomId();
$ship = $this->unzer->ship($hddCharge->getPayment(), $invoiceId);
$this->assertNotNull($ship);

$cancel = $payment->cancelAmount();
$this->assertGreaterThan(0, count($cancel));
}

/**
* Verify full cancel of charged HP after shipment.
*
* @test
*
* @depends verifyChargingAnInitializedInstallmentSecured
*/
public function verifyPartlyCancelChargedInstallmentSecuredAfterShipment(): void
{
$yesterday = $this->getYesterdaysTimestamp();
$plans = $this->unzer->fetchInstallmentPlans(119.0, 'EUR', 4.99, $yesterday);
$this->assertGreaterThan(0, count($plans->getPlans()));

/** @var InstalmentPlan $selectedPlan */
$selectedPlan = $plans->getPlans()[0];
$ins = new InstallmentSecured($selectedPlan, 'DE89370400440532013000', 'Manuel Weißmann', $yesterday, 'COBADEFFXXX', $this->getTodaysDateString(), $this->getTomorrowsTimestamp());
$this->unzer->createPaymentType($ins);

$authorize = $ins->authorize(119.0, 'EUR', self::RETURN_URL, $this->getCustomer(), null, null, $basket = $this->createBasket());
$payment = $authorize->getPayment();

$hddCharge = $payment->charge();
$invoiceId = 'i' . self::generateRandomId();
$ship = $this->unzer->ship($hddCharge->getPayment(), $invoiceId);
$this->assertNotNull($ship);

$cancel = $payment->cancelAmount(59.5, null, null, 50.0, 9.5);
$this->assertCount(1, $cancel);
$this->assertTrue($payment->isCompleted());
}

//</editor-fold>

//<editor-fold desc="Helper">
Expand Down