diff --git a/src/Response/PaymentResponse.php b/src/Response/PaymentResponse.php index 3cad0d3..e230d03 100644 --- a/src/Response/PaymentResponse.php +++ b/src/Response/PaymentResponse.php @@ -9,6 +9,18 @@ class PaymentResponse { + public const ACTION_CANCEL = 'cancel'; + public const ACTION_FAIL = 'fail'; + public const ACTION_PAID = 'paid'; + public const ACTION_PAID_PARTIALLY = 'paid_partially'; + public const ACTION_PROCESS = 'process'; + public const ACTION_PROCESS_UNCONFIRMED = 'process_unconfirmed'; + public const ACTION_REFUND = 'refund'; + public const ACTION_REMIND = 'remind'; + public const ACTION_REOPEN = 'reopen'; + public const ACTION_AUTHORIZE = 'authorize'; + public const ACTION_CHARGEBACK = 'chargeback'; + /** * @param array $data - Data that will be saved on the order to identify the payment */ @@ -24,55 +36,60 @@ public static function validationError(string $message): ResponseInterface public static function paid(): ResponseInterface { - return self::createStatusResponse('paid'); + return self::createStatusResponse(self::ACTION_PAID); } public static function paidPartially(): ResponseInterface { - return self::createStatusResponse('paid_partially'); + return self::createStatusResponse(self::ACTION_PAID_PARTIALLY); } public static function cancelled(string $message = ''): ResponseInterface { - return self::createStatusResponse('cancelled', $message); + return self::createStatusResponse(self::ACTION_CANCEL, $message); } public static function failed(string $message = ''): ResponseInterface { - return self::createStatusResponse('failed', $message); + return self::createStatusResponse(self::ACTION_FAIL, $message); } public static function authorize(): ResponseInterface { - return self::createStatusResponse('authorize'); + return self::createStatusResponse(self::ACTION_AUTHORIZE); } public static function unconfirmed(): ResponseInterface { - return self::createStatusResponse('unconfirmed'); + return self::createStatusResponse(self::ACTION_PROCESS_UNCONFIRMED); } public static function inProgress(): ResponseInterface { - return self::createStatusResponse('in_progress'); + return self::createStatusResponse(self::ACTION_PROCESS); } public static function refunded(): ResponseInterface { - return self::createStatusResponse('refunded'); + return self::createStatusResponse(self::ACTION_REFUND); } public static function reminded(): ResponseInterface { - return self::createStatusResponse('reminded'); + return self::createStatusResponse(self::ACTION_REMIND); } public static function chargeback(): ResponseInterface { - return self::createStatusResponse('chargeback'); + return self::createStatusResponse(self::ACTION_CHARGEBACK); + } + + public static function reopen(): ResponseInterface + { + return self::createStatusResponse(self::ACTION_REOPEN); } - private static function createStatusResponse(string $status, string $message = ''): ResponseInterface + public static function createStatusResponse(string $status, string $message = ''): ResponseInterface { return self::createResponse(array_filter(['status' => $status, 'message' => $message])); } diff --git a/src/Response/RefundResponse.php b/src/Response/RefundResponse.php index d47e38e..7e6cd58 100644 --- a/src/Response/RefundResponse.php +++ b/src/Response/RefundResponse.php @@ -9,29 +9,35 @@ class RefundResponse { + public const ACTION_CANCEL = 'cancel'; + public const ACTION_COMPLETE = 'complete'; + public const ACTION_FAIL = 'fail'; + public const ACTION_PROCESS = 'process'; + public const ACTION_REOPEN = 'reopen'; + public static function open(): ResponseInterface { - return self::createStatusResponse('open'); + return self::createStatusResponse(self::ACTION_REOPEN); } public static function inProgress(): ResponseInterface { - return self::createStatusResponse('in_progress'); + return self::createStatusResponse(self::ACTION_PROCESS); } public static function cancelled(): ResponseInterface { - return self::createStatusResponse('cancelled'); + return self::createStatusResponse(self::ACTION_CANCEL); } public static function failed(): ResponseInterface { - return self::createStatusResponse('failed'); + return self::createStatusResponse(self::ACTION_FAIL); } public static function completed(): ResponseInterface { - return self::createStatusResponse('completed'); + return self::createStatusResponse(self::ACTION_COMPLETE); } private static function createStatusResponse(string $status): ResponseInterface diff --git a/tests/Response/PaymentResponseTest.php b/tests/Response/PaymentResponseTest.php index d49c75a..2f50a71 100644 --- a/tests/Response/PaymentResponseTest.php +++ b/tests/Response/PaymentResponseTest.php @@ -32,7 +32,7 @@ public function testCancelled(): void $response = PaymentResponse::cancelled(); static::assertSame(200, $response->getStatusCode()); - static::assertSame('{"status":"cancelled"}', $response->getBody()->getContents()); + static::assertSame('{"status":"cancel"}', $response->getBody()->getContents()); } public function testFailed(): void @@ -40,7 +40,7 @@ public function testFailed(): void $response = PaymentResponse::failed(); static::assertSame(200, $response->getStatusCode()); - static::assertSame('{"status":"failed"}', $response->getBody()->getContents()); + static::assertSame('{"status":"fail"}', $response->getBody()->getContents()); } public function testAuthorize(): void @@ -56,7 +56,7 @@ public function testUnconfirmed(): void $response = PaymentResponse::unconfirmed(); static::assertSame(200, $response->getStatusCode()); - static::assertSame('{"status":"unconfirmed"}', $response->getBody()->getContents()); + static::assertSame('{"status":"process_unconfirmed"}', $response->getBody()->getContents()); } public function testInProgress(): void @@ -64,7 +64,7 @@ public function testInProgress(): void $response = PaymentResponse::inProgress(); static::assertSame(200, $response->getStatusCode()); - static::assertSame('{"status":"in_progress"}', $response->getBody()->getContents()); + static::assertSame('{"status":"process"}', $response->getBody()->getContents()); } public function testRefunded(): void @@ -72,7 +72,7 @@ public function testRefunded(): void $response = PaymentResponse::refunded(); static::assertSame(200, $response->getStatusCode()); - static::assertSame('{"status":"refunded"}', $response->getBody()->getContents()); + static::assertSame('{"status":"refund"}', $response->getBody()->getContents()); } public function testReminded(): void @@ -80,7 +80,7 @@ public function testReminded(): void $response = PaymentResponse::reminded(); static::assertSame(200, $response->getStatusCode()); - static::assertSame('{"status":"reminded"}', $response->getBody()->getContents()); + static::assertSame('{"status":"remind"}', $response->getBody()->getContents()); } public function testChargeback(): void diff --git a/tests/Response/RefundResponseTest.php b/tests/Response/RefundResponseTest.php index 921103c..7b2d073 100644 --- a/tests/Response/RefundResponseTest.php +++ b/tests/Response/RefundResponseTest.php @@ -17,7 +17,7 @@ public function testOpen(): void static::assertSame(200, $response->getStatusCode()); static::assertSame('application/json', $response->getHeaderLine('Content-Type')); - static::assertSame('{"status":"open"}', $response->getBody()->getContents()); + static::assertSame('{"status":"reopen"}', $response->getBody()->getContents()); } public function testInProgress(): void @@ -26,7 +26,7 @@ public function testInProgress(): void static::assertSame(200, $response->getStatusCode()); static::assertSame('application/json', $response->getHeaderLine('Content-Type')); - static::assertSame('{"status":"in_progress"}', $response->getBody()->getContents()); + static::assertSame('{"status":"process"}', $response->getBody()->getContents()); } public function testCancelled(): void @@ -35,7 +35,7 @@ public function testCancelled(): void static::assertSame(200, $response->getStatusCode()); static::assertSame('application/json', $response->getHeaderLine('Content-Type')); - static::assertSame('{"status":"cancelled"}', $response->getBody()->getContents()); + static::assertSame('{"status":"cancel"}', $response->getBody()->getContents()); } public function testFailed(): void @@ -44,7 +44,7 @@ public function testFailed(): void static::assertSame(200, $response->getStatusCode()); static::assertSame('application/json', $response->getHeaderLine('Content-Type')); - static::assertSame('{"status":"failed"}', $response->getBody()->getContents()); + static::assertSame('{"status":"fail"}', $response->getBody()->getContents()); } public function testCompleted(): void @@ -53,6 +53,6 @@ public function testCompleted(): void static::assertSame(200, $response->getStatusCode()); static::assertSame('application/json', $response->getHeaderLine('Content-Type')); - static::assertSame('{"status":"completed"}', $response->getBody()->getContents()); + static::assertSame('{"status":"complete"}', $response->getBody()->getContents()); } }