Skip to content

Commit

Permalink
[CC-1576] Remove redundancy.
Browse files Browse the repository at this point in the history
Preauthorization object can be used with existing authorization method.
  • Loading branch information
Ryouzanpaku committed Oct 30, 2024
1 parent 74b3de7 commit 756f8c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
18 changes: 1 addition & 17 deletions src/Unzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -685,26 +685,10 @@ public function performAuthorization(
return $this->paymentService->performAuthorization($authorization, $paymentType, $customer, $metadata, $basket);
}

public function updateAuthorization($payment, Authorization $authorization): Authorization
{
return $this->paymentService->updateAuthorization($payment, $authorization);
}

/**
* {@inheritDoc}
*/
public function performPreAuthorization(
Authorization $authorization,
$paymentType,
$customer = null,
Metadata $metadata = null,
Basket $basket = null
): Authorization
{
return $this->paymentService->performAuthorization($authorization, $paymentType, $customer, $metadata, $basket);
}

public function updatePreAuthorization($payment, Authorization $authorization): Authorization
public function updateAuthorization($payment, Authorization $authorization): Authorization
{
return $this->paymentService->updateAuthorization($payment, $authorization);
}
Expand Down
7 changes: 4 additions & 3 deletions test/integration/TransactionTypes/PreAuthorizationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function authorizeWithTypeId(): void
{
$paymentType = $this->unzer->createPaymentType($this->createCardObject());
$preauth = new PreAuthorization(100.0, 'EUR', self::RETURN_URL);
$this->unzer->performPreAuthorization($preauth, $paymentType->getId());
$this->unzer->performAuthorization($preauth, $paymentType->getId());
$this->assertNotNull($preauth);
$this->assertNotEmpty($preauth->getId());
$this->assertNotEmpty($preauth->getUniqueId());
Expand All @@ -59,7 +59,7 @@ public function authorizationProducesPaymentAndCustomer(): void
$this->assertNull($customer->getId());

$preauth = new PreAuthorization(100.0, 'EUR', self::RETURN_URL);
$this->unzer->performPreAuthorization($preauth, $paymentType, $customer);
$this->unzer->performAuthorization($preauth, $paymentType, $customer);
$payment = $preauth->getPayment();
$this->assertNotNull($payment);
$this->assertNotNull($payment->getId());
Expand All @@ -83,7 +83,7 @@ public function authorizationWithCustomerId(): Authorization
$customerId = $this->unzer->createCustomer($this->getMinimalCustomer())->getId();
$orderId = microtime(true);
$preauth = (new PreAuthorization(100.0, 'EUR', self::RETURN_URL))->setOrderId($orderId);
$this->unzer->performPreAuthorization($preauth, $paymentType, $customerId);
$this->unzer->performAuthorization($preauth, $paymentType, $customerId);
$payment = $preauth->getPayment();
$this->assertNotNull($payment);
$this->assertNotNull($payment->getId());
Expand All @@ -107,6 +107,7 @@ public function authorizationWithCustomerId(): Authorization
public function authorizationCanBeFetched(Authorization $authorization): void
{
$fetchedAuthorization = $this->unzer->fetchAuthorization($authorization->getPaymentId());
$this->assertInstanceOf(PreAuthorization::class, $fetchedAuthorization);
$this->assertEquals($authorization->setCard3ds(true)->expose(), $fetchedAuthorization->expose());
}

Expand Down

0 comments on commit 756f8c2

Please sign in to comment.