Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions app/Billing/Gateways/BankPaymentGateway.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace App\Billing\Gateways;

use App\Billing\PaymentGatewayContract;

final class BankPaymentGateway implements PaymentGatewayContract
{

public function charge(int $amountInCents): array
{
// TODO: Implement charge() method.
}

public function setDiscount(int $amountInCents): void
{
// TODO: Implement setDiscount() method.
}

public function processPayment()
{
// TODO: Implement processPayment() method.
}
}
24 changes: 24 additions & 0 deletions app/Billing/Gateways/CreditCardPaymentGateway.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Billing\Gateways;

use App\Billing\PaymentGatewayContract;

class CreditCardPaymentGateway implements PaymentGatewayContract
{

public function charge(int $amountInCents): array
{
// TODO: Implement charge() method.
}

public function setDiscount(int $amountInCents): void
{
// TODO: Implement setDiscount() method.
}

public function processPayment()
{
// TODO: Implement processPayment() method.
}
}
23 changes: 23 additions & 0 deletions app/Billing/Gateways/CryptoPaymentGateway.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace App\Billing\Gateways;

use App\Billing\PaymentGatewayContract;

class CryptoPaymentGateway implements PaymentGatewayContract
{
public function charge(int $amountInCents): array
{
// TODO: Implement charge() method.
}

public function setDiscount(int $amountInCents): void
{
// TODO: Implement setDiscount() method.
}

public function processPayment()
{
// TODO: Implement processPayment() method.
}
}
24 changes: 24 additions & 0 deletions app/Billing/Gateways/PayPalPaymentGateway.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Billing\Gateways;

use App\Billing\PaymentGatewayContract;

class PayPalPaymentGateway implements PaymentGatewayContract
{

public function charge(int $amountInCents): array
{
// TODO: Implement charge() method.
}

public function setDiscount(int $amountInCents): void
{
// TODO: Implement setDiscount() method.
}

public function processPayment()
{
// TODO: Implement processPayment() method.
}
}
24 changes: 24 additions & 0 deletions app/Billing/Gateways/StripePaymentGateway.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Billing\Gateways;

use App\Billing\PaymentGatewayContract;

class StripePaymentGateway implements PaymentGatewayContract
{

public function charge(int $amountInCents): array
{
// TODO: Implement charge() method.
}

public function setDiscount(int $amountInCents): void
{
// TODO: Implement setDiscount() method.
}

public function processPayment()
{
// TODO: Implement processPayment() method.
}
}
25 changes: 25 additions & 0 deletions app/Billing/Order/OrderDetails.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace App\Billing\Order;

use App\Billing\PaymentGatewayContract;
use Illuminate\Http\Request;

class OrderDetails
{
private PaymentGatewayContract $paymentGateway;
private array $orderItems;

public function __construct(Request $request, PaymentGatewayContract $paymentGateway)
{
$this->paymentGateway = $paymentGateway;
$this->request = $request;
$this->orderItems = $request->input('order_items');
}

public function processOrder(): void
{
$this->paymentGateway->setDiscount(50); //test
$this->paymentGateway->setItems($this->orderItems);
}
}
14 changes: 14 additions & 0 deletions app/Billing/PaymentGatewayContract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace App\Billing;

interface PaymentGatewayContract
{
public function charge(int $amountInCents): array;

public function setDiscount(int $amountInCents): void;

public function processPayment();
}
20 changes: 20 additions & 0 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,24 @@ public function index()
{
return view('home');
}

/**
* @return array
*/
private function getTranslations(): array
{
return $this->translations = [
'test_translation' => __('Document Serial Number'),
];
}

/**
* @return array
*/
private function getPermissions(): array
{
return $this->permissions = [
'view home',
];
}
}
68 changes: 68 additions & 0 deletions app/Http/Controllers/InterfaceUsageController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

namespace App\Http\Controllers;

use App\Models\InterfaceUsage;
use App\Http\Requests\StoreInterfaceUsageRequest;
use App\Http\Requests\UpdateInterfaceUsageRequest;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Response;

class InterfaceUsageController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index(): Response
{
//
}

/**
* Show the form for creating a new resource.
*/
public function create(): Response
{
//
}

/**
* Store a newly created resource in storage.
*/
public function store(StoreInterfaceUsageRequest $request): RedirectResponse
{
//
}

/**
* Display the specified resource.
*/
public function show(InterfaceUsage $interfaceUsage): Response
{
//
}

/**
* Show the form for editing the specified resource.
*/
public function edit(InterfaceUsage $interfaceUsage): Response
{
//
}

/**
* Update the specified resource in storage.
*/
public function update(UpdateInterfaceUsageRequest $request, InterfaceUsage $interfaceUsage): RedirectResponse
{
//
}

/**
* Remove the specified resource from storage.
*/
public function destroy(InterfaceUsage $interfaceUsage): RedirectResponse
{
//
}
}
22 changes: 22 additions & 0 deletions app/Http/Controllers/Payments/PayOrderController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers\Payments;


use App\Billing\Order\OrderDetails;
use App\Billing\PaymentGatewayContract;
use App\Http\Controllers\Controller;


final class PayOrderController extends Controller
{
public function store(OrderDetails $orderDetails, PaymentGatewayContract $paymentGateway): void
{
$orderDetails->processOrder();

$paymentGateway->setDiscount(10);
$paymentGateway->charge(5000);
}
}
28 changes: 28 additions & 0 deletions app/Http/Requests/StoreInterfaceUsageRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class StoreInterfaceUsageRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return false;
}

/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\Rule|array|string>
*/
public function rules(): array
{
return [
//
];
}
}
28 changes: 28 additions & 0 deletions app/Http/Requests/UpdateInterfaceUsageRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class UpdateInterfaceUsageRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return false;
}

/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\Rule|array|string>
*/
public function rules(): array
{
return [
//
];
}
}
15 changes: 15 additions & 0 deletions app/Models/InterfaceUsage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class InterfaceUsage extends Model
{
use HasFactory;

protected $guarded = [];

protected $fillable = [];
}
Loading