Skip to content
Merged
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
38 changes: 38 additions & 0 deletions .github/workflows/pint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Pint

on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

jobs:
pint:
runs-on: ubuntu-latest

name: Pint check

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
coverage: none

- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"

- name: Install dependencies
run: composer update --prefer-dist --no-interaction

- name: Run Pint
run: vendor/bin/pint --test
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"require-dev": {
"phpunit/phpunit": "^11.0.1",
"orchestra/testbench": "^9.16",
"juzaweb/core": "^5.0"
"juzaweb/core": "^5.0",
"laravel/pint": "^1.29"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion database/Seeders/PaymentDatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Juzaweb\Modules\Payment\Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;

class PaymentDatabaseSeeder extends Seeder
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
Expand Down
4 changes: 2 additions & 2 deletions database/migrations/2025_09_06_104610_create_orders_table.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
Expand Down
4 changes: 2 additions & 2 deletions database/migrations/2025_09_07_043220_create_carts_table.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
Expand Down
21 changes: 8 additions & 13 deletions helpers/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
use Illuminate\Support\Facades\Cookie;
use Juzaweb\Modules\Payment\Models\Cart;

if (!function_exists('find_or_create_cart')) {
if (! function_exists('find_or_create_cart')) {
/**
* Find or create a cart for the current actor.
*
* @param string|null $cartId The cart ID from cookie.
* @return Cart
* @param string|null $cartId The cart ID from cookie.
*/
function find_or_create_cart(?string $cartId = null): Cart
{
Expand All @@ -32,17 +31,15 @@ function find_or_create_cart(?string $cartId = null): Cart
}
}

if (!function_exists('get_cart')) {
if (! function_exists('get_cart')) {
/**
* Get the current cart from cookie.
*
* @return Cart|null
*/
function get_cart(): ?Cart
{
$cartId = Cookie::get('cart_id');

if (!$cartId) {
if (! $cartId) {
return null;
}

Expand All @@ -53,9 +50,7 @@ function get_cart(): ?Cart
/**
* Format price with currency symbol
*
* @param float|null $price
* @param string $currency Currency code (default: USD)
* @return string
* @param string $currency Currency code (default: USD)
*/
function format_price(?float $price, string $currency = 'USD'): string
{
Expand All @@ -72,13 +67,13 @@ function format_price(?float $price, string $currency = 'USD'): string
'VND' => '₫',
];

$symbol = $symbols[$currency] ?? $currency . ' ';
$symbol = $symbols[$currency] ?? $currency.' ';

// Format based on currency
if ($currency === 'VND') {
return number_format($price, 0, '.', ',') . $symbol;
return number_format($price, 0, '.', ',').$symbol;
}

// Default format for USD, EUR, etc.
return $symbol . number_format($price, 2, '.', ',');
return $symbol.number_format($price, 2, '.', ',');
}
4 changes: 3 additions & 1 deletion src/Contracts/ModuleHandlerInterface.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

/**
* JUZAWEB CMS - Laravel CMS for Your Project
*
* @package juzaweb/cms
* @author The Anh Dang
*
* @link https://cms.juzaweb.com
*
* @license GNU V2
*/

Expand Down
4 changes: 3 additions & 1 deletion src/Contracts/PaymentGatewayInterface.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

/**
* JUZAWEB CMS - Laravel CMS for Your Project
*
* @package juzaweb/cms
* @author The Anh Dang
*
* @link https://cms.juzaweb.com
*
* @license GNU V2
*/

Expand Down
4 changes: 3 additions & 1 deletion src/Contracts/PaymentManager.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

/**
* JUZAWEB CMS - Laravel CMS for Your Project
*
* @package juzaweb/cms
* @author The Anh Dang
*
* @link https://cms.juzaweb.com
*
* @license GNU V2
*/

Expand Down
4 changes: 3 additions & 1 deletion src/Contracts/Paymentable.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

/**
* JUZAWEB CMS - Laravel CMS for Your Project
*
* @package juzaweb/cms
* @author The Anh Dang
*
* @link https://cms.juzaweb.com
*
* @license GNU V2
*/

Expand Down
5 changes: 3 additions & 2 deletions src/Enums/OrderDeliveryStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
/**
* JUZAWEB CMS - Laravel CMS for Your Project
*
* @package juzaweb/cms
* @author The Anh Dang
*
* @link https://cms.juzaweb.com
*
* @license GNU V2
*/

Expand All @@ -22,7 +23,7 @@ enum OrderDeliveryStatus: string
public static function all(): array
{
return collect(self::cases())
->mapWithKeys(fn($case) => [$case->value => $case->label()])
->mapWithKeys(fn ($case) => [$case->value => $case->label()])
->toArray();
}

Expand Down
6 changes: 4 additions & 2 deletions src/Enums/OrderPaymentStatus.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

/**
* JUZAWEB CMS - Laravel CMS for Your Project
*
* @package juzaweb/cms
* @author The Anh Dang
*
* @link https://cms.juzaweb.com
*
* @license GNU V2
*/

Expand All @@ -24,7 +26,7 @@ public static function all()

public function label(): string
{
return match($this) {
return match ($this) {
self::PENDING => __('Pending'),
self::COMPLETED => __('Paid'),
};
Expand Down
4 changes: 3 additions & 1 deletion src/Enums/PaymentHistoryStatus.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

/**
* JUZAWEB CMS - Laravel CMS for Your Project
*
* @package juzaweb/cms
* @author The Anh Dang
*
* @link https://cms.juzaweb.com
*
* @license GNU V2
*/

Expand Down
8 changes: 4 additions & 4 deletions src/Events/PaymentCancel.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

/**
* JUZAWEB CMS - Laravel CMS for Your Project
*
* @package juzaweb/cms
* @author The Anh Dang
*
* @link https://cms.juzaweb.com
*
* @license GNU V2
*/

Expand All @@ -14,7 +16,5 @@

class PaymentCancel
{
public function __construct(public Paymentable $paymentable, public array $params)
{
}
public function __construct(public Paymentable $paymentable, public array $params) {}
}
8 changes: 4 additions & 4 deletions src/Events/PaymentFail.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

/**
* JUZAWEB CMS - Laravel CMS for Your Project
*
* @package juzaweb/cms
* @author The Anh Dang
*
* @link https://cms.juzaweb.com
*
* @license GNU V2
*/

Expand All @@ -14,7 +16,5 @@

class PaymentFail
{
public function __construct(public Paymentable $paymentable, public array $params)
{
}
public function __construct(public Paymentable $paymentable, public array $params) {}
}
8 changes: 4 additions & 4 deletions src/Events/PaymentSuccess.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

/**
* JUZAWEB CMS - Laravel CMS for Your Project
*
* @package juzaweb/cms
* @author The Anh Dang
*
* @link https://cms.juzaweb.com
*
* @license GNU V2
*/

Expand All @@ -14,7 +16,5 @@

class PaymentSuccess
{
public function __construct(public Paymentable $paymentable, public array $params)
{
}
public function __construct(public Paymentable $paymentable, public array $params) {}
}
4 changes: 3 additions & 1 deletion src/Exceptions/PaymentException.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

/**
* JUZAWEB CMS - Laravel CMS for Your Project
*
* @package juzaweb/cms
* @author The Anh Dang
*
* @link https://cms.juzaweb.com
*
* @license GNU V2
*/

Expand Down
4 changes: 3 additions & 1 deletion src/Exceptions/PaymentMethodNotFound.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

/**
* JUZAWEB CMS - Laravel CMS for Your Project
*
* @package juzaweb/cms
* @author The Anh Dang
*
* @link https://cms.juzaweb.com
*
* @license GNU V2
*/

Expand Down
Loading
Loading