1. Go to this page and download the library: Download bayarcash/laravel 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/ */
bayarcash / laravel example snippets
use Bayarcash\Laravel\Concerns\HasBayarcashPayments;
use Illuminate\Database\Eloquent\Model;
class Order extends Model
{
use HasBayarcashPayments;
}
use Bayarcash\Bayarcash;
$intent = $order->charge([
'portal_key' => 'your_portal_key',
'payment_channel' => Bayarcash::FPX,
'order_number' => $order->reference, // optional; auto-generated when omitted
'amount' => '10.00',
'payer_name' => $order->customer_name,
'payer_email' => $order->customer_email,
'payer_telephone_number' => $order->customer_phone,
]);
// Redirect the customer to the hosted checkout.
return redirect()->away($intent->url);
use Bayarcash\Laravel\Events\PaymentSucceeded;
use Illuminate\Support\Facades\Event;
Event::listen(PaymentSucceeded::class, function (PaymentSucceeded $event) {
$event->transaction->owner->markPaid();
});
use Bayarcash\Laravel\Facades\Bayarcash;
$portals = Bayarcash::portals(); // Collection of PortalResource, every page
$portals = Bayarcash::portals($tenantId); // with a tenant's credentials
Bayarcash::hasPortal('your_portal_key'); // bool, stops at the page that has it
Bayarcash::hasPortal('your_portal_key', $tenantId);