-
Notifications
You must be signed in to change notification settings - Fork 3
refactor: enhance type safety and improve request flexibility #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
fordimalanda
wants to merge
13
commits into
devscast:master
Choose a base branch
from
fordimalanda:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a82ea2b
code(types): enforce strict types in Data\Type enum
fordimalanda a6743f2
refactor(request): loosen CardRequest constructor restrictions with o…
fordimalanda 77d607d
feat(payout/env): adopt PHP 8.3 #[Override] in PayoutRequest and refa…
fordimalanda b7faafb
refactor(response): align snake_case API data with camelCase properti…
fordimalanda 178d416
feat(request): finalize CardRequest with optional parameters and PHP …
fordimalanda 5c3ffe5
refactor(request): isolate abstract Request class and remove duplicat…
fordimalanda bf53a3e
fix(request): finalize MobileRequest constructor with null-coalescing…
fordimalanda cc8f2ad
fix(request): align PayoutRequest with MobileRequest architecture and…
fordimalanda d93151b
feat(response): add Symfony Serializer annotations to PayoutResponse
fordimalanda 98df9ba
feat(env): finalize Environment enum with validated Payout endpoint
fordimalanda 806ec90
refactor(response): remove redundant Serializer attributes for native…
fordimalanda 47f6a47
style: final code style and named arguments optimization
fordimalanda 634efef
chore(tests): remove accidental tests.zip archive
fordimalanda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Devscast\Flexpay\Data; | ||
|
|
||
| enum Type: int | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -9,44 +9,62 @@ | |
| use Webmozart\Assert\Assert; | ||
|
|
||
| /** | ||
| * Class Request. | ||
| * | ||
| * @author bernard-ng <bernard@devscast.tech> | ||
| * Class Request | ||
| * * Classe de base abstraite pour toutes les requêtes de l'API Flexpay. | ||
| * Elle centralise les informations communes à chaque transaction. | ||
| * * @author bernard-ng <bernard@devscast.tech> | ||
| */ | ||
| abstract class Request | ||
| { | ||
| /** | ||
| * ID du marchand fourni par Flexpay | ||
| */ | ||
| public ?string $merchant = null; | ||
|
|
||
| /** | ||
| * Jeton d'autorisation (Token) | ||
| */ | ||
| public ?string $authorization = null; | ||
|
|
||
| /** | ||
| * Constructeur de base. | ||
| * * @param float $amount Montant de la transaction (doit être > 0) | ||
| * @param string $reference Référence unique de la transaction | ||
| * @param Currency $currency Devise (CDF ou USD) | ||
| * @param string $callbackUrl URL de notification (Webhook) | ||
| * @param string $description Description optionnelle | ||
| * @param string $approveUrl URL de retour après succès | ||
| * @param string $cancelUrl URL de retour après annulation | ||
| * @param string $declineUrl URL de retour après échec | ||
| */ | ||
| public function __construct( | ||
| public readonly float $amount, | ||
| public readonly string $reference, | ||
| public readonly Currency $currency, | ||
| public readonly string $callbackUrl, | ||
| public readonly ?string $approveUrl = null, | ||
| public readonly ?string $description = null, | ||
| public readonly ?string $cancelUrl = null, | ||
| public readonly ?string $declineUrl = null, | ||
| public readonly string $description = '', | ||
| public readonly string $approveUrl = '', | ||
| public readonly string $cancelUrl = '', | ||
| public readonly string $declineUrl = '', | ||
|
Comment on lines
+45
to
+48
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be a breaking change. Why should we accept empty strings where |
||
| ) { | ||
| // Validations de base communes à tous les flux | ||
| Assert::greaterThan($this->amount, 0, 'The transaction amount should be greater than 0'); | ||
| Assert::notEmpty($this->reference, 'The transaction reference is mandatory'); | ||
| Assert::oneOf($this->currency, Currency::cases(), 'Unsupported currency'); | ||
| Assert::notEmpty($this->callbackUrl, 'The callback (webhook) url must be provided'); | ||
| } | ||
|
|
||
| /** | ||
| * @internal | ||
| * | ||
| * Cette méthode est utilisée pour définir les informations d'authentification. | ||
| * Elle est définie ici pour éviter de passer par le constructeur | ||
| * et rajouter de la complexité pour le développeur final | ||
| * Définit les informations d'authentification de manière centralisée. | ||
| * * @internal Cette méthode est utilisée par le Provider pour injecter les credentials. | ||
| */ | ||
| public function setCredential(Credential $credential): void | ||
| { | ||
| $this->merchant = $credential->merchant; | ||
| $this->authorization = $credential->token; | ||
| } | ||
|
|
||
| /** | ||
| * Chaque type de requête doit implémenter sa propre logique de génération de payload. | ||
| */ | ||
| abstract public function getPayload(): array; | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another breaking change here. Last time I checked the Flexpay API, those URLs were mandatory and they still are.
If the user does not have corresponding handlers in their app, they should provide the app’s default URL on the calling side.