PHPackages                             aliirfaan/citronel-commerce - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. aliirfaan/citronel-commerce

ActiveLibrary

aliirfaan/citronel-commerce
===========================

This package provides classes to create simple e-commerce flow using products, order, payments and fulfillments.

1.1.0(1mo ago)026MITPHPPHP &gt;=8.0.0

Since Apr 16Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/aliirfaan/citronel-commerce)[ Packagist](https://packagist.org/packages/aliirfaan/citronel-commerce)[ RSS](/packages/aliirfaan-citronel-commerce/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (12)Used By (0)

Citronel commerce
=================

[](#citronel-commerce)

Simple order and payment processing for Laravel API project.

Dependencies
------------

[](#dependencies)

- [aliirfaan/citronel-core](https://github.com/aliirfaan/citronel-core)
- [aliirfaan/citronel-job](https://github.com/aliirfaan/citronel-job)

Features
--------

[](#features)

- Product

- Keep products/services in a product table with product configurations.
- Each product may use contracts and have a product class that allows you customize order process per product.

- Order

- Create order by adding products.
- An order contains order items.
- An order item has a product and quantity.
- Order status

- Currency

- Use currency service and contract to refresh currency rates.

- Payment

- Add different payment methods.
- A payment method can be linked to different payment configurations.
- Use payment gateway contract to integrate with payment gateways.
- Manual payment confirmation.
- Payment status

- Fulfillment

- Once payment is completed, create order fulfillment.
- Manual fulfillment retries.

- Refund

- Payment refunds

Product
-------

[](#product)

### Features

[](#features-1)

- product\_class Each product has a product class that extends traits.
- fulfillment\_type Each product may be fulfillemt type as sync or async(queue).
- allow\_transaction Transactions/payments can be disabled per product.
- allow\_manual\_retry Alow manual fulfillment in case of failure.

### Contracts

[](#contracts)

- AbstractCitronelProduct
    Each product class must extend AbstractCitronelProduct.
    A product class may also implement contracts found in `src/Contracts/Product`

Order
-----

[](#order)

### Config

[](#config)

- citronel-order.php

### Features

[](#features-2)

- fulfillment failure notification

Payment method
--------------

[](#payment-method)

Payment method configuration
----------------------------

[](#payment-method-configuration)

Payment
-------

[](#payment)

Currency
--------

[](#currency)

Fulfillment
-----------

[](#fulfillment)

Manual fulfillment
------------------

[](#manual-fulfillment)

Refund
------

[](#refund)

Create a migration to link order to an actor
--------------------------------------------

[](#create-a-migration-to-link-order-to-an-actor)

```
$ php artisan make:migration alter_actor_id_in_orders_table --table=orders
```

```
// use actor
use aliirfaan\CitronelAuth\Models\Actor\CitronelActor;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('orders', function (Blueprint $table) {
            // Drop the existing actor_id column
            $table->dropColumn('actor_id');

            // Add the actor_id column with foreign key constraint
            $table->foreignId('actor_id')
                ->nullable()
                ->constrained((new CitronelActor)->getTable());
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('orders', function (Blueprint $table) {
            // Drop the foreign key constraint
            $table->dropForeign(['actor_id']);

            // Re-add the actor_id column as uuid and nullable
            $table->uuid('actor_id')->nullable(true);
        });
    }
}
```

Routes
------

[](#routes)

- Publish routes if you want to override them

```
$ php artisan vendor:publish --tag=citronel-commerce-routes
```

- Make sure to review routes and remove endpoints you do not want to expose
- Review route prefix

Middleware
----------

[](#middleware)

- Review route middleware
    Add policy to check if linked actor is the one doing the action: // authorize - MatchActorToken middleware

```
\aliirfaan\CitronelAuth\Http\Middleware\Actor\EnsureActorIsVerified::class,
\aliirfaan\CitronelAuth\Http\Middleware\Actor\EnsureActorIsActive::class,
ActorTokenIsValid,
MatchActorToken
```

Extend citronel order
---------------------

[](#extend-citronel-order)

### actor validation rules

[](#actor-validation-rules)

```
