Skip to content

Commit

Permalink
PHP-79: Add additional countries to constants and fix empty excluded …
Browse files Browse the repository at this point in the history
…provider ids being rejected by the api (#53)
  • Loading branch information
lighe authored Apr 24, 2024
1 parent 09e02f4 commit 4f2fb66
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 4 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0.1] - 2024-04-24

### Added

- Additional supported countries in TrueLayer\Constants\Countries

### Fixed

- Using provider filters without specifying an excluded provider id would return an error

## [2.0.0] - 2024-03-26

### Changed
Expand Down
15 changes: 14 additions & 1 deletion src/Constants/Countries.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,20 @@

class Countries
{
public const GB = 'GB';
public const AT = 'AT';
public const BE = 'BE';
public const DE = 'DE';
public const DK = 'DK';
public const ES = 'ES';
public const FI = 'FI';
public const FR = 'FR';
public const GB = 'GB';
public const IE = 'IE';
public const IT = 'IT';
public const LT = 'LT';
public const NL = 'NL';
public const NO = 'NO';
public const PL = 'PL';
public const PT = 'PT';
public const RO = 'RO';
}
4 changes: 2 additions & 2 deletions src/Entities/Provider/ProviderSelection/ProviderFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ public function providerIds(array $providerIds): ProviderFilterInterface
/**
* @return array|string[]
*/
public function getExcludesProviderIds(): array
public function getExcludesProviderIds(): ?array
{
return $this->excludesProviderIds ?? [];
return $this->excludesProviderIds ?? null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,39 @@
\expect($payment1)->not->toBe($payment3);
\expect($payment2)->not->toBe($payment3);
});

\it('creates payment without excluded provider ids', function () {
$helper = \paymentHelper();

$account = Arr::first(
$helper->client()->getMerchantAccounts(),
fn(MerchantAccountInterface $account) => $account->getCurrency() === 'GBP'
);

$filter = $helper->client()->providerFilter()
->countries([\TrueLayer\Constants\Countries::ES])
->releaseChannel(\TrueLayer\Constants\ReleaseChannels::GENERAL_AVAILABILITY);

$providerSelection = $helper->client()->providerSelection()
->userSelected()
->filter($filter);

$paymentMethod = $helper->client()->paymentMethod()->bankTransfer()
->beneficiary($helper->merchantBeneficiary($account))
->providerSelection($providerSelection);

$created = $helper->create(
$paymentMethod, $helper->user(), $account->getCurrency()
);

\expect($created)->toBeInstanceOf(PaymentCreatedInterface::class);
\expect($created->getId())->toBeString();
\expect($created->getResourceToken())->toBeString();
\expect($created->getUserId())->toBeString();

$paymentMethod = $created->getDetails()->getPaymentMethod();
\expect($paymentMethod)->toBeInstanceOf(BankTransferPaymentMethodInterface::class);
\expect($paymentMethod->getBeneficiary()->getReference())->toBe('TEST');

return $created;
})->only();
2 changes: 1 addition & 1 deletion tests/integration/PaymentCreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
'mock-payments-gb-redirect',
],
'excludes' => [
'provider_ids' => [],
'provider_ids' => null,
],
],
],
Expand Down

0 comments on commit 4f2fb66

Please sign in to comment.