| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace Webkul\BagistoApi\Models;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- use Webkul\BagistoApi\Contracts\PaymentAttempt as PaymentAttemptContract;
- use Webkul\Sales\Models\OrderProxy;
- /**
- * Audit trail for the full payment lifecycle (initiate / replay / callback).
- *
- * This is intentionally separate from `order_transactions`, which only
- * records the final settled (invoiced) transaction. A payment attempt is
- * an intent that may fail, be replayed multiple times, or be cancelled.
- */
- class PaymentAttempt extends Model implements PaymentAttemptContract
- {
- protected $table = 'payment_attempts';
- /**
- * Lifecycle stage of the attempt.
- */
- public const ACTION_INITIATE = 'initiate';
- public const ACTION_REPLAY = 'replay';
- public const ACTION_CALLBACK = 'callback';
- public const ACTION_WEBHOOK = 'webhook';
- /**
- * Status of the attempt.
- */
- public const STATUS_CREATED = 'created';
- public const STATUS_REDIRECTED = 'redirected';
- public const STATUS_CAPTURED = 'captured';
- public const STATUS_CANCELLED = 'cancelled';
- public const STATUS_FAILED = 'failed';
- /**
- * The attributes that are mass assignable.
- *
- * @var array
- */
- protected $fillable = [
- 'order_id',
- 'cart_id',
- 'payment_method',
- 'gateway_order_id',
- 'action',
- 'status',
- 'amount',
- 'currency',
- 'express',
- 'request_payload',
- 'response_payload',
- 'idempotency_key',
- ];
- /**
- * The attributes that should be cast.
- *
- * @var array
- */
- protected $casts = [
- 'express' => 'boolean',
- 'request_payload' => 'array',
- 'response_payload' => 'array',
- 'amount' => 'float',
- ];
- /**
- * Get the order associated with this payment attempt.
- */
- public function order(): BelongsTo
- {
- return $this->belongsTo(OrderProxy::modelClass(), 'order_id');
- }
- }
|