Ir para o conteúdo

Registrar Notificações

Função tem como objetivo registrar um app de terceiros para ouvir eventos de pagamento do app-phatpay

Registrar Notificações de Eventos

registerNotify()

Warning

Funcionalidade disponível desde App PhastPay v1.1.0.0 e PhastPay-SDK v1.0.1.0

Utiliza-se a função registerNotify para registrar a intenção de ouvir eventos que ocorrem no app-phastpay.

Request

O único parâmetro de entrada é o callback.

Parâmetros

Nome Tipo Obrigatório Descrição
callback IRegisterNotifyCallback Sim Interface que será executada quando notificações de sucesso, erro ou eventos no app-phastpay.

Detalhamento dos Parâmetros

callback (IRegisterNotifyCallback)

Nome Tipo Obrigatório Descrição
onSuccess String Sim Método chamado em caso de sucesso. A resposta será uma String.
onError String Sim Método chamado em caso de erro. A resposta será uma String.
onNotifyPaymentCreate String Sim Método chamado quando um pagamento é criado no app-phastpay.
onNotifyPaymentUpdate String Sim Método chamado quando um pagamento é atualizado no app-phastpay.
onNotifyPaymentConfirmed String Sim Método chamado quando um pagamento é confirmado no app-phastpay.
onNotifyPing String Sim Método chamado para testar o canal de comunicação no app-phastpay em Settings.

Response

string em formado json com informações do pagamento, as informações podem variar de acordo com o evento.



fun registerNotificationListener() {
        registerNotifyService.execute(
            phastPayClient,
            object : PhastPayClient.IRegisterNotifyCallback {
                override fun onSuccess(response: String?) {
                    Log.d(ConstantsUtils.TAG, "RegisterNotify callback onSuccess: $response")
                }

                override fun onError(response: String?) {
                    Log.d(ConstantsUtils.TAG, "RegisterNotify callback onError: $response")
                }

                override fun onNotifyPaymentCreate(response: String) {
                    Log.d(
                        ConstantsUtils.TAG,
                        "RegisterNotify callback onNotifyPaymentCreate: $response"
                    )
                }

                override fun onNotifyPaymentConfirmed(response: String) {
                    Log.d(
                        ConstantsUtils.TAG,
                        "RegisterNotify callback onNotifyPaymentConfirmed: $response"
                    )
                }

                override fun onNotifyPaymentUpdate(response: String) {
                    Log.d(
                        ConstantsUtils.TAG,
                        "RegisterNotify callback onNotifyPaymentUpdate: $response"
                    )
                }

                override fun onNotifyPing(response: String) {
                    Log.d(ConstantsUtils.TAG, "RegisterNotify callback onNotifyPing: $response")
                }
            }
        )
    }