Feature: Moving Payment Methods to DB, adding fees, Transaction Updates, Refund Updates, General Updates to Payments
This commit is contained in:
@@ -6,17 +6,35 @@ use Illuminate\Database\Eloquent\Casts\AsArrayObject;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Admin-editable settings for one payment type key (matching a key in
|
||||
* config('lunar.payments.types')) — enabled/disabled, and whatever type-
|
||||
* specific data it needs (starts with 'fee' for cash-on-delivery's flat
|
||||
* surcharge). Mirrors Lunar's own Discount model: a single jsonb 'data'
|
||||
* column holding keyed settings, rather than a fixed column per setting or
|
||||
* a separate conditions table — new settings are a code change (a new key
|
||||
* read from data), not a migration.
|
||||
*
|
||||
* Seeded once per type by InstallLunarCommand (skip-if-exists, same
|
||||
* idempotent convention as seedStorefrontLabels()) — never auto-created on
|
||||
* read, so a read path stays a pure read.
|
||||
* A merchant-configured payment method — the DB-instance layer, admin
|
||||
* creatable/deletable, same split Modules\Core\Shipping's own
|
||||
* shipping_methods table already has (see docs/payments.md):
|
||||
* - type: unique, machine-facing slug (Cart::meta['payment_method'],
|
||||
* ApplyCashOnDeliveryFee's lookup key, every Payment event's $type).
|
||||
* - name: admin-facing label.
|
||||
* - driver: the Modules\Core\Payment\Services\PaymentDriverRegistry key
|
||||
* — NOT the same as `type`, and not unique (two rows can share one
|
||||
* driver, e.g. two differently-named offline-style methods).
|
||||
* - capture_mode: 'pay' or 'authorize' — which SupportsPay/
|
||||
* SupportsAuthorization method CheckoutService::initiatePayment()
|
||||
* calls for this row.
|
||||
* - captured_status / authorized_status / refunded_status: the
|
||||
* Order::status value Modules\Core\Order\Listeners\
|
||||
* ApplyResolvedPaymentStatus applies on a PaymentCaptured/
|
||||
* PaymentAuthorized/PaymentRefunded event. For a refund, this is
|
||||
* always the ORIGINAL payment method's row (the one the customer
|
||||
* actually paid with), never the driver the refund itself was routed
|
||||
* through (Payment\Support\TransactionDriverAdapter::refundVia() may
|
||||
* use a different one entirely — e.g. a cash-on-delivery order
|
||||
* refunded via a Bank Transfer driver with no PaymentMethod row of
|
||||
* its own) — see that listener's own docblock.
|
||||
* - position: admin-controlled display/checkout order.
|
||||
* - driver_missing_at: set by `payment:sync-drivers` when `driver` no
|
||||
* longer resolves via the registry — separate from `enabled`, so a
|
||||
* driver vanishing (a deploy removed it) is never confused with an
|
||||
* admin's own manual toggle.
|
||||
* - data: jsonb, driver-specific settings that don't warrant their own
|
||||
* column (starts with 'fee', the offline flat surcharge).
|
||||
*/
|
||||
class PaymentMethod extends Model
|
||||
{
|
||||
@@ -24,6 +42,8 @@ class PaymentMethod extends Model
|
||||
|
||||
protected $casts = [
|
||||
'enabled' => 'boolean',
|
||||
'position' => 'integer',
|
||||
'driver_missing_at' => 'datetime',
|
||||
'data' => AsArrayObject::class,
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user