Skip to content

Commit

Permalink
Rename "Payment" to "Checkout" where relevant
Browse files Browse the repository at this point in the history
  • Loading branch information
r-kujawa committed Apr 19, 2024
1 parent a41aa90 commit 03d407d
Show file tree
Hide file tree
Showing 24 changed files with 283 additions and 284 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "payavel/checkout",
"description": "The best checkout solution that integrates with any payment processor and Laravel.",
"description": "Laravel package providing checkout with easy setup and flexible configurations to fit any e-commerce requirements.",
"license": "MIT",
"authors": [
{
Expand Down Expand Up @@ -33,7 +33,7 @@
"extra": {
"laravel": {
"providers": [
"Payavel\\Checkout\\PaymentServiceProvider"
"Payavel\\Checkout\\CheckoutServiceProvider"
]
}
}
Expand Down
8 changes: 4 additions & 4 deletions config/checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@
| Checkout Test Mode
|--------------------------------------------------------------------------
|
| When set to true, the provider & account will be shared with the fake payment
| When set to true, the provider & account will be shared with the fake checkout
| request so you can mock your responses as you wish. This is very useful for
| local & testing environments where a sandbox is limited or non-existent.
|
*/
'test_mode' => env('PAYMENT_TEST_MODE', false),
'test_mode' => env('CHECKOUT_TEST_MODE', false),

/*
|--------------------------------------------------------------------------
| Checkout Testing
|--------------------------------------------------------------------------
|
| This option allows you to define the location of the fake payment
| This option allows you to define the location of the fake checkout
| request & response classes you would like to leverage when test_mode
| is set to true. Also, feel free to add any other settings here.
|
*/
'test_gateway' => \App\Services\Payment\FakePaymentRequest::class,
'test_gateway' => \App\Services\Checkout\FakeCheckoutRequest::class,

];
1 change: 0 additions & 1 deletion database/factories/PaymentMethodFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Payavel\Checkout\Models\Wallet;
use Payavel\Checkout\Models\PaymentMethod;
use Payavel\Checkout\Models\PaymentType;
use Payavel\Orchestration\Support\ServiceConfig;

class PaymentMethodFactory extends Factory
{
Expand Down
12 changes: 6 additions & 6 deletions database/factories/PaymentTransactionEventFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Database\Eloquent\Factories\Factory;
use Payavel\Checkout\Models\PaymentTransaction;
use Payavel\Checkout\Models\PaymentTransactionEvent;
use Payavel\Checkout\PaymentStatus;
use Payavel\Checkout\CheckoutStatus;

class PaymentTransactionEventFactory extends Factory
{
Expand All @@ -26,11 +26,11 @@ public function definition()
return [
'reference' => $this->faker->uuid(),
'status_code' => $this->faker->randomElement([
PaymentStatus::CAPTURED,
PaymentStatus::SETTLED,
PaymentStatus::VOIDED,
PaymentStatus::REFUNDED,
PaymentStatus::REFUND_SETTLED,
CheckoutStatus::CAPTURED,
CheckoutStatus::SETTLED,
CheckoutStatus::VOIDED,
CheckoutStatus::REFUNDED,
CheckoutStatus::REFUND_SETTLED,
]),
];
}
Expand Down
4 changes: 2 additions & 2 deletions database/factories/PaymentTransactionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Database\Eloquent\Factories\Factory;
use Payavel\Checkout\Models\PaymentTransaction;
use Payavel\Checkout\PaymentStatus;
use Payavel\Checkout\CheckoutStatus;
use Payavel\Orchestration\Models\Account;
use Payavel\Orchestration\Models\Provider;

Expand All @@ -28,7 +28,7 @@ public function definition()
'reference' => $this->faker->uuid(),
'amount' => $this->faker->numberBetween(1, 999) * 100,
'currency' => $this->faker->currencyCode(),
'status_code' => PaymentStatus::AUTHORIZED,
'status_code' => CheckoutStatus::AUTHORIZED,
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/PaymentGateway.php → src/CheckoutGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Payavel\Orchestration\Service;

class PaymentGateway extends Service
class CheckoutGateway extends Service
{
public function __construct()
{
Expand Down
19 changes: 19 additions & 0 deletions src/CheckoutRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Payavel\Checkout;

use Payavel\Checkout\Contracts\CheckoutRequester;
use Payavel\Checkout\Traits\CheckoutRequests;
use Payavel\Orchestration\ServiceRequest;

abstract class CheckoutRequest extends ServiceRequest implements CheckoutRequester
{
use CheckoutRequests;

/**
* The service response class.
*
* @var \Payavel\Orchestration\ServiceResponse
*/
protected $serviceResponse = CheckoutResponse::class;
}
54 changes: 54 additions & 0 deletions src/CheckoutResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace Payavel\Checkout;

use Payavel\Checkout\Contracts\CheckoutResponder;
use Payavel\Checkout\Traits\CheckoutResponses;
use Payavel\Orchestration\ServiceResponse;

abstract class CheckoutResponse extends ServiceResponse implements CheckoutResponder
{
use CheckoutResponses;

/**
* Statuses in this array are considered successful.
*
* @var array
*/
protected $successStatuses = [
CheckoutStatus::AUTHORIZED,
CheckoutStatus::APPROVED,
CheckoutStatus::CAPTURED,
CheckoutStatus::PARTIALLY_CAPTURED,
CheckoutStatus::SETTLED,
CheckoutStatus::CANCELED,
CheckoutStatus::VOIDED,
CheckoutStatus::REFUNDED,
CheckoutStatus::PARTIALLY_REFUNDED,
CheckoutStatus::REFUND_SETTLED,
CheckoutStatus::REFUND_FAILED,
CheckoutStatus::REFUND_REVERSED,
CheckoutStatus::PENDING,
CheckoutStatus::PROCESSING_ASYNC,
];

/**
* Get a string representation of the response's status.
*
* @return string|null
*/
public function getStatusMessage()

Check warning on line 40 in src/CheckoutResponse.php

View check run for this annotation

Codecov / codecov/patch

src/CheckoutResponse.php#L40

Added line #L40 was not covered by tests
{
return CheckoutStatus::get($this->getStatusCode());

Check warning on line 42 in src/CheckoutResponse.php

View check run for this annotation

Codecov / codecov/patch

src/CheckoutResponse.php#L42

Added line #L42 was not covered by tests
}

/**
* Get a description of the response's status.
*
* @return string|null
*/
public function getStatusDescription()

Check warning on line 50 in src/CheckoutResponse.php

View check run for this annotation

Codecov / codecov/patch

src/CheckoutResponse.php#L50

Added line #L50 was not covered by tests
{
return CheckoutStatus::getMessage($this->getStatusCode());

Check warning on line 52 in src/CheckoutResponse.php

View check run for this annotation

Codecov / codecov/patch

src/CheckoutResponse.php#L52

Added line #L52 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Payavel\Checkout\Console\Commands\CheckoutInstall;
use Payavel\Checkout\Console\Commands\CheckoutProvider;

class PaymentServiceProvider extends ServiceProvider
class CheckoutServiceProvider extends ServiceProvider
{
public function boot()
{
Expand All @@ -23,8 +23,8 @@ public function boot()

public function register()
{
$this->app->singleton(PaymentGateway::class, function ($app) {
return new PaymentGateway();
$this->app->singleton(CheckoutGateway::class, function ($app) {
return new CheckoutGateway();
});

$this->mergeConfigFrom(
Expand Down
110 changes: 55 additions & 55 deletions src/PaymentStatus.php → src/CheckoutStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,63 @@

namespace Payavel\Checkout;

class PaymentStatus
class CheckoutStatus
{
const AUTHORIZED = 200;
const APPROVED = 201;
const CAPTURED = 202;
const PARTIALLY_CAPTURED = 203;
const SETTLED = 204;
const CANCELED = 210;
const VOIDED = 211;
const REFUNDED = 212;
const PARTIALLY_REFUNDED = 213;
const REFUND_SETTLED = 214;
const REFUND_FAILED = 215;
const REFUND_REVERSED = 216;
const CHARGEBACK = 220;
const CHARGEBACK_WON = 221;
const CHARGEBACK_LOST = 222;
const CHARGEBACK_REVERSED = 223;
const SECOND_CHARGEBACK = 224;
const PENDING = 300;
const PROCESSING_ASYNC = 301;
const REFUSED = 400;
const DECLINED = 401;
const REFERRED = 402;
const NOT_ENOUGH_BALANCE = 403;
const INVALID_CARD = 410;
const INVALID_CARD_HOLDER_NAME = 411;
const INVALID_CARD_NUMBER = 412;
const INVALID_CARD_EXPIRY = 413;
const INVALID_CARD_SECURITY_CODE = 414;
const BLOCKED_CARD = 415;
const RESTRICTED_CARD = 416;
const INVALID_ADDRESS = 460;
const INVALID_BILLING_ADDRESS = 461;
const INVALID_SHIPPING_ADDRESS = 462;
const FRAUD = 470;
const FAILED_FRAUD_CHECK = 471;
const ACQUIRER_SUSPECTED_FRAUD = 472;
const ISSUER_SUSPECTED_FRAUD = 473;
const AVS_DECLINED = 474;
const INVALID_TRANSACTION = 480;
const INVALID_CREDENTIALS = 481;
const INVALID_AMOUNT = 482;
const TRANSACTION_NOT_SUPPORTED = 483;
const TRANSACTION_NOT_PERMITTED = 484;
const DUPLICATE_TRANSACTION = 485;
const PROCESSING_ISSUE = 490;
const AUTHORIZATION_REVOKED = 491;
const ACQUIRER_UNREACHABLE = 492;
const ISSUER_UNREACHABLE = 493;
const ERROR = 500;
const ACQUIRER_ERROR = 501;
const ISSUER_ERROR = 502;
const UNKNOWN_ERROR = 503;
public const AUTHORIZED = 200;
public const APPROVED = 201;
public const CAPTURED = 202;
public const PARTIALLY_CAPTURED = 203;
public const SETTLED = 204;
public const CANCELED = 210;
public const VOIDED = 211;
public const REFUNDED = 212;
public const PARTIALLY_REFUNDED = 213;
public const REFUND_SETTLED = 214;
public const REFUND_FAILED = 215;
public const REFUND_REVERSED = 216;
public const CHARGEBACK = 220;
public const CHARGEBACK_WON = 221;
public const CHARGEBACK_LOST = 222;
public const CHARGEBACK_REVERSED = 223;
public const SECOND_CHARGEBACK = 224;
public const PENDING = 300;
public const PROCESSING_ASYNC = 301;
public const REFUSED = 400;
public const DECLINED = 401;
public const REFERRED = 402;
public const NOT_ENOUGH_BALANCE = 403;
public const INVALID_CARD = 410;
public const INVALID_CARD_HOLDER_NAME = 411;
public const INVALID_CARD_NUMBER = 412;
public const INVALID_CARD_EXPIRY = 413;
public const INVALID_CARD_SECURITY_CODE = 414;
public const BLOCKED_CARD = 415;
public const RESTRICTED_CARD = 416;
public const INVALID_ADDRESS = 460;
public const INVALID_BILLING_ADDRESS = 461;
public const INVALID_SHIPPING_ADDRESS = 462;
public const FRAUD = 470;
public const FAILED_FRAUD_CHECK = 471;
public const ACQUIRER_SUSPECTED_FRAUD = 472;
public const ISSUER_SUSPECTED_FRAUD = 473;
public const AVS_DECLINED = 474;
public const INVALID_TRANSACTION = 480;
public const INVALID_CREDENTIALS = 481;
public const INVALID_AMOUNT = 482;
public const TRANSACTION_NOT_SUPPORTED = 483;
public const TRANSACTION_NOT_PERMITTED = 484;
public const DUPLICATE_TRANSACTION = 485;
public const PROCESSING_ISSUE = 490;
public const AUTHORIZATION_REVOKED = 491;
public const ACQUIRER_UNREACHABLE = 492;
public const ISSUER_UNREACHABLE = 493;
public const ERROR = 500;
public const ACQUIRER_ERROR = 501;
public const ISSUER_ERROR = 502;
public const UNKNOWN_ERROR = 503;

/**
* List of all supported payment response codes.
* List of all supported checkout response codes.
*
* @var array
*/
Expand Down Expand Up @@ -118,7 +118,7 @@ class PaymentStatus
];

/**
* List of all supported payment response code messages.
* List of all supported checkout response code messages.
*
* @var array
*/
Expand Down
Loading

0 comments on commit 03d407d

Please sign in to comment.