-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Method\Payment; | ||
|
||
use Vjik\TelegramBot\Api\ParseResult\ValueHelper; | ||
use Vjik\TelegramBot\Api\Request\HttpMethod; | ||
use Vjik\TelegramBot\Api\Request\TelegramRequestWithResultPreparingInterface; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#refundstarpayment | ||
*/ | ||
final readonly class RefundStarPayment implements TelegramRequestWithResultPreparingInterface | ||
{ | ||
public function __construct( | ||
private int $userId, | ||
private string $telegramPaymentChargeId, | ||
) { | ||
} | ||
|
||
public function getHttpMethod(): HttpMethod | ||
{ | ||
return HttpMethod::POST; | ||
} | ||
|
||
public function getApiMethod(): string | ||
{ | ||
return 'refundStarPayment'; | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
return [ | ||
'user_id' => $this->userId, | ||
'telegram_payment_charge_id' => $this->telegramPaymentChargeId, | ||
]; | ||
} | ||
|
||
public function prepareResult(mixed $result): true | ||
{ | ||
ValueHelper::assertTrueResult($result); | ||
return $result; | ||
} | ||
} |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Tests\Method\Payment; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Vjik\TelegramBot\Api\Method\Payment\RefundStarPayment; | ||
use Vjik\TelegramBot\Api\Request\HttpMethod; | ||
|
||
final class RefundStarPaymentTest extends TestCase | ||
{ | ||
public function testBase(): void | ||
{ | ||
$method = new RefundStarPayment(1, 'test'); | ||
|
||
$this->assertSame(HttpMethod::POST, $method->getHttpMethod()); | ||
$this->assertSame('refundStarPayment', $method->getApiMethod()); | ||
$this->assertSame( | ||
[ | ||
'user_id' => 1, | ||
'telegram_payment_charge_id' => 'test', | ||
], | ||
$method->getData() | ||
); | ||
} | ||
|
||
public function testPrepareResult(): void | ||
{ | ||
$method = new RefundStarPayment(1, 'test'); | ||
|
||
$preparedResult = $method->prepareResult(true); | ||
|
||
$this->assertTrue($preparedResult); | ||
} | ||
} |
This file contains 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