Files
core/src/Payment/Models/PaymentMethod.php
T

50 lines
2.2 KiB
PHP
Raw Normal View History

<?php
namespace Modules\Core\Payment\Models;
use Illuminate\Database\Eloquent\Casts\AsArrayObject;
use Illuminate\Database\Eloquent\Model;
/**
* 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
{
protected $guarded = [];
protected $casts = [
'enabled' => 'boolean',
'position' => 'integer',
'driver_missing_at' => 'datetime',
'data' => AsArrayObject::class,
];
}