-
Notifications
You must be signed in to change notification settings - Fork 0
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
4 changed files
with
101 additions
and
1 deletion.
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,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Answear\PayPo\Request\Transaction; | ||
|
||
use Answear\PayPo\Enum\OrderStatusEnum; | ||
|
||
class CancelRequest implements RequestInterface | ||
{ | ||
private const HTTP_METHOD = 'PATCH'; | ||
private const ENDPOINT = '/transactions'; | ||
|
||
public string $status; | ||
private string $transactionUuid; | ||
|
||
public function __construct(string $transactionUuid) | ||
{ | ||
$this->status = OrderStatusEnum::CANCELED; | ||
$this->transactionUuid = $transactionUuid; | ||
} | ||
|
||
public function getHttpMethod(): string | ||
{ | ||
return self::HTTP_METHOD; | ||
} | ||
|
||
public function getUrl(): string | ||
{ | ||
return self::ENDPOINT . '/' . $this->transactionUuid; | ||
} | ||
} |
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,54 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Answear\PayPo\Tests\Integration\Request\Transaction; | ||
|
||
use Answear\PayPo\Configuration\PayPoConfiguration; | ||
use Answear\PayPo\Exception\ConfigurationException; | ||
use Answear\PayPo\Service\PayPoClient; | ||
use GuzzleHttp\Client; | ||
|
||
class CancelTest extends AbstractOrderTest | ||
{ | ||
private const TRANSACTION_UUID = 'transaction-uuid'; | ||
|
||
/** | ||
* @test | ||
* | ||
* @dataProvider provideDataForRequest | ||
*/ | ||
public function configurationNotSetException(string $transactionUuid): void | ||
{ | ||
PayPoConfiguration::reset(); | ||
|
||
$this->expectException(ConfigurationException::class); | ||
|
||
$client = $this->createMock(Client::class); | ||
$this->getOrderService(new PayPoClient($client))->cancel($transactionUuid); | ||
} | ||
|
||
public function provideDataForRequest(): iterable | ||
{ | ||
$this->setUpConfiguration(); | ||
|
||
yield [ | ||
self::TRANSACTION_UUID, | ||
'{"status":"CANCELED"}', | ||
[ | ||
'code' => '200', | ||
'statusDescription' => 'Transaction updated successfully', | ||
], | ||
]; | ||
} | ||
|
||
protected function sendAndAssert(PayPoClient $client, $request, array $apiResponse): void | ||
{ | ||
self::assertSame(self::TRANSACTION_UUID, $request); | ||
|
||
$response = $this->getOrderService($client)->cancel($request); | ||
|
||
self::assertSame($apiResponse['code'], $response->code); | ||
self::assertSame($apiResponse['statusDescription'], $response->statusDescription); | ||
} | ||
} |