Easily integrate Pi Network features into your Laravel projects. Fast, reliable, and convenient.
View on GitHubEasily integrate with Laravel using a simple and intuitive setup.
Implement a full-featured payment system with Pi Network in your Laravel project.
Preconfigured for seamless integration, with key options adjustable.
Requirements:
Run the following command to install the package:
composer require rgalstyan/larapi
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
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
If you have exported the larapi-migrations configurations, run:
php artisan migrate
This package integrates the Pi Network API into Laravel and provides two main services:
The LaraPiDbService is responsible for managing the payment data stored in your local database. Below are the key methods:
The LaraPiPaymentService is used to interact directly with the Pi Network API. Its main methods include:
The following examples demonstrate how you can use these services within your Laravel application:
use Rgalstyan\Larapi\Facades\LaraPiPayment;
use Rgalstyan\Larapi\Facades\LaraPiDb;
// 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."]); }
// 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."]);
Use this page to test the package's integration. For proper Pi authorization, please open this page in the Pi Browser as it is the only browser that supports Pi authorization.
If you enjoy using this package, consider donating 1 Pi to the author as a token of your appreciation.
Or you can test it on Pi Sandbox
If you like this package, you can support it by donating via Pi Network or other methods.