mralston / payment
Payment flows for cash, finance and leasing.
Installs: 50
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 2
Open Issues: 0
pkg:composer/mralston/payment
Requires
- php: ^8.4
- gregoryduckworth/encryptable: ^1.0
- illuminate/broadcasting: *
- illuminate/database: ^11.0|^12.0
- illuminate/routing: *
- illuminate/support: ^11.0|^12.0
- inertiajs/inertia-laravel: ^2.0
- laravel/framework: ^11.0||^12.0
- laravel/sanctum: ^4.0
- mralston/laravel-additional-string-helpers: ^1.0
- mralston/mug: ^1.0
- pusher/pusher-php-server: ^7.2
- spatie/array-to-xml: ^3.4
- spatie/laravel-data: ^4.17
Requires (Dev)
- orchestra/testbench: ^9.0
- pestphp/pest: ^4.1
README
Introduction
Payment flows for cash, finance and leasing.
Installation
composer require mralston/payment
Configuration
Add the following to your .env file
# Configure the parent model for payment records PAYMENT_PARENT_MODEL=\App\Models\Quote # Optionally configure an Inertia route view from your application PAYMENT_INERTIA_ROOT_VIEW=/layouts/inertia # Helper class PAYMENT_HELPER=\App\Services\PaymentHelper
Parent Model
Payment records are linked to a parent model in your application; a quotation or contract for example. The parent model must implement the PaymentParentModel interface which includes a several relationships. The easiest way to implement the relationship methods is using the HasPayments trait. The parent model is declared in the PAYMENT_PARENT_MODEL configuration variable.
<?php namespace App; use Illuminate\Database\Eloquent\Model; use Mralston\Payment\Interfaces\PaymentParentModel; use Mralston\Payment\Models\PaymentSurvey; use Mralston\Payment\Traits\HasPayments; class Quote extends Model implements PaymentParentModel { use HasPayments; public function paymentSurvey(): MorphOne { return $this->morphOne(PaymentSurvey::class, 'parentable'); } }
Helper
The Payment package relies on a helper class which your application must provide. The helper class implements the PaymentHelper interface and allows the Payment package to understand its parent application. The helper class is declared in the PAYMENT_HELPER configuration variable.
<?php namespace App\Services; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Collection; use Mralston\Payment\Data\CustomerData; class PaymentHelper { protected $parentModel; public function setParentModel(Model $parentModel) { $this->parentModel = $parentModel; } public function getCustomers(): Collection { // TODO: Return a collection of CustomerData objects } }
Security Vulnerabilities
Please e-mail security vulnerabilities directly to me.
Licence
PDF is open-sourced software licenced under the MIT license.