1. Go to this page and download the library: Download damms005/laravel-cashier 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/ */
damms005 / laravel-cashier example snippets
use Damms005\LaravelMultipay\Services\SubscriptionService;
use Damms005\LaravelMultipay\Contracts\PaymentHandlerInterface;
$handler = app(PaymentHandlerInterface::class);
$plan = SubscriptionService::createPaymentPlan(
handler: $handler,
name: 'Pro Monthly',
amount: '5000', // in minor currency unit (e.g., kobo, cents)
interval: 'monthly', // 'monthly', 'quarterly', 'biannually', or 'yearly'
description: 'Pro plan - billed monthly',
currency: 'NGN'
);
use Damms005\LaravelMultipay\Services\SubscriptionService;
$subscription = SubscriptionService::getActiveSubscriptionFor($user, $plan);
if ($subscription) {
// User has an active subscription
// $subscription->next_payment_due_date
}
use Damms005\LaravelMultipay\Services\SubscriptionService;
// inside your subscription.create webhook handling
SubscriptionService::recordProviderSubscriptionData(
$subscription,
subscriptionCode: $request->input('data.subscription_code'),
emailToken: $request->input('data.email_token'),
);
try {
$status = $terminal->waitForTerminalHardware();
// Terminal is online
} catch (\Exception $e) {
// Terminal is offline or not configured
}
try {
$eventId = $terminal->pushToTerminal($payment);
// Payment has been pushed to terminal
} catch (\Exception $e) {
// Failed to push to terminal
}
try {
$result = $terminal->terminalReceivedPaymentRequest($eventId);
// Terminal has received the payment request
} catch (\Exception $e) {
// Could not verify receipt
}
use Damms005\LaravelMultipay\Models\Payment;
use Damms005\LaravelMultipay\Contracts\WebhookPayloadPackager;
class MyWebhookPayloadPackager implements WebhookPayloadPackager
{
public function getWebhookPayload(Payment $payment): array
{
return [
'transaction_reference' => $payment->transaction_reference,
'amount_paid' => $payment->original_amount_displayed_to_user,
'payment_processor_name' => $payment->payment_processor_name,
// ...add any app-specific data you need
];
}
}