Cash Driver Provider
Installation
To get the latest version of Cash Driver Provider
, simply require the project using Composer:
$ composer require cashier-provider/cash
Or manually update require
block of composer.json
and run composer update
.
{
"require": {
"cashier-provider/cash": "^1.0"
}
}
Using
Note:
This project is the driver for
Cashier Provider
.
Configuration
Add your driver information to the config/cashier.php
file:
use App\Models\Payment;
use App\Payments\Cash as CashDetails;
use CashierProvider\Cash\Driver as CashDriver;
use CashierProvider\Core\Constants\Driver;
return [
'payment' => [
'map' => [
Payment::TYPE_CASH => 'cash'
]
],
'drivers' => [
'cash' => [
Driver::DRIVER => CashDriver::class,
Driver::DETAILS => CashDetails::class,
]
]
];
Resource
Create a model resource class inheriting from CashierProvider\Core\Resources\Model
in your application.
Use the $this->model
link to refer to the payment model. When executed, the $model
parameter will contain the payment instance.
namespace App\Payments;
use CashierProvider\Core\Resources\Model;
class Cash extends Model
{
protected function paymentId(): string
{
return (string) $this->model->id;
}
protected function sum(): float
{
return (float) $this->model->sum;
}
protected function currency(): int
{
return $this->model->currency;
}
protected function createdAt(): Carbon
{
return $this->model->created_at;
}
}
Available Methods And Details Data
$payment->cashier->external_id
// Returns transaction ID for this operation
$payment->cashier->details->getStatus(): ?string
// Returns the text status from the bank
// For example, `PAID`.
$payment->cashier->details->toArray(): array
// Returns an array of status.
// For example,
//
// [
// 'status' => 'PAID'
// ]