PHPackages                             advancelearn/manage-payment-and-orders - 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. [Framework](/categories/framework)
4. /
5. advancelearn/manage-payment-and-orders

ActiveLibrary[Framework](/categories/framework)

advancelearn/manage-payment-and-orders
======================================

Orders and payments management system in Laravel and the feature of adding sales functionality for each model

2.1.0(2y ago)8121MITPHPPHP ^8.0.2

Since Sep 20Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Saberqadimi/manage-payment-and-orders)[ Packagist](https://packagist.org/packages/advancelearn/manage-payment-and-orders)[ RSS](/packages/advancelearn-manage-payment-and-orders/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (23)Used By (0)

\#Advancelearn manage-payment-order

[![advancelearn-otp-auth](https://camo.githubusercontent.com/7a45e86f4665edb03e54e9ed7b2daf34c8a45a1c3bd2df4696126110aec56537/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f616476616e63656c6561726e2532466d616e6167652d7061796d656e742d616e642d6f72646572732e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d616476616e63656c6561726e2532466d616e6167652d7061796d656e742d616e642d6f7264657273267061747465726e3d62616e6b4e6f7465267374796c653d7374796c655f31266465736372697074696f6e3d4f72646572732b616e642b7061796d656e74732b6d616e6167656d656e742b73797374656d2b696e2b4c61726176656c2b616e642b7468652b666561747572652b6f662b616464696e672b73616c65732b66756e6374696f6e616c6974792b666f722b656163682b6d6f64656c266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667267769647468733d32353026686569676874733d6175746f)](https://camo.githubusercontent.com/7a45e86f4665edb03e54e9ed7b2daf34c8a45a1c3bd2df4696126110aec56537/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f616476616e63656c6561726e2532466d616e6167652d7061796d656e742d616e642d6f72646572732e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d616476616e63656c6561726e2532466d616e6167652d7061796d656e742d616e642d6f7264657273267061747465726e3d62616e6b4e6f7465267374796c653d7374796c655f31266465736372697074696f6e3d4f72646572732b616e642b7061796d656e74732b6d616e6167656d656e742b73797374656d2b696e2b4c61726176656c2b616e642b7468652b666561747572652b6f662b616464696e672b73616c65732b66756e6374696f6e616c6974792b666f722b656163682b6d6f64656c266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667267769647468733d32353026686569676874733d6175746f)

[![Latest Stable Version](https://camo.githubusercontent.com/12f27a598868d41afc4d81ceda3fd09d3be6d130771834311392d07709c6d229/687474703a2f2f706f7365722e707567782e6f72672f616476616e63656c6561726e2f6d616e6167652d7061796d656e742d616e642d6f72646572732f76)](https://packagist.org/packages/advancelearn/manage-payment-and-orders) [![Total Downloads](https://camo.githubusercontent.com/594470e566f2c0317809367f25b4f6e6fb1adfe35bc204259ee0071d0ac59e40/687474703a2f2f706f7365722e707567782e6f72672f616476616e63656c6561726e2f6d616e6167652d7061796d656e742d616e642d6f72646572732f646f776e6c6f616473)](https://packagist.org/packages/advancelearn/manage-payment-and-orders) [![Latest Unstable Version](https://camo.githubusercontent.com/dfe515e214e53e6fb6eda395db9a64a8ea5e840a877924046c50a02b0c0478f3/687474703a2f2f706f7365722e707567782e6f72672f616476616e63656c6561726e2f6d616e6167652d7061796d656e742d616e642d6f72646572732f762f756e737461626c65)](https://packagist.org/packages/advancelearn/manage-payment-and-orders) [![License](https://camo.githubusercontent.com/1b9add7a15dca4c11f14a08eb4f6c2ac0af2c5954c8c3a7617cc26b136e9d910/687474703a2f2f706f7365722e707567782e6f72672f616476616e63656c6561726e2f6d616e6167652d7061796d656e742d616e642d6f72646572732f6c6963656e7365)](https://packagist.org/packages/advancelearn/manage-payment-and-orders) [![PHP Version Require](https://camo.githubusercontent.com/8ca1c8367bef52e1243eb3932bf8370a507cf0551111292bce292a5332ee2855/687474703a2f2f706f7365722e707567782e6f72672f616476616e63656c6561726e2f6d616e6167652d7061796d656e742d616e642d6f72646572732f726571756972652f706870)](https://packagist.org/packages/advancelearn/manage-payment-and-orders)

- [English documents](README.md)
- [داکیومنت فارسی](README-FA.md)

Introduction
------------

[](#introduction)

This package was developed in collaboration with a Sadratech team member and AdvanceLearn. This package aims to create and manage various aspects related to user orders and payments. It includes tracking the number of products and tagging all steps of the user's purchase order." This package is currently under active development and there are plans to add a shopping voucher module in the future, pending support and feasibility.

By installing this package and during the next steps, tables of address, country, province, city, order items, order registration steps, order shipping cost, inventory and price, orders, payments will be created for you. And with the help of seder, you value some tables and you can easily have the country of Iran along with its provinces and cities in your database.

Installation
------------

[](#installation)

You can install the package with Composer.

```
composer require advancelearn/manage-payment-and-orders
```

Config
------

[](#config)

After installation, please add its provider to your config folder in the app file to complete and configure the package:

```
 \Advancelearn\ManagePaymentAndOrders\ManagePayOrderServiceProvider::class,
```

Then run this command to import and make the package tables public

```
php artisan vendor:publish
```

Select the row number of this title from among the tags and enter it

```
  Tag: AdvanceLearnManagePayAndOrder-migrations ...............
```

#### By entering the tag number of the image above, these tables will be added to the tables folder of your program

[](#by-entering-the-tag-number-of-the-image-above-these-tables-will-be-added-to-the-tables-folder-of-your-program)

[![img.png](assets/images/img.png)](assets/images/img.png)

Then enter the following command to add tables in your database

```
php artisan migrate
```

\###Now you need to follow these steps to initialize Audits in the program

```
php artisan vendor:publish
```

Select the row number of this title from among the tags and enter it

```
Tag: AdvanceLearnManagePayAndOrder-seeds .....
```

Enter the commands in order according to the picture

[![img.png](assets/images/imgSeeders.png)](assets/images/imgSeeders.png)

Adding the value for the table of order stages in the database until we can use the ID of these records when updating according to each stage of the order we wanted.

***Important***

In the next step, you have to set the values of these three tables for your user and your product (the user's address, the amount of the model that will be known as the product, and the amount of costs due to the type of shipment)

[![img_7.png](./assets/images/tables.png)](./assets/images/tables.png)

this table **`adm_addresses`** example:

[![img.png](assets/images/img_7.png)](assets/images/img_7.png)

this table ***`adm_inventories`*** example:

[![img_8.png](./assets/images/img_8.png)](./assets/images/img_8.png)

this table **`adm_shippings`** example:

[![img_9.png](./assets/images/img_9.png)](./assets/images/img_9.png)

\##Create new Order By User Request "In the initial step, it's important to note that we aim to store a user's order within the system. To achieve this, we need to send the required parameters to the 'store' method of the order service package. Upon successful validation of these parameters, we will receive a response containing the order details." We receive and send the requested parameters from the user: `$shippingId , $addressId , $description , $items`**`__!!Pay attention to the type of parameters that they should be__`**

```
$items = [
    0 => [
        'quantity' => 2,
        "inventory_id" => 1
    ]

];
$shippingId = $request->shippingId; //It can be null
$addressId = (int)$request->addressId;
$newOrder = app('orderFunction')->store($shippingId, $addressId, "test from create new order", $items);
//
return $newOrder;
#params :
# shippingId => Type of shipment,
# $addressId => The address ID stored for the user in the address table ,
# $description => create new order by user example .... ,
# $items =>  Enter the product order number and inventory ID for the corresponding model
```

### add this method for Relationship in your model with Inventory

[](#add-this-method-for-relationship-in-your-model-with-inventory)

```
    public function inventories()
    {
        return $this->morphMany(app('inventory'), 'adm_inventories');
    }
```

### After add RelationShip:

[](#after-add-relationship)

"After integrating your model with the inventory model, it is essential to implement this contract within your model. This allows you to execute various actions, such as sending emails or updating your model, during the successful payment phase. Additionally, you can seamlessly update the Inventory associated with the sold record in your model."

```
use Advancelearn\ManagePaymentAndOrders\PaymentConfirmationInterface;

class Product extends Model implements PaymentConfirmationInterface
{
    //you're methods or logic

    //added this method after implemention:
    public function paymentConfirmation($user_id, $inventory_id, $quantity)
    {
        //you're added logic after paymentConfirmation
    }
}
```

"Now you have created a new order in the order creation phase, so to redirect the user to the payment gateway, you need to send this order id to this method, you can check whether the order amount has already been paid or not. In case of non-payment, you can redirect the user to the payment gateway."

write this namespace in your class:

```
use Advancelearn\ManagePaymentAndOrders\Enums\AuditTypes;
```

```
$order = app('order')::findOrFail($orderId);

if ($order->audits->where('id', AuditTypes::PAID)->count()) {
    return response()->json(['errors' => 'Already paid'], 422);
}

```

And finally, send the final order amount to send to the portal:

```
$invoice = new Invoice;

$invoice->amount($order->payment_price);
```

And in the same method that the user was sent to the payment portal, you can create a payment for the user with a pending status:

```
 app('payment')::create
 ([
    'order_id' => $order->id,
    'driver' => $request->input('driver'),
    'transaction_id' => //transactionId from your gateway sent request for pay,
    'amount' => $order->payment_price
]);
```

And for example, in your callback method that returns from the portal, let's assume that your callback method is called paymentConfirmation.

```
public function paymentConfirmation(Request $request)
{
    $payment = app('payment')::where('transaction_id', $transactionId)->first();
    $order = app('order')::find($payment->order_id);
     $receipt = //api call gateway for verifyPayment and get response add to this variable
    $this->verifyPayAndConfirm($payment, $order, $request);
//          return redirect('https://example.com?gatewayOrderID=' .
//           $paymentTransaction->OrderId ?? null . '&RRN=' .
//           $paymentTransaction->RRN ?? null);
}
```

create call method verifyPayAndConfirm:: write this namespace in your class:

```
use Advancelearn\ManagePaymentAndOrders\Enums\AuditTypes;
```

```
private function verifyPayAndConfirm($receipt, $payment, Request $request): void
{
    $payment->reference_id = $receipt->getReferenceId();
    $payment->transaction = $request->all();
    $payment->driver = $receipt->getDriver();
    $payment->save();
    $order->audits()->attach([AuditTypes::PAID => ['description' => 'Payment was successful']]);
    foreach ($order->items as $item) {
        //this method called fromAnd finally, this
        // method reaches the method that we implemented
        // in the corresponding model of the interface
        $item->PaymentConfirmation($order->address->user_id);
    }
    return $receipt;
}
```

\##Payment status

You can monitor the status of orders that have been prepared by checking each step where the new status should be documented. You can add a record related to the current stage of the order and you can reference the stage IDs from the adm\_audits table.

**You can call this method to get all the information about your orders**

```
$paginateCount = 6;
app('orderFunction')->getOrders($paginateCount);
```

**Use this method to display individual information of an order**

```
app('orderFunction')->show($order);
```

\####Pay attention to the type of parameters ####You can use this method to update an order You can create a new record in the adm\_shippings table for the types of shipping steps and prices that must be calculated for shipping, and send its ID for calculation in the store or update method. Pay attention to this example.

```
$shippingId = app('shipping')::find(1)->pluck('id')->first();
```

```
$items = [
    0 => [
        'quantity' => 1,
        "inventory_id" => 1,
        "price" => 168000//It can be Nal
    ]
];
$shippingId = $request->shippingId; //can be null
$addressId = $request->addressId;
$auditId = app('audit')::find(2)->toArray();
$orderId = 9;
$update = app('orderFunction')->update($shippingId, $addressId, "update order for test", "2023-09-28 10:01:03", $items, $auditId['id'], $orderId);
#params => shippingId , $addressId , $description , $shippingDate , $items , $auditID , $orderId
```

\##Important Remember that the address ID you enter for updating must be related to ***`the user who made the purchase`***, because we reach the user from the address in the codes. ####You can use this method to cancel the order By User

```
$delete =  app('orderFunction')->destroyByUser($orderId);
return $delete;
```

\####You can use this method to cancel the order By Admin

```
$delete =  app('orderFunction')->destroyByAdmin($orderId);
return $delete;
```

You can display the list of orders and payments to the admin and to the user who is logged in with the help of these methods and passing the required parameters.

get Orders List Or SingleOrder
------------------------------

[](#get-orders-list-or-singleorder)

```
return app('orderFunction')->getOrders(); // get Order List for AdminPanel
return app('orderFunction')->singleOrder(5); // get singleOrder for AdminPanel

return app('orderFunction')->ordersOfTheLoggedInUser(); // get user Authenticated Order list
return app('orderFunction')->SingleOrderOfTheLoggedInUser(5); //get user Authenticated singleOrder
```

get Payments List Or SinglePayment
----------------------------------

[](#get-payments-list-or-singlepayment)

```
return app('paymentFunction')->getPayments(); // get PaymentList for AdminPanel

return app('paymentFunction')->singlePayment(1); //get singlePayment for AdminPanel

return app('paymentFunction')->paymentsOfTheLoggedInUser(); //get user Authenticated payment list

return app('paymentFunction')->SinglePaymentsOfTheLoggedInUser(1); //send $paymentId
```

\##keep in mind

"When a user utilizes your User model and you have defined Address relationships for this user, upon creating a new user account in the system, with the assistance of AdmUserObserve in your package, a digital address is generated for the user within the system. In this manner, if the user intends to purchase non-physical products for which shipping costs are irrelevant, we create a digital delivery address in the system for them."

Conclusion
----------

[](#conclusion)

By utilizing this package, there is no need to create separate models for the order and payment processes. Moreover, it allows for the presentation of user information history and the management of these records. For instance, you can perform actions like updating the order status to various types and sections, organizing the order stages (e.g., sending the products, order cancellation, final registration, readiness for shipment), and more—all within a unified framework.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

22

Last Release

958d ago

Major Versions

1.1.9 → 2.0.02023-09-23

### Community

Maintainers

![](https://www.gravatar.com/avatar/f5b879e115994885b2c78de050edd98f1740ac54d5681f72371df3f822657971?d=identicon)[Saberqadimi](/maintainers/Saberqadimi)

---

Top Contributors

[![Saberqadimi](https://avatars.githubusercontent.com/u/83162836?v=4)](https://github.com/Saberqadimi "Saberqadimi (29 commits)")

---

Tags

frameworklaravellaravel-packagepaymentorderadvancelearnlaravel wocomerce

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/advancelearn-manage-payment-and-orders/health.svg)

```
[![Health](https://phpackages.com/badges/advancelearn-manage-payment-and-orders/health.svg)](https://phpackages.com/packages/advancelearn-manage-payment-and-orders)
```

###  Alternatives

[bagisto/bagisto

Bagisto Laravel E-Commerce

26.2k161.6k7](/packages/bagisto-bagisto)[krayin/laravel-crm

Krayin CRM

22.0k32.8k1](/packages/krayin-laravel-crm)[unopim/unopim

UnoPim Laravel PIM

9.4k1.8k](/packages/unopim-unopim)[milwad/laravel-validate

The Laravel-Validate package enhanced Laravel validation capabilities with custom rules and methods for simplified and efficient validation logic.

59739.5k1](/packages/milwad-laravel-validate)[binafy/laravel-user-monitoring

Monitor your user and all activity on your application

57425.7k](/packages/binafy-laravel-user-monitoring)[binafy/laravel-cart

Laravel Cart is a customizable package for adding shopping cart functionality to Laravel applications

40445.9k](/packages/binafy-laravel-cart)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
