-
-
Notifications
You must be signed in to change notification settings - Fork 19
New payment parameters: #48
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,5 +14,6 @@ parameters: | |
| paths: | ||
| - src | ||
| - .docs | ||
| - tests/Cases | ||
|
|
||
| ignoreErrors: | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ class Payment extends AbstractPayment | |
|
|
||
| private string $method = PaymentMethodCode::ALL; | ||
|
|
||
| /** @var string ISO 639-1 */ | ||
| /** @see https://cs.wikipedia.org/wiki/ISO_639-1 */ | ||
| private string $lang = LangCode::CS; | ||
|
|
||
| private bool $prepareOnly = true; | ||
|
|
@@ -26,6 +26,14 @@ class Payment extends AbstractPayment | |
|
|
||
| private bool $embedded = false; | ||
|
|
||
| private bool $chargeUnregulatedCardFees; | ||
|
|
||
| private string $urlPaid; | ||
|
|
||
| private string $urlCancelled; | ||
|
|
||
| private string $urlPending; | ||
|
|
||
|
Comment on lines
+29
to
+36
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. Uninitialized typed properties will cause runtime errors. These properties lack default values and are not initialized in the constructor. Calling their getters (lines 132-170) before their setters will throw a Apply this diff to provide safe defaults: - private bool $chargeUnregulatedCardFees;
+ private ?bool $chargeUnregulatedCardFees = null;
- private string $urlPaid;
+ private ?string $urlPaid = null;
- private string $urlCancelled;
+ private ?string $urlCancelled = null;
- private string $urlPending;
+ private ?string $urlPending = null;Then update the getter return types accordingly: - public function isChargeUnregulatedCardFees(): bool
+ public function isChargeUnregulatedCardFees(): ?bool
- public function getUrlPaid(): string
+ public function getUrlPaid(): ?string
- public function getUrlCancelled(): string
+ public function getUrlCancelled(): ?string
- public function getUrlPending(): string
+ public function getUrlPending(): ?string
|
||
| final private function __construct() | ||
| { | ||
| // Noop | ||
|
|
@@ -39,7 +47,7 @@ public static function of( | |
| string $fullName, | ||
| string $method = PaymentMethodCode::ALL, | ||
| string $country = CountryCode::ALL, | ||
| string $lang = LangCode::CS | ||
| string $lang = LangCode::CS, | ||
| ): self | ||
| { | ||
| $p = new static(); | ||
|
|
@@ -121,20 +129,98 @@ public function setEmbedded(bool $embedded): void | |
| $this->embedded = $embedded; | ||
| } | ||
|
|
||
| public function isChargeUnregulatedCardFees(): bool | ||
| { | ||
| return $this->chargeUnregulatedCardFees; | ||
| } | ||
|
|
||
| public function setChargeUnregulatedCardFees(bool $chargeUnregulatedCardFees): void | ||
| { | ||
| $this->chargeUnregulatedCardFees = $chargeUnregulatedCardFees; | ||
| } | ||
|
|
||
| public function getUrlPaid(): string | ||
| { | ||
| return $this->urlPaid; | ||
| } | ||
|
|
||
| public function setUrlPaid(string $urlPaid): void | ||
| { | ||
| $this->urlPaid = $urlPaid; | ||
| } | ||
|
|
||
| public function getUrlCancelled(): string | ||
| { | ||
| return $this->urlCancelled; | ||
| } | ||
|
|
||
| public function setUrlCancelled(string $urlCancelled): void | ||
| { | ||
| $this->urlCancelled = $urlCancelled; | ||
| } | ||
|
|
||
| public function getUrlPending(): string | ||
| { | ||
| return $this->urlPending; | ||
| } | ||
|
|
||
| public function setUrlPending(string $urlPending): void | ||
| { | ||
| $this->urlPending = $urlPending; | ||
| } | ||
|
|
||
| /** | ||
| * @return mixed[] | ||
| * @return array{ | ||
| * price: ?int, | ||
| * curr: ?string, | ||
| * label: ?string, | ||
| * refId: ?string, | ||
| * email: ?string, | ||
| * fullName: ?string, | ||
| * country: ?string, | ||
| * account: ?string, | ||
| * name: ?string, | ||
| * method: string, | ||
| * lang: string, | ||
| * prepareOnly: string, | ||
| * preauth: string, | ||
| * initRecurring: string, | ||
| * verification: string, | ||
| * embedded: string, | ||
| * chargeUnregulatedCardFees?: string, | ||
| * url_paid?: string, | ||
| * url_cancelled?: string, | ||
| * url_pending?: string, | ||
| * } | ||
| */ | ||
| public function toArray(): array | ||
| { | ||
| return array_merge(parent::toArray(), [ | ||
| $data = [ | ||
| 'method' => $this->method, | ||
| 'lang' => $this->lang, | ||
| 'prepareOnly' => $this->prepareOnly ? 'true' : 'false', | ||
| 'preauth' => $this->preauth ? 'true' : 'false', | ||
| 'initRecurring' => $this->initRecurring ? 'true' : 'false', | ||
| 'verification' => $this->verification ? 'true' : 'false', | ||
| 'embedded' => $this->embedded ? 'true' : 'false', | ||
| ]); | ||
| ]; | ||
| if (isset($this->chargeUnregulatedCardFees)) { | ||
| $data['chargeUnregulatedCardFees'] = $this->chargeUnregulatedCardFees ? 'true' : 'false'; | ||
| } | ||
|
|
||
| if (isset($this->urlPaid)) { | ||
| $data['url_paid'] = $this->urlPaid; | ||
| } | ||
|
|
||
| if (isset($this->urlCancelled)) { | ||
| $data['url_cancelled'] = $this->urlCancelled; | ||
| } | ||
|
|
||
| if (isset($this->urlPending)) { | ||
| $data['url_pending'] = $this->urlPending; | ||
| } | ||
|
|
||
| return array_merge(parent::toArray(), $data); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -26,8 +26,10 @@ public function getTransId(): string | |||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * @return mixed[] | ||||||
| */ | ||||||
| * @return array{ | ||||||
| * transId: string, | ||||||
| * } | ||||||
| **/ | ||||||
|
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. Fix non-standard docblock closing syntax. The docblock closing uses Apply this diff: - **/
+ */📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| public function toArray(): array | ||||||
| { | ||||||
| return [ | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,7 +10,7 @@ class Refund extends AbstractEntity | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private int $amount; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** @var string ISO 4217 */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** @see https://cs.wikipedia.org/wiki/ISO_4217 */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private string $curr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private string $transId; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -58,7 +58,12 @@ public function getRefId(): ?string | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @return mixed[] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @return array{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * amount: float, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * curr: string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * transId: string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * refId: ?string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
60
to
+66
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. Type mismatch in PHPDoc for The docblock declares Apply this diff to correct the documentation: /**
* @return array{
- * amount: float,
+ * amount: int,
* curr: string,
* transId: string,
* refId: ?string
* }
*/📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Comment on lines
+61
to
+66
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. Fix type mismatch in PHPDoc. The PHPDoc specifies Apply this diff to fix the type mismatch: /**
* @return array{
- * amount: float,
+ * amount: int,
* curr: string,
* transId: string,
* refId: ?string
* }
*/📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public function toArray(): array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
Uninitialized typed properties will cause fatal errors.
The new properties are declared as non-nullable types without default values, creating uninitialized typed properties. Calling the getter methods (lines 132-170) before the setters will trigger:
Error: Typed property must not be accessed before initialization.This breaks the pattern established by existing properties like
prepareOnly,preauth, etc., which all have default values.Apply this diff to make properties nullable with safe defaults:
Then update getter return types to match:
🤖 Prompt for AI Agents