ComgateGateway
extends AbstractPaymentGateway
in package
Table of Contents
Constants
- API_URL : mixed = 'https://payments.comgate.cz/v2.0/'
Properties
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.
- createClient() : Client|null
- isProduction() : bool
- mapStatus() : int
- resolveCurrencyCode() : string
- returnMessageForStatus() : string
Constants
API_URL
private
mixed
API_URL
= 'https://payments.comgate.cz/v2.0/'
Properties
$currencyManager read-only
private
CurrencyManager
$currencyManager
$paymentManager read-only
private
PaymentManager
$paymentManager
Methods
__construct()
public
__construct(PaymentManager $paymentManager, CurrencyManager $currencyManager) : mixed
Parameters
- $paymentManager : PaymentManager
- $currencyManager : CurrencyManager
allowRedirect()
public
allowRedirect() : bool
Return values
boolcheckDelivery()
public
checkDelivery(Payment $payment, PaymentGate $paymentGate, array<string, mixed> $params) : GatewayCheckResult
Parameters
- $payment : Payment
- $paymentGate : PaymentGate
- $params : array<string, mixed>
Return values
GatewayCheckResultcheckPayment()
public
checkPayment(Payment $payment, PaymentGate $paymentGate, array<string, mixed> $params) : GatewayCheckResult
Parameters
- $payment : Payment
- $paymentGate : PaymentGate
- $params : array<string, mixed>
Return values
GatewayCheckResultcreatePayment()
public
createPayment(Payment $payment, PaymentGate $paymentGate, array<string|int, mixed> $urls) : GatewayCreateResult
Parameters
- $payment : Payment
- $paymentGate : PaymentGate
- $urls : array<string|int, mixed>
Return values
GatewayCreateResultgetScriptName()
public
getScriptName() : string
Return values
stringloadPayment()
public
loadPayment(PaymentGate $paymentGate, array<string, mixed> $params) : Payment|null
Parameters
- $paymentGate : PaymentGate
- $params : array<string, mixed>
Return values
Payment|nullloadPaymentFromDelivery()
public
loadPaymentFromDelivery(PaymentGate $paymentGate, array<string, mixed> $params) : Payment|null
Parameters
- $paymentGate : PaymentGate
- $params : array<string, mixed>
Return values
Payment|nullsendDeliveryResponse()
public
sendDeliveryResponse() : void
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|nullamountFromUnits()
protected
amountFromUnits(mixed $value) : float|null
Parameters
- $value : mixed
Return values
float|nullcreateFailure()
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
GatewayCreateResultgetSetting()
protected
getSetting(PaymentGate $paymentGate, string $key[, mixed $default = null ]) : mixed
Parameters
- $paymentGate : PaymentGate
- $key : string
- $default : mixed = null
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
stringsettingString()
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
stringcreateClient()
private
createClient(PaymentGate $paymentGate) : Client|null
Parameters
- $paymentGate : PaymentGate
Return values
Client|nullisProduction()
private
isProduction(PaymentGate $paymentGate) : bool
Parameters
- $paymentGate : PaymentGate
Return values
boolmapStatus()
private
mapStatus(string $comgateState) : int
Parameters
- $comgateState : string
Return values
intresolveCurrencyCode()
private
resolveCurrencyCode(Payment $payment) : string
Parameters
- $payment : Payment
Return values
stringreturnMessageForStatus()
private
returnMessageForStatus(int $status) : string
Parameters
- $status : int