PHPackages                             rgalstyan/larapi - 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. [Payment Processing](/categories/payments)
4. /
5. rgalstyan/larapi

ActiveLibrary[Payment Processing](/categories/payments)

rgalstyan/larapi
================

Laravel package for Pi Network payment system

1.0.0(1y ago)216[1 issues](https://github.com/rgalstyan/larapi/issues)MITPHPPHP &gt;=8.1CI failing

Since Mar 9Pushed 1y ago2 watchersCompare

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

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

 [ ![Total Downloads](https://camo.githubusercontent.com/538420c556b53ae8a31f5f31bc050fd7922bd3aa13f4dcb9631a79feebf9400f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7267616c737479616e2f6c6172617069) ](https://packagist.org/packages/rgalstyan/larapi) [ ![Latest Stable Version](https://camo.githubusercontent.com/fddbc49f6cdf67486f0f9c54647eb7cbe457dfcd0f47d3c19feafbe29a384aaf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7267616c737479616e2f6c6172617069) ](https://packagist.org/packages/rgalstyan/larapi) [ ![License](https://camo.githubusercontent.com/b69173f272b6d301f91f301e0bcbdd2783dbfb6f5de5f4f76a92599d3cc99c79/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7267616c737479616e2f6c6172617069) ](https://packagist.org/packages/rgalstyan/larapi)

 [ ![Test on PI Sandbox](https://camo.githubusercontent.com/48fd876b3f3166c03f130b626ee7be27096f046ea09c44868b6084b04883ffa3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f546573742532306f6e2d504925323053616e64626f782d3631324637343f7374796c653d666f722d7468652d6261646765266c6f676f436f6c6f723d7768697465) ](https://sandbox.minepi.com/mobile-app-ui/app/laravel-package-b9e1b05510f937f1)

Package Installation
====================

[](#package-installation)

Requirements
------------

[](#requirements)

- **PHP 8.1+**
- **Laravel 10+**
- **Composer**

---

Step 1: Install via Composer
----------------------------

[](#step-1-install-via-composer)

Run the following command to install the package:

```
composer require rgalstyan/larapi
```

---

**Step 2: Publish the Configuration (Optional)**
------------------------------------------------

[](#step-2-publish-the-configuration-optional)

If you need to modify the default settings, publish the config file:

```
php artisan vendor:publish --tag=larapi-config
php artisan vendor:publish --tag=larapi-migrations
```

---

Step 3: Environment Configuration
---------------------------------

[](#step-3-environment-configuration)

Add the required environment variables to your `.env` file:

```
PI_API_KEY=your_api_key
PI_API_URL=https://api.minepi.com
PI_API_VERSION=v2
```

---

Step 4: Run Migrations
----------------------

[](#step-4-run-migrations)

If you have exported the **larapi-migrations** configurations, run:

```
php artisan migrate
```

---

Using Package Functions
=======================

[](#using-package-functions)

Overview
--------

[](#overview)

This package integrates the Pi Network API into Laravel and provides two main services:

- **LaraPiDbService**: Manages all database operations for Pi payments using `PaymentDTO` objects, including creating, updating, deleting, and retrieving payment records along with their associated statuses and transactions.
- **LaraPiPaymentService**: Handles communication with the Pi Network API. It provides methods to create, approve, complete, cancel payments, and retrieve payment details.

---

**LaraPiDbService**
-------------------

[](#larapidbservice)

The **LaraPiDbService** is responsible for managing the payment data stored in your local database. Below are the key methods:

- **createPayment(PaymentDTO $dto): PiPayment** – Creates a new payment record. This method checks for duplicate payment identifiers, creates associated payment status and transaction records, and returns the created payment. In case of errors, the transaction is rolled back and the error is logged.
- **updatePayment(int $paymentId, PaymentDTO $dto): PiPayment** – Updates an existing payment record along with its related status or transaction data.
- **deletePayment(int $paymentId): bool** – Deletes a payment record by its ID.
- **getPaymentById(int $paymentId): ?PiPayment** – Retrieves a payment record by its ID.
- **getPaymentsByUserId(int $userId): ?object** – Retrieves all payment records for a specific user based on the user ID.
- **getPaymentsByUserUid(string $piUserUid): ?object** – Retrieves all payments associated with a specific Pi user UID.

---

**LaraPiPaymentService**
------------------------

[](#larapipaymentservice)

The **LaraPiPaymentService** is used to interact directly with the Pi Network API. Its main methods include:

- **createPayment(float $amount, string $uid, string $memo = 'A2U Payment', array $metadata = \[\]): PaymentDTO|null** – Sends a payment creation request to the API. On success, it returns a `PaymentDTO` containing the payment details.
- **getPayment(string $paymentId): PaymentDTO|null** – Retrieves payment details from the API for the given payment ID.
- **approvePayment(string $paymentId): PaymentDTO|null** – Approves a pending payment by sending the appropriate request to the API.
- **completePayment(string $paymentId, string $txid): PaymentDTO|null** – Completes a payment by providing the transaction ID (`txid`) to the API.
- **cancelPayment(string $paymentId): PaymentDTO|null** – Cancels a pending payment through an API call.
- **incompleteServerPayments(): object|null** – Retrieves server-side payments that have not yet been completed, allowing further processing or error handling.

---

Example Usage
-------------

[](#example-usage)

The following examples demonstrate how you can use these services within your Laravel application:

```
use Rgalstyan\Larapi\Facades\LaraPiPayment;
use Rgalstyan\Larapi\Facades\LaraPiDb;
```

### Example 1: Creating a Payment

[](#example-1-creating-a-payment)

```
// Create a payment via the Pi Network API
$paymentDTO = LaraPiPayment::createPayment(10.50, 'user-unique-id', 'Payment for Order #1234', ['order_id' => 1234]);

if ($paymentDTO) {
    // Store the payment information in your database using PaymentDTO
    $payment = LaraPiDb::createPayment($paymentDTO);
    return response()->json(['success' => true, 'message' => "Payment created successfully with ID: " . $payment->id]);
} else {
    return response()->json(['success' => true, 'message' => "Payment creation failed."]);
}
```

### Example 2: Updating a Payment

[](#example-2-updating-a-payment)

```
// Assume $paymentDTO contains updated payment details and $paymentId holds the existing payment ID
$paymentId = 123; // Example payment ID
$updatedPayment = LaraPiDb::updatePayment($paymentId, $paymentDTO);
return response()->json(['success' => true, 'message' => "Payment updated successfully."]);
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity46

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

Unknown

Total

1

Last Release

435d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

laravelpaymentpi network

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rgalstyan-larapi/health.svg)

```
[![Health](https://phpackages.com/badges/rgalstyan-larapi/health.svg)](https://phpackages.com/packages/rgalstyan-larapi)
```

###  Alternatives

[laravel/boost

Laravel Boost accelerates AI-assisted development by providing the essential context and structure that AI needs to generate high-quality, Laravel-specific code.

3.4k10.6M274](/packages/laravel-boost)[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[laravel-zero/framework

The Laravel Zero Framework.

3371.4M369](/packages/laravel-zero-framework)[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4845.9k](/packages/sebdesign-laravel-viva-payments)[021/laravel-wallet

Reliable and flexible wallet system for Laravel

2785.2k](/packages/021-laravel-wallet)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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