diff --git a/src/Services/HttpService.php b/src/Services/HttpService.php
index e8b4866f..4e4fb060 100755
--- a/src/Services/HttpService.php
+++ b/src/Services/HttpService.php
@@ -100,14 +100,14 @@ public function send(
?string $uri = null,
?AbstractUnzerResource $resource = null,
string $httpMethod = HttpAdapterInterface::REQUEST_GET,
- string $apiVersion = Unzer::API_VERSION
+ string $apiVersion = null
): string {
if (!$resource instanceof AbstractUnzerResource) {
throw new RuntimeException('Transfer object is empty!');
}
$unzerObj = $resource->getUnzerObject();
- $apiRequest = (new ApiRequest($uri, $resource, $httpMethod, $unzerObj, $apiVersion));
+ $apiRequest = (new ApiRequest($uri, $resource, $httpMethod, $unzerObj, $apiVersion ?? $resource->getApiVersion()));
return $this->sendRequest($apiRequest);
}
diff --git a/src/Services/IdService.php b/src/Services/IdService.php
index 1c2136da..231ba17c 100755
--- a/src/Services/IdService.php
+++ b/src/Services/IdService.php
@@ -117,7 +117,7 @@ public static function getResourceTypeFromIdString(string $typeId): ?string
return $typeIdString;
}
- public static function isUUDIResource(string $id): bool
+ public static function isUUIDResource(string $id): bool
{
preg_match('/^[sp]-([a-z]{3}|p24)-[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/', $id, $matches);
return count($matches) > 0;
diff --git a/src/Services/ResourceService.php b/src/Services/ResourceService.php
index ee1bfa7c..7436fb56 100755
--- a/src/Services/ResourceService.php
+++ b/src/Services/ResourceService.php
@@ -120,7 +120,7 @@ public function setUnzer(Unzer $unzer): ResourceServiceInterface
public function send(
AbstractUnzerResource $resource,
string $httpMethod = HttpAdapterInterface::REQUEST_GET,
- string $apiVersion = Unzer::API_VERSION
+ string $apiVersion = null
): stdClass
{
$apiConfig = $resource->getApiConfig();
@@ -346,7 +346,7 @@ public function deleteResource(AbstractUnzerResource &$resource): ?AbstractUnzer
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
* @throws Exception
*/
- public function fetchResource(AbstractUnzerResource $resource, string $apiVersion = Unzer::API_VERSION): AbstractUnzerResource
+ public function fetchResource(AbstractUnzerResource $resource, string $apiVersion = null): AbstractUnzerResource
{
$method = HttpAdapterInterface::REQUEST_GET;
$response = $this->send($resource, $method, $apiVersion);
@@ -553,16 +553,15 @@ public function createBasket(Basket $basket): Basket
public function fetchBasket($basket): Basket
{
$basketObj = $basket;
- $isV3Basket = false;
if (is_string($basket)) {
- $isV3Basket = IdService::isUUDIResource($basket);
+ $isV3Basket = IdService::isUUIDResource($basket);
$basketObj = $isV3Basket ? new BasketV3() : new Basket();
$basketObj->setId($basket);
}
$basketObj->setParentResource($this->unzer);
- $basketVersion = $isV3Basket ? ApiVersions::V3 : ApiVersions::V2;
+ $basketVersion = $basketObj->getApiVersion() === ApiVersions::V3 ? ApiVersions::V3 : ApiVersions::V2;
try {
$this->fetchResource($basketObj, $basketVersion);
@@ -658,7 +657,7 @@ public function fetchCustomer($customer): Customer
$customerObject = $customer;
if (is_string($customer)) {
- $isUUID = IdService::isUUDIResource($customer);
+ $isUUID = IdService::isUUIDResource($customer);
$customerObject = $isUUID ? new CustomerV2() : new Customer();
$customerObject->setId($customer);
}
diff --git a/test/integration/PaymentTypes/PaypalTest.php b/test/integration/PaymentTypes/PaypalTest.php
index bd2bd02d..89509da7 100755
--- a/test/integration/PaymentTypes/PaypalTest.php
+++ b/test/integration/PaymentTypes/PaypalTest.php
@@ -81,7 +81,6 @@ public function paypalShouldBeAuthorizable(Paypal $paypal): void
$this->assertNotEmpty($authorization->getRedirectUrl());
$payment = $authorization->getPayment();
- $this->getUnzerObject()->performChargeOnPayment($payment, new Charge(100.0, 'EUR', self::RETURN_URL));
$this->assertNotNull($payment);
$this->assertTrue($payment->isPending());
}
diff --git a/test/integration/Resources/BasketV2Test.php b/test/integration/Resources/BasketV2Test.php
index 677f691a..ec9a666d 100644
--- a/test/integration/Resources/BasketV2Test.php
+++ b/test/integration/Resources/BasketV2Test.php
@@ -21,8 +21,6 @@
class BasketV2Test extends BaseIntegrationTest
{
- //
-
/**
* Verify basket can be created and fetched.
*
@@ -299,10 +297,6 @@ public function chargeTransactionsShouldCreateBasketIfItDoesNotExistYet(): void
$this->assertEquals($basket->expose(), $fetchedPayment->getBasket()->expose());
}
- //
-
- //
-
/**
* @return array
*/
@@ -315,6 +309,4 @@ public function basketItemWithInvalidUrlWillThrowAnErrorDP(): array
'invalid not available' => [true, 'https://files.readme.io/does-not-exist.jpg', ApiResponseCodes::API_ERROR_BASKET_ITEM_IMAGE_INVALID_URL]
];
}
-
- //
}
diff --git a/test/integration/Resources/BasketV3Test.php b/test/integration/Resources/BasketV3Test.php
index 514bde63..55f60d99 100644
--- a/test/integration/Resources/BasketV3Test.php
+++ b/test/integration/Resources/BasketV3Test.php
@@ -19,7 +19,6 @@
use UnzerSDK\test\BaseIntegrationTest;
/**
- * @group skip
*/
class BasketV3Test extends BaseIntegrationTest
{
@@ -44,7 +43,7 @@ public function minV3BasketShouldBeCreatableAndFetchable(): void
$basketItem = new BasketItem();
$basketItem->setBasketItemReferenceId('item1')
->setQuantity(1)
- ->setAmountPerUnitGross(100)
+ ->setAmountPerUnitGross(99.99)
->setTitle('title');
$basket->addBasketItem($basketItem);
$this->assertEmpty($basket->getId());
@@ -53,7 +52,7 @@ public function minV3BasketShouldBeCreatableAndFetchable(): void
$this->assertNotEmpty($basket->getId());
$this->unzer->prepareJwtToken();
- $fetchedBasket = $this->unzer->fetchBasket($basket->getId())->setOrderId('');
+ $fetchedBasket = $this->unzer->fetchBasket($basket->getId())->setOrderId($orderId);
$this->assertEquals($basket->expose(), $fetchedBasket->expose());
}
diff --git a/test/integration/Resources/CustomerV2Test.php b/test/integration/Resources/CustomerV2Test.php
index d76bac94..f49d74b8 100755
--- a/test/integration/Resources/CustomerV2Test.php
+++ b/test/integration/Resources/CustomerV2Test.php
@@ -15,7 +15,6 @@
/**
* @backupStaticAttributes enabled
* @group CC-2016
- * @group skip
*/
class CustomerV2Test extends BaseIntegrationTest
{
diff --git a/test/integration/Resources/LinkpayV2Test.php b/test/integration/Resources/LinkpayV2Test.php
index 38486b1c..949c35aa 100644
--- a/test/integration/Resources/LinkpayV2Test.php
+++ b/test/integration/Resources/LinkpayV2Test.php
@@ -12,6 +12,14 @@
*/
class LinkpayV2Test extends BaseIntegrationTest
{
+ private static ?string $token = null;
+
+ protected function setUp(): void
+ {
+ parent::setUp();
+ self::$token = $this->unzer->prepareJwtToken(self::$token);
+ }
+
/**
* @test
*/
@@ -128,7 +136,8 @@ public function updateLinkpayExpiryDate()
$this->assertEquals($paypage->getCurrency(), $updatePaypage->getCurrency());
$this->assertEquals($paypage->getAlias(), $updatePaypage->getAlias());
$this->assertEquals($paypage->getAmountSettings(), $updatePaypage->getAmountSettings());
- $this->assertEquals($paypage->getResources(), $updatePaypage->getResources());
+
+ $this->assertNotEmpty($updatePaypage->getResources()->getMetadataId());
}
/**
@@ -167,8 +176,11 @@ public function updateLinkpayAmount()
$this->assertEquals($paypage->getCurrency(), $updatePaypage->getCurrency());
$this->assertEquals($paypage->getAlias(), $updatePaypage->getAlias());
$this->assertEquals($paypage->getAmountSettings(), $updatePaypage->getAmountSettings());
- $this->assertEquals($paypage->getResources(), $updatePaypage->getResources());
$this->assertEquals($paypage->getExpiresAt(), $updatePaypage->getExpiresAt());
+
+ $this->assertNotEmpty($updatePaypage->getResources()->getMetadataId());
+ $this->assertEmpty($updatePaypage->getResources()->getCustomerId());
+ $this->assertEmpty($updatePaypage->getResources()->getBasketId());
}
/**
@@ -208,8 +220,11 @@ public function updateLinkpayAmountSettings()
$this->assertEquals($paypage->getAmount(), $updatePaypage->getAmount());
$this->assertEquals($paypage->getCurrency(), $updatePaypage->getCurrency());
$this->assertEquals($paypage->getExpiresAt(), $updatePaypage->getExpiresAt());
- $this->assertEquals($paypage->getResources(), $updatePaypage->getResources());
$this->assertEquals('linkpay', $paypage->getType());
+
+ $this->assertNotEmpty($updatePaypage->getResources()->getMetadataId());
+ $this->assertEmpty($updatePaypage->getResources()->getCustomerId());
+ $this->assertEmpty($updatePaypage->getResources()->getBasketId());
}
/**
diff --git a/test/integration/Resources/PaypageV2Test.php b/test/integration/Resources/PaypageV2Test.php
index 35ba02e6..c583bcb7 100644
--- a/test/integration/Resources/PaypageV2Test.php
+++ b/test/integration/Resources/PaypageV2Test.php
@@ -2,6 +2,7 @@
namespace UnzerSDK\test\integration\Resources;
+use UnzerSDK\Constants\CustomerGroups;
use UnzerSDK\Constants\ExemptionType;
use UnzerSDK\Constants\PaypageCheckoutTypes;
use UnzerSDK\Resources\EmbeddedResources\Paypage\PaymentMethodConfig;
@@ -41,6 +42,14 @@
*/
class PaypageV2Test extends BaseIntegrationTest
{
+ private static ?string $token = null;
+
+ protected function setUp(): void
+ {
+ parent::setUp();
+ self::$token = $this->unzer->prepareJwtToken(self::$token);
+ }
+
/**
* @test
*/
@@ -99,7 +108,6 @@ public function JwtTokenShouldBeReusedForMultipleRequests()
$this->assertNull($paypageSecond->getRedirectUrl());
// Create Firt paypage
- $this->assertNull($unzer->getJwtToken());
$unzer->createPaypage($paypageFirst);
$InitialJwtToken = $unzer->getJwtToken();
$this->assertNotNull($InitialJwtToken);
@@ -228,7 +236,7 @@ public function createPaypageWithRiskData()
$unzer = $this->getUnzerObject();
$risk = new Risk();
- $risk->setCustomerGroup('neutral')
+ $risk->setCustomerGroup(CustomerGroups::NEUTRAL)
->setConfirmedAmount('1234')
->setConfirmedOrders('42')
->setRegistrationLevel('1')
@@ -299,8 +307,7 @@ public function paymentMethodsConfigsDataProvider()
->addMethodConfig(PostFinanceEfinance::class, $enabledConfig)
->addMethodConfig(PostFinanceCard::class, $enabledConfig)
->addMethodConfig(Twint::class, $enabledConfig)
- ->addMethodConfig(OpenbankingPis::class, $enabledConfig)
- ;
+ ->addMethodConfig(OpenbankingPis::class, $enabledConfig);
$withPaylaterConfig = (new PaymentMethodsConfigs())
->addMethodConfig(PaylaterInvoice::class, $paylaterConfig);
diff --git a/test/unit/Services/IdServiceTest.php b/test/unit/Services/IdServiceTest.php
index c3b1d114..cd3c0239 100644
--- a/test/unit/Services/IdServiceTest.php
+++ b/test/unit/Services/IdServiceTest.php
@@ -16,7 +16,7 @@ class IdServiceTest extends BasePaymentTest
*/
public function idWithUniqueIdReturnsTrue(string $id)
{
- $isUUID = IdService::isUUDIResource($id);
+ $isUUID = IdService::isUUIDResource($id);
$this->assertTrue($isUUID);
}
@@ -29,7 +29,7 @@ public function idWithUniqueIdReturnsTrue(string $id)
*/
public function shortIdShouldReturnFalse(string $id)
{
- $isUUID = IdService::isUUDIResource($id);
+ $isUUID = IdService::isUUIDResource($id);
$this->assertFalse($isUUID);
}
diff --git a/test/unit/Services/ResourceServiceTest.php b/test/unit/Services/ResourceServiceTest.php
index d28680e6..8ba3c4c7 100755
--- a/test/unit/Services/ResourceServiceTest.php
+++ b/test/unit/Services/ResourceServiceTest.php
@@ -1063,7 +1063,7 @@ public function fetchBasketShouldCallV1EnpointIfBasketWasNotFound(): void
$resourceServiceMock->expects(self::exactly(2))
->method('fetchResource')
- ->withConsecutive([$basket, BasePaymentTest::API_VERSION_2], [$basket, Unzer::API_VERSION])
+ ->withConsecutive([$basket, BasePaymentTest::API_VERSION_2], [$basket])
->will($this->returnCallback(function ($basket, $version) {
if ($version === BasePaymentTest::API_VERSION_2) {
throw new UnzerApiException(null, null, ApiResponseCodes::API_ERROR_BASKET_NOT_FOUND);
@@ -1092,7 +1092,7 @@ public function fetchBasketShouldCallFetchResourceMaxTwoTimes(): void
$resourceServiceMock->expects(self::exactly(2))
->method('fetchResource')
- ->withConsecutive([$basket, BasePaymentTest::API_VERSION_2], [$basket, Unzer::API_VERSION])
+ ->withConsecutive([$basket, BasePaymentTest::API_VERSION_2], [$basket])
->willThrowException(new UnzerApiException(null, null, ApiResponseCodes::API_ERROR_BASKET_NOT_FOUND));
$this->expectException(UnzerApiException::class);