Skip to content

yookassa-draft#3

Merged
mob-stuv merged 2 commits into
masterfrom
yookassa-draft
Mar 30, 2026
Merged

yookassa-draft#3
mob-stuv merged 2 commits into
masterfrom
yookassa-draft

Conversation

@atcq-me
Copy link
Copy Markdown
Collaborator

@atcq-me atcq-me commented Nov 19, 2025

✔️ Check all applicable options or remove those that do not apply

Q A
Is bugfix? ✔️/❌
New feature? ✔️/❌
Breaks BC? ✔️/❌
Fixed issues comma-separated list of tickets # fixed by the PR, if any

✍ Describe your PR in detail

📷 Screenshots - If you wish, attach an image to help us better understand the idea

private string $clientId;
private string $clientSecret;
private bool $sandbox;
private const TOKEN_EXPIRY_BUFFER = 300;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class YooKassaGatewayTest extends TestCase
final class YooKassaGatewayTest extends TestCase

private string $clientId;
private string $clientSecret;
private bool $sandbox;
private const TOKEN_EXPIRY_BUFFER = 300;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private const TOKEN_EXPIRY_BUFFER = 300;
private const TOKEN_EXPIRY_SECONDS = 300;

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Suggested change
$this->assertSame('rub', $result->currency);
$this->assertSame('RUB', $result->currency);

Copilot uses AI. Check for mistakes.
"card" => [
"first6" => "555555",
"last4" => "4477",
"expiry_year" => "2011",
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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".

Suggested change
"expiry_year" => "2011",
"expiry_year" => "2028",

Copilot uses AI. Check for mistakes.

public function confirmPaymentIntent(string $intentId, array $params = []): PaymentIntent
{
return $this->capturePaymentIntent($intentId, $params);
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space before $params. Should be $this->capturePaymentIntent($intentId, $params); with single space after the comma.

Suggested change
return $this->capturePaymentIntent($intentId, $params);
return $this->capturePaymentIntent($intentId, $params);

Copilot uses AI. Check for mistakes.

public function capturePaymentIntent(string $intentId, array $params = []): PaymentIntent
{
$request = $this->createRequest('POST', "/payments/{$intentId}/capture", []);
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
$request = $this->createRequest('POST', "/payments/{$intentId}/capture", []);
$request = $this->createRequest('POST', "/payments/{$intentId}/capture", $params);

Copilot uses AI. Check for mistakes.

public function deleteCustomer(string $customerId): void
{
throw new \RuntimeException('YooKassa API does not support delete customer');
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar issue: should be "deleting customer" instead of "delete customer" for consistency with other error messages ("retrieving customer", "updating customer").

Suggested change
throw new \RuntimeException('YooKassa API does not support delete customer');
throw new \RuntimeException('YooKassa API does not support deleting customer');

Copilot uses AI. Check for mistakes.
$this->httpClient = new TestHttpClient($this->psr17Factory);

$this->gateway = new YooKassaGateway(
'shop_ip',
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
'shop_ip',
'test_shop_id',

Copilot uses AI. Check for mistakes.
@mob-stuv mob-stuv merged commit 802509f into master Mar 30, 2026
6 checks passed
@mob-stuv mob-stuv deleted the yookassa-draft branch March 30, 2026 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants