CoolCMS API

CreditGateway extends AbstractPaymentGateway
in package

FinalYes

Table of Contents

Properties

$user  : User
$userManager  : UserManager

Methods

__construct()  : mixed
allowRedirect()  : bool
checkDelivery()  : GatewayCheckResult
checkPayment()  : GatewayCheckResult
createPayment()  : GatewayCreateResult
getScriptName()  : string
loadPayment()  : Payment|null
loadPaymentFromDelivery()  : Payment|null
sendDeliveryResponse()  : void
amountFromMinorUnits()  : float|null
Converts an amount in minor units (cents) to currency units. `null` when the gateway reports none.
amountFromUnits()  : float|null
createFailure()  : GatewayCreateResult
Handles a gateway client failure while creating a transaction: the redacted detail goes only to the server log, the result carries a stable code. A logging error never breaks the payment flow.
getSetting()  : mixed
pickGatewayPaymentId()  : string
Picks the transaction id to verify at the gateway.
settingString()  : string
Typed variant of {@see getSetting()}; settings are always plain strings, this only saves `(string)` casts over `mixed` at call sites.
paid()  : GatewayCheckResult

Properties

Methods

getScriptName()

public getScriptName() : string
Return values
string

amountFromMinorUnits()

Converts an amount in minor units (cents) to currency units. `null` when the gateway reports none.

protected amountFromMinorUnits(mixed $value) : float|null
Parameters
$value : mixed
Return values
float|null

amountFromUnits()

protected amountFromUnits(mixed $value) : float|null
Parameters
$value : mixed
Return values
float|null

createFailure()

Handles a gateway client failure while creating a transaction: the redacted detail goes only to the server log, the result carries a stable code. A logging error never breaks the payment flow.

protected createFailure(string $provider, Throwable $e[, int|null $paymentId = null ]) : GatewayCreateResult
Parameters
$provider : string
$e : Throwable
$paymentId : int|null = null
Return values
GatewayCreateResult

pickGatewayPaymentId()

Picks the transaction id to verify at the gateway.

protected pickGatewayPaymentId(Payment $payment, mixed ...$candidates) : string

The id is stored in the DB only by the central guard in PaymentProcessorTrait, and only after the gateway confirms the transaction; this method just says which id to ask about.

IMPORTANT: the id from the request wins over the stored one, because the gateway reports exactly that transaction. One payment can have several transactions at the gateway (a retried payment overwrites the stored id while the first stays open and payable). Ignoring the request id would drop the paid notification as a conflict: the money arrives and the order stays unpaid.

Security is kept: when the id differs from the stored one, the central guard (PaymentProcessorTrait::processPayment()) lets the notification through only with a proven referenceId equal to our payment_id, so a foreign transaction planted by an attacker is rejected, after querying the gateway.

Parameters
$payment : Payment
$candidates : mixed

request values in priority order (the first non-empty one wins)

Return values
string

settingString()

Typed variant of {@see getSetting()}; settings are always plain strings, this only saves `(string)` casts over `mixed` at call sites.

protected settingString(PaymentGate $paymentGate, string $key[, string $default = '' ]) : string
Parameters
$paymentGate : PaymentGate
$key : string
$default : string = ''
Return values
string
On this page

Search results