TransactionDelegate

@objc(DTTransactionDelegate)
public protocol TransactionDelegate

Implement TransactionDelegate to be notified when a transaction ends. TransactionDelegate will notify you about the success, error or cancel state of the processed transaction.

  • This is called after a transaction has been successfully completed. This callback provides details about the transaction.

    Declaration

    Swift

    func transactionDidFinish(_ transaction: Transaction, result: TransactionSuccess)

    Parameters

    transaction

    The object containing the information of the completed transaction.

    result

    The object including the information related to the transaction success.

  • This is called after a transaction fails or encounters an error. Keep in mind that the SDK shows the error to the user before this is invoked. Therefore, this callback can be used to cancel any on-going process involving the transaction.

    You may also use the error details provided here and display it the way you want when suppressing the error message within the TransactionOptions.

    Declaration

    Swift

    func transactionDidFail(_ transaction: Transaction, error: TransactionError)

    Parameters

    transaction

    The object containing the information of the failed transaction.

    error

    The error that occurred.

  • This is called after a transaction has been cancelled. This callback can be used to cancel any on-going process involving the transaction.

    Some payment methods - such as Twint that involves an app-switch - also call this method when a payment error or decline occurs, to prevent showing an error dialog twice, as an error is already displayed in the payment application.

    Declaration

    Swift

    @objc
    optional func transactionDidCancel(_ transaction: Transaction)

    Parameters

    transaction

    The object containing the information of the cancelled transaction.