-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
209 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace UnzerSDK\Resources\PaymentTypes; | ||
|
||
use UnzerSDK\Traits\CanAuthorize; | ||
use UnzerSDK\Traits\CanDirectCharge; | ||
|
||
class OpenBanking extends BasePaymentType | ||
{ | ||
use CanAuthorize; | ||
use CanDirectCharge; | ||
|
||
/** @var string|null $ibanCountry */ | ||
protected $ibanCountry; | ||
|
||
public function __construct(string $ibanCountry = null) | ||
{ | ||
$this->ibanCountry = $ibanCountry; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getIbanCountry(): ?string | ||
{ | ||
return $this->ibanCountry; | ||
} | ||
|
||
/** | ||
* @param string|null $ibanCountry | ||
* | ||
* @return OpenBanking | ||
*/ | ||
public function setIbanCountry(string $ibanCountry): OpenBanking | ||
{ | ||
$this->ibanCountry = $ibanCountry; | ||
return $this; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"ibanCountry": "DE" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"id": "s-obp-q0nucec6itwe", | ||
"method": "openbanking-pis", | ||
"recurring": false, | ||
"geoLocation": { | ||
"clientIp": "0:0:0:0:0:0:0:1", | ||
"countryIsoA2": "" | ||
}, | ||
"processing": { | ||
"uniqueId": "31HA07BC8127DC45EE6946C3B070FF71", | ||
"shortId": "5550.0369.6888", | ||
"traceId": "24c0a2ecbe3d54a838c76444d4bdcd1f" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
|
||
/** @noinspection PhpUnhandledExceptionInspection */ | ||
/** @noinspection PhpDocMissingThrowsInspection */ | ||
/** | ||
* This class defines integration tests to verify interface and functionality of the payment method paypal. | ||
* | ||
* @link https://docs.unzer.com/ | ||
* | ||
*/ | ||
|
||
namespace UnzerSDK\test\integration\PaymentTypes; | ||
|
||
use UnzerSDK\Resources\PaymentTypes\BasePaymentType; | ||
use UnzerSDK\Resources\PaymentTypes\OpenBanking; | ||
use UnzerSDK\test\BaseIntegrationTest; | ||
|
||
class OpenBankingTest extends BaseIntegrationTest | ||
{ | ||
/** | ||
* Verify OpenBanking payment type can be created and fetched. | ||
* | ||
* @test | ||
* | ||
* @return BasePaymentType | ||
*/ | ||
public function openBankingShouldBeCreatableAndFetchable(): BasePaymentType | ||
{ | ||
$openBanking = $this->unzer->createPaymentType(new OpenBanking('DE')); | ||
$this->assertInstanceOf(OpenBanking::class, $openBanking); | ||
$this->assertNotEmpty($openBanking->getId()); | ||
|
||
$fetchedOpenBanking = $this->unzer->fetchPaymentType($openBanking->getId()); | ||
$this->assertInstanceOf(OpenBanking::class, $fetchedOpenBanking); | ||
$this->assertNotSame($openBanking, $fetchedOpenBanking); | ||
$this->assertEquals($openBanking->expose(), $fetchedOpenBanking->expose()); | ||
|
||
return $fetchedOpenBanking; | ||
} | ||
|
||
|
||
|
||
/** | ||
* Verify OpenBanking can authorize. | ||
* | ||
* @test | ||
* | ||
* @depends openBankingShouldBeCreatableAndFetchable | ||
* | ||
* @param OpenBanking $openBanking | ||
*/ | ||
public function openBankingShouldBeAuthorizable(OpenBanking $openBanking): void | ||
{ | ||
$authorization = $openBanking->authorize(100.0, 'EUR', self::RETURN_URL); | ||
$this->assertNotNull($authorization); | ||
$this->assertNotEmpty($authorization->getId()); | ||
$this->assertNotEmpty($authorization->getRedirectUrl()); | ||
|
||
$payment = $authorization->getPayment(); | ||
$this->assertNotNull($payment); | ||
$this->assertTrue($payment->isPending()); | ||
} | ||
|
||
/** | ||
* Verify OpenBanking can charge. | ||
* | ||
* @test | ||
* | ||
* @depends openBankingShouldBeCreatableAndFetchable | ||
* | ||
* @param OpenBanking $openBanking | ||
*/ | ||
public function openBankingShouldBeChargeable(OpenBanking $openBanking): void | ||
{ | ||
$charge = $openBanking->charge(100.0, 'EUR', self::RETURN_URL); | ||
$this->assertNotNull($charge); | ||
$this->assertNotEmpty($charge->getId()); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace UnzerSDK\test\unit\Resources\PaymentTypes; | ||
|
||
use UnzerSDK\Resources\PaymentTypes\Clicktopay; | ||
use UnzerSDK\Resources\PaymentTypes\OpenBanking; | ||
use UnzerSDK\test\BasePaymentTest; | ||
use UnzerSDK\test\Fixtures\JsonProvider; | ||
|
||
class OpenBankingTest extends BasePaymentTest | ||
{ | ||
/** | ||
* Verify the resource data is set properly. | ||
* | ||
* @test | ||
*/ | ||
public function constructorShouldSetParameters(): void | ||
{ | ||
$countryCode = 'DE'; | ||
|
||
$openBanking = new OpenBanking($countryCode); | ||
|
||
|
||
$this->assertEquals($countryCode, $openBanking->getIbanCountry()); | ||
} | ||
|
||
/** | ||
* Test OpenBanking json serialization. | ||
* | ||
* @test | ||
*/ | ||
public function jsonSerialization(): void | ||
{ | ||
$openBankingObject = new OpenBanking("DE",); | ||
|
||
$expectedJson = JsonProvider::getJsonFromFile('openBanking/createRequest.json'); | ||
$this->assertJsonStringEqualsJsonString($expectedJson, $openBankingObject->jsonSerialize()); | ||
} | ||
|
||
/** | ||
* Test OpenBanking json response handling. | ||
* | ||
* @test | ||
*/ | ||
public function openBankingAuthorizationShouldBeMappedCorrectly(): void | ||
{ | ||
$openBanking = new OpenBanking('DE'); | ||
|
||
$jsonResponse = JsonProvider::getJsonFromFile('openBanking/fetchResponse.json'); | ||
|
||
$jsonObject = json_decode($jsonResponse, false, 512, JSON_THROW_ON_ERROR); | ||
$openBanking->handleResponse($jsonObject); | ||
|
||
$this->assertEquals('s-obp-q0nucec6itwe', $openBanking->getId()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters