PgClient events¶
PgClient
communicates with the application using events.
Typical transaction flow looks like this:
- Charge/Authorize/Refund method is called
TransactionStarted
event is raisedProgressInfo
event is raised multiple times- [optional]
SignatureRequested
event is raised for some transactions - [optional]
BeepRequested
event is raised for some transactions - [optional] more
ProgressInfo
events - depending on outcome, one of the following events is raised:
TransactionFinished
: transaction was successfully processed to the end and it was either approved or declined. data provided with the event to notify customer or store in your local system.Error
: an error occurred and the transaction was not processed.TransactionCanceled
: your application has canceled the transaction.
Event reference¶
Most of the events carry with them useful additional information.
TransactionStarted event¶
Raised when the transaction starts.
It carries the information about payment request.
Arguments:
object sender
: object which raised the eventTransactionStartedEventArgs args
: transaction details.TransactionRequest
property with payment request information:Amount
: the amount to be charged from the credit card holderCurrency
: ISO 4217 code of currency of the amount (e.g. “EUR”)InstallmentCount
: number of installmentsExternalId
: external identifier, used by 3rd party apps to identify the transactions in their own systemCallbackUrl
: callback URL to be called by the gateway after payment transaction endsId
: the id of the transaction
TransactionFinished event¶
Raised after the transaction is processed.
It carries the information about outcome (approved/declined) and other transaction details.
Arguments:
object sender
: object which raised the eventTransactionFinishedEventArgs args
: transaction details.TransactionInfo
propertyTransactionId
: internal transaction identifierExternalId
: external identifier specified by end user, which can be used to map the transaction to end user’s systemsAuthorizationCode
: transaction authorisation codeCreatedAt
: transaction creation timeAmount
: transaction amountCurrency
: transaction currency codeMid
: merchant identifierTid
: terminal identifierReceiptUrl
: returns the URL which can be used to access online receiptRrn
: returns the transaction reference number (RRN)EntryMode
: card entry mode. Can be one of:Unknown
,Manual
,Chip
,Magstripe
,Contactless
,ContactlessMagstripe
Status
: transaction status. Can be one of:Processing
,Approved
,Declined
,Refunded
,Voided
,Unknown
CardInfo
: card details with following data:MaskedPan
: PAN with masked dataPanSequenceNumber
: PAN sequence numberExpiryDate
: Card expiry dateBrand
: Card brand, e.g.Visa
,MasterCard
…
Error event¶
Raised if an error has happened, which prevented the transaction to be carried out.
Arguments:
object sender
: object which raised the eventTransactionErrorEventArgs args
: error details.Scope
: returns the error category. One of ErrorScope enum values:CommunicationError
: there was a problem communicating with card reader or payment gateway.TransactionError
: Transaction was processed but it failed due to some other reason.
Code
: returns the error code. One of ErrorCode enum values:CardReaderFailedToConnect
: could not connect to card readerCardReaderDisconnected
: connection to reader was lostPaymentGatewayError
: error in communication with payment gatewayTransactionVoid
: transaction was voidedTransactionCancelled
: transaction was cancelledSignatureError
: transaction declined because signature was not givenTransactionDeclined
: transaction declined due to invalid cardTransactionDeclinedKeepCard
: transaction declined and card should be captured.InvalidCard
: transaction declined due to invalid cardGenericError
: Unspecified error happened
Description
: additional information about the error
ProgressInfo event¶
Raised to provide notifications of transaction progress (insert card, enter PIN, etc)
Arguments:
object sender
: object which raised the eventProgressInfoEventArgs args
: progress event details.Message
: contains the description of the eventEvent
: returns the event identifier, which is a ProgressInfoEvent enum value:TransactionStarted
: transaction was startedUnspecified
: unspecified progress eventReaderConfigCheck
: reader config was verifiedReaderUpdating
: reader update startedReaderConnecting
: reader is connectingReaderRestarting
: reader initiated restartPresentCard
: waiting for card to be presentedRemoveCard
: waiting for card removalCardDataRead
: card info read by gatewayWaitingForPinEntry
: waiting for PIN entryPinEntryCompleted
: PIN was enteredProcessing
: transaction is being processedSeeDevice
: important information is displayed on deviceTransactionFinished
: transaction was finished
TransactionCanceled event¶
Raised when you cancel the transaction by calling PgClient.Cancel
method,
to mark the end of the transaction. If the transaction is canceled,
TransactionFinished
event WILL NOT be raised.
Arguments:
object sender
: object which raised the eventEventArgs args
: an empty EventArgs instance.
SignatureRequested event¶
Raised when customer must authorize the transaction with the signature.
Arguments:
object sender
: object which raised the eventSignatureRequestedEventArgs args
: doesn’t contain any properties, but allows caller code to set signature or cancel signature collection with following methods.SetSignature(byte[] data)
: Sets the signature which will be sent to gateway.CancelSignature()
: Cancels the signature request. Transaction will be canceled.
BeepRequested event¶
Raised when sound confirmation is required for contactless transactions.
object sender
: object which raised the eventBeepRequestedEventArgs args
:Success
: specifies whether the beep should notify success or failure.