generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
d34d7a3
commit f8c810f
Showing
18 changed files
with
273 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Routegroup\Imoje\Payment\DTO\Api; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use JetBrains\PhpStorm\ArrayShape; | ||
use Routegroup\Imoje\Payment\DTO\BaseDto; | ||
use Routegroup\Imoje\Payment\DTO\Casts\CustomerDto; | ||
use Routegroup\Imoje\Payment\Factories\Api\PaymentDtoFactory; | ||
use Routegroup\Imoje\Payment\Lib\Config; | ||
use Routegroup\Imoje\Payment\Types\Currency; | ||
|
||
/** | ||
* @property-read string $serviceId | ||
* @property-read int $amount | ||
* @property-read Currency $currency | ||
* @property-read string $orderId | ||
* @property-read CustomerDto $customer | ||
* @property-read string $title | ||
* @property-read string $visibleMethod | ||
* @property-read string $preselectMethodCode | ||
* @property-read string $returnUrl | ||
* @property-read string $successReturnUrl | ||
* @property-read string $failureReturnUrl | ||
* @property-read string $simp | ||
* @property-read int $validTo | ||
* @property-read array $cart | ||
*/ | ||
class PaymentDto extends BaseDto | ||
{ | ||
use HasFactory; | ||
|
||
protected bool $allowNull = true; | ||
|
||
protected array $casts = [ | ||
'amount' => 'int', | ||
'currency' => Currency::class, | ||
'customer' => CustomerDto::class, | ||
]; | ||
|
||
public function __construct( | ||
#[ArrayShape([ | ||
// Required | ||
'amount' => 'int', | ||
'currency' => 'string', | ||
'orderId' => 'string', | ||
'customer' => 'object', | ||
// Required but provided, | ||
'serviceId' => 'string', | ||
// Optional | ||
'title' => 'string', | ||
'visibleMethod' => 'string', | ||
'preselectMethodCode' => 'string', | ||
'returnUrl' => 'string', | ||
'successReturnUrl' => 'string', | ||
'failureReturnUrl' => 'string', | ||
'simp' => 'string', | ||
'validTo' => 'int', | ||
'cart' => 'array', | ||
])] array $attributes = [] | ||
) { | ||
$config = app(Config::class); | ||
|
||
$attributes = array_merge_recursive([ | ||
'serviceId' => $config->serviceId, | ||
], $attributes); | ||
|
||
parent::__construct($attributes); | ||
} | ||
|
||
protected static function newFactory(): PaymentDtoFactory | ||
{ | ||
return PaymentDtoFactory::new(); | ||
} | ||
} |
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
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
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,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Routegroup\Imoje\Payment\DTO\Casts; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Routegroup\Imoje\Payment\DTO\BaseDto; | ||
use Routegroup\Imoje\Payment\Factories\Casts\TransactionPaymentDtoFactory; | ||
use Routegroup\Imoje\Payment\Types\Currency; | ||
use Routegroup\Imoje\Payment\Types\TransactionStatus; | ||
|
||
/** | ||
* @property-read string $id | ||
* @property-read string|null $title | ||
* @property-read int $amount | ||
* @property-read TransactionStatus $status | ||
* @property-read int $created | ||
* @property-read string $orderId | ||
* @property-read Currency $currency | ||
* @property-read int $modified | ||
* @property-read string $serviceId | ||
*/ | ||
class TransactionPaymentDto extends BaseDto | ||
{ | ||
use HasFactory; | ||
|
||
protected array $casts = [ | ||
'id' => 'string', | ||
'amount' => 'int', | ||
'status' => TransactionStatus::class, | ||
'created' => 'int', | ||
'orderId' => 'string', | ||
'currency' => Currency::class, | ||
'modified' => 'int', | ||
'serviceId' => 'string', | ||
]; | ||
|
||
protected static function newFactory(): TransactionPaymentDtoFactory | ||
{ | ||
return TransactionPaymentDtoFactory::new(); | ||
} | ||
} |
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
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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Routegroup\Imoje\Payment\DTO\Responses; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Routegroup\Imoje\Payment\DTO\Casts\PaymentDto; | ||
use Routegroup\Imoje\Payment\Factories\Api\PaymentDtoFactory; | ||
|
||
/** | ||
* @property-read PaymentDto $payment | ||
*/ | ||
class PaymentResponseDto extends ResponseDto | ||
{ | ||
use HasFactory; | ||
|
||
protected array $casts = [ | ||
'payment' => PaymentDto::class, | ||
]; | ||
|
||
protected static function newFactory(): PaymentDtoFactory | ||
{ | ||
return PaymentDtoFactory::new(); | ||
} | ||
} |
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,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Routegroup\Imoje\Payment\Factories\Api; | ||
|
||
use Routegroup\Imoje\Payment\DTO\Api\PaymentDto; | ||
use Routegroup\Imoje\Payment\DTO\Casts\CustomerDto; | ||
use Routegroup\Imoje\Payment\Factories\Factory; | ||
use Routegroup\Imoje\Payment\Types\Currency; | ||
|
||
class PaymentDtoFactory extends Factory | ||
{ | ||
protected $model = PaymentDto::class; | ||
|
||
public function definition(): array | ||
{ | ||
return [ | ||
'amount' => $this->faker->numberBetween(1, 100) * 100, | ||
'currency' => Currency::PLN, | ||
'orderId' => $this->faker->uuid, | ||
'customer' => CustomerDto::factory(), | ||
'returnUrl' => 'https://imoje.requestcatcher.com', | ||
'successReturnUrl' => 'https://imoje.requestcatcher.com', | ||
'failureReturnUrl' => 'https://imoje.requestcatcher.com', | ||
]; | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Routegroup\Imoje\Payment\Factories\Casts; | ||
|
||
use Routegroup\Imoje\Payment\DTO\Casts\TransactionPaymentDto; | ||
use Routegroup\Imoje\Payment\Factories\Factory; | ||
use Routegroup\Imoje\Payment\Types\Currency; | ||
use Routegroup\Imoje\Payment\Types\TransactionStatus; | ||
|
||
class TransactionPaymentDtoFactory extends Factory | ||
{ | ||
protected $model = TransactionPaymentDto::class; | ||
|
||
public function definition(): array | ||
{ | ||
$now = now(); | ||
|
||
return [ | ||
'id' => $this->faker->unique()->uuid, | ||
'amount' => $this->faker->numberBetween(1, 1000) * 100, | ||
'status' => TransactionStatus::SETTLED, | ||
'created' => $now->timestamp, | ||
'orderId' => $this->faker->unique()->uuid, | ||
'currency' => Currency::PLN, | ||
'modified' => $now->timestamp, | ||
'serviceId' => config('services.imoje.service_key'), | ||
]; | ||
} | ||
} |
Oops, something went wrong.