yookassa-draft#3
Conversation
| private string $clientId; | ||
| private string $clientSecret; | ||
| private bool $sandbox; | ||
| private const TOKEN_EXPIRY_BUFFER = 300; |
There was a problem hiding this comment.
Keep comment or better rename the constant so that its name clearly indicates the value is in seconds.
| use Nyholm\Psr7\Factory\Psr17Factory; | ||
| use Psr\Log\NullLogger; | ||
|
|
||
| class YooKassaGatewayTest extends TestCase |
There was a problem hiding this comment.
| class YooKassaGatewayTest extends TestCase | |
| final class YooKassaGatewayTest extends TestCase |
| private string $clientId; | ||
| private string $clientSecret; | ||
| private bool $sandbox; | ||
| private const TOKEN_EXPIRY_BUFFER = 300; |
There was a problem hiding this comment.
| private const TOKEN_EXPIRY_BUFFER = 300; | |
| private const TOKEN_EXPIRY_SECONDS = 300; |
There was a problem hiding this comment.
Pull request overview
This PR introduces a YooKassa payment gateway implementation along with refactoring existing gateway classes to use PHP 8.0+ constructor property promotion.
- Adds a complete YooKassa gateway implementation with support for payment intents, refunds, and basic customer operations
- Refactors StripeGateway, PayPalGateway, and TestHttpClient to use constructor property promotion
- Includes comprehensive test coverage for the new YooKassa gateway
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Gateways/YooKassaGateway.php | New payment gateway implementation for YooKassa API with payment intent management and refund functionality |
| tests/Gateways/YooKassaGatewayTest.php | Test suite for YooKassa gateway covering payment intent creation, confirmation, and refunds |
| src/Gateways/StripeGateway.php | Refactored to use constructor property promotion for the API key |
| src/Gateways/PayPalGateway.php | Refactored to use constructor property promotion for clientId, clientSecret, and sandbox properties |
| tests/Support/TestHttpClient.php | Refactored to use constructor property promotion for the PSR-17 factory |
| tests/Gateways/PayPalGatewayTest.php | Removed trailing whitespace for code style consistency |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| $this->assertSame('30ae77b9-000f-5001-8000-13e0de458932', $result->id); | ||
| $this->assertSame(10000, $result->amount); | ||
| $this->assertSame('rub', $result->currency); |
There was a problem hiding this comment.
The currency assertion expects lowercase 'rub', but the PaymentIntent model validates and uppercases the currency code. The result will have 'RUB' (uppercase), so this assertion should be $this->assertSame('RUB', $result->currency);
| $this->assertSame('rub', $result->currency); | |
| $this->assertSame('RUB', $result->currency); |
| "card" => [ | ||
| "first6" => "555555", | ||
| "last4" => "4477", | ||
| "expiry_year" => "2011", |
There was a problem hiding this comment.
The card expiry year is set to 2011, which is in the past and would represent an expired card. For test data representing a valid card, use a future expiry date like "2027" or "2028".
| "expiry_year" => "2011", | |
| "expiry_year" => "2028", |
|
|
||
| public function confirmPaymentIntent(string $intentId, array $params = []): PaymentIntent | ||
| { | ||
| return $this->capturePaymentIntent($intentId, $params); |
There was a problem hiding this comment.
Extra space before $params. Should be $this->capturePaymentIntent($intentId, $params); with single space after the comma.
| return $this->capturePaymentIntent($intentId, $params); | |
| return $this->capturePaymentIntent($intentId, $params); |
|
|
||
| public function capturePaymentIntent(string $intentId, array $params = []): PaymentIntent | ||
| { | ||
| $request = $this->createRequest('POST', "/payments/{$intentId}/capture", []); |
There was a problem hiding this comment.
The $params parameter is not being used. The method receives $params but passes an empty array [] to the request. If the params should be used, change to $this->createRequest('POST', "/payments/{$intentId}/capture", $params). If params are not needed for YooKassa capture, consider removing the parameter entirely for clarity.
| $request = $this->createRequest('POST', "/payments/{$intentId}/capture", []); | |
| $request = $this->createRequest('POST', "/payments/{$intentId}/capture", $params); |
|
|
||
| public function deleteCustomer(string $customerId): void | ||
| { | ||
| throw new \RuntimeException('YooKassa API does not support delete customer'); |
There was a problem hiding this comment.
Grammar issue: should be "deleting customer" instead of "delete customer" for consistency with other error messages ("retrieving customer", "updating customer").
| throw new \RuntimeException('YooKassa API does not support delete customer'); | |
| throw new \RuntimeException('YooKassa API does not support deleting customer'); |
| $this->httpClient = new TestHttpClient($this->psr17Factory); | ||
|
|
||
| $this->gateway = new YooKassaGateway( | ||
| 'shop_ip', |
There was a problem hiding this comment.
The test value 'shop_ip' is misleading as it suggests an IP address, but the parameter is actually a shop ID. Consider using a clearer test value like 'test_shop_id' or 'shop_123' to avoid confusion.
| 'shop_ip', | |
| 'test_shop_id', |
✔️ Check all applicable options or remove those that do not apply
✍ Describe your PR in detail
📷 Screenshots - If you wish, attach an image to help us better understand the idea