SnappPay Facade API Reference
The Eamirgh\SnappPay\Facades\SnappPay facade provides convenient access to all service methods.
getEligibility
public static function getEligibility(int $amount, array $paymentMethodTypes = []): EligibilityResultQueries merchant and cart installment eligibility.
- Parameters:
$amount(int): Cart amount in IRR.$paymentMethodTypes(array): Optional array ofPaymentMethodTypeor strings ('POSTPAID','INSTALLMENT','FINANCING').
- Returns:
EligibilityResult(isEligible(),$titleMessage,$description).
getPaymentToken
public static function getPaymentToken(PaymentTokenRequest $request): PaymentTokenResultRequests a payment token and redirect URL using a complete itemized cart.
- Parameters:
PaymentTokenRequest $request. - Returns:
PaymentTokenResult($paymentToken,$paymentPageUrl,$transactionId).
requestPaymentFor
public static function requestPaymentFor(SnappPayable $payable, ?array $forcedPaymentMethodTypes = null): PaymentTokenResultRequests a payment token directly for an application domain model (e.g. Order, Invoice) implementing the SnappPayable interface contract.
- Parameters:
$payable(SnappPayable): The domain model instance.$forcedPaymentMethodTypes(?array): Optional payment method restrictions.
- Returns:
PaymentTokenResult.
quickToken
public static function quickToken(
int $amount,
string $mobile,
string $returnURL,
string $transactionId,
array $items = [],
int $discountAmount = 0,
int $externalSourceAmount = 0,
?array $forcedPaymentMethodTypes = null
): PaymentTokenResultShortcut method to initiate a payment token for simple baskets without constructing full Cart models manually.
verify
public static function verify(string $paymentToken): TransactionResultVerifies a payment once after receiving a successful callback (state = 'OK').
settle
public static function settle(string $paymentToken): TransactionResultSettles an order after successful verification to finalize the transaction and capture funds.
verifyWithResilience
public static function verifyWithResilience(string $paymentToken, ?int $maxRetries = null): TransactionResultExecutes the Section 11 Verify Management workflow: handles 30s timeouts by falling back to status inquiry and auto-retrying if status is PENDING.
settleWithResilience
public static function settleWithResilience(string $paymentToken, ?int $maxRetries = null): TransactionResultExecutes the Section 12 Settle Management workflow: checks payment status on network timeout or false response to ensure idempotent settlement.
verifyAndSettle
public static function verifyAndSettle(string $paymentToken): TransactionResultExecutes verifyWithResilience() followed by settleWithResilience(). The recommended standard for callback handlers.
revert
public static function revert(string $paymentToken): TransactionResultReverts an order before settlement if merchant fulfillment fails.
cancel
public static function cancel(string $paymentToken): TransactionResultPermanently cancels an order in SETTLE status.
update
public static function update(UpdateOrderRequest $request): TransactionResultUpdates cart items or order total for settled orders (new total must be strictly less than original).
getStatus
public static function getStatus(string $paymentToken): StatusResultInspects current payment lifecycle status (SETTLE, VERIFY, PENDING, CANCEL, REVERT).
parseCallback
public static function parseCallback(Request|array $request): CallbackPayloadExtracts and validates inbound POST callback parameters (transactionId, state, amount).
connection
public static function connection(?string $name = null): SnappPayServiceSwitches to a named connection configured in config/snapppay.php.
build
public static function build(array $customConfig): SnappPayServiceInstantiates an isolated SnappPay service with custom credentials at runtime.