1. Go to this page and download the library: Download rgalstyan/larapi library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rgalstyan / larapi example snippets
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."]);