Skip to main content
Skip table of contents

Inicializar Pay-me SDK Android

A continuación, se detallan los pasos para inicializar el SDK.

Es necesario los datos del paso Parámetros de Entrada y Salida de Pay-me SDK Android y la Key brindada por Pay-me.

Importar las clases del SDK

Se debe importar las siguientes clases en la actividad donde se invocará al SDK.

KOTLIN
import com.alignet.payme.PaymeClient;
import com.alignet.payme.PaymeClientDelegate;
import com.alignet.payme.util.PaymeEnvironment;
import com.alignet.payme.model.*

Invocar al SDK

Se invoca el SDK con los datos de entrada.

La función authorizeTransaction de la clase PaymeClient es el encargado de inicializar el proceso de autorización, esta función recibe los siguientes parámetros:

  • activity: Es el activity desde donde se hará la invocación del SDK.

  • paymeRequest: El objeto de entrada que contiene toda la información de la transacción.

setEnvironment: Este parámetro nos permitirá seleccionar el ambiente:

  • Development

  • Production

KOTLIN
val paymePersonData = PaymePersonData(
        firstName = "Levis",
        lastName = "Silvestre",
        email = "levis.silvestre@alignet.com",
        addrLine1 = "Av casimiro Ulloa 333",
        addrLine2 = "Av casimiro Ulloa 333",
        city = "Lima",
        countryCode = "PE",
        countryNumber = "840",
        zip = "18",
        state = "Lima",
        mobilePhone = "51-958435685"
)

val reservedData = HashMap<String, String>()
reservedData["reserved1"] = "1"
reservedData["reserved2"] = "2"

val authenticationData = PaymeAuthenticationData("01")

val paymeRequest = PaymeRequest(
        merchant = PaymeMerchantData(
                operation = PaymeOperationData(
                        operationNumber = "000001",
                        operationDescription = "Televisor",
                        amount = "10.55",
                        currency = PaymeCurrencyData(
                                code = "604",
                                symbol = "S/"
                        )
                ),
                addrMatch = true,
                shipping  = paymePersonData,
                billing   = paymePersonData
        ),
        feature = PaymeFeatureData(
                reserved = reservedData,
                wallet = PaymeWalletData(true, "COMMERCE_USER""),
                installments = PaymeInstallmentsData(true),
                authentication = authenticationData
        ),
        setting = PaymeSettingData(
                locale = "es_PE",
                brands = listOf("VISA","MSCD","AMEX","DINC")
        )
)

val paymeClient = PaymeClient(this, "COMMERCE_KEY")
paymeClient.setEnvironment(PaymeEnvironment.PRODUCTION)
paymeClient.authorizeTransaction(activity = this, paymeRequest = paymeRequest)

Se debe implementar el delegado PaymeClientDelegate:

KOTLIN
class MainActivity: AppCompatActivity(), PaymeClientDelegate {
  ...
}

El Objeto PaymeInternalAction retornará por el SDK notificaciones por cada acción interna:

  • Tarjeta Habiente le da al botón pagar

  • Se inicia y terminar el proceso RBA

  • Se inicia y termina el proceso 3DS

  • Se inicia la autorización con el componente Charges

El objeto PaymeResponse retornará por el SDK la respuesta final, una vez finalizado todo el proceso.

KOTLIN
override fun onNotificate(action: PaymeInternalAction) {
        when (action) {
            PaymeInternalAction.PRESS_PAY_BUTTON -> println("El usuario presionó el boton pagar exitosamente.")
            PaymeInternalAction.START_SCORING -> println("Inicia el proceso de evaluación de riesgo.")
            PaymeInternalAction.END_SCORING -> println("Termina el proceso de evaluación de riesgo.")
            PaymeInternalAction.START_TDS -> println("Inicia el proceso de autenticación.")
            PaymeInternalAction.END_TDS -> println("Termina el proceso de autenticación.")
            PaymeInternalAction.START_AUTHORIZATION -> println("Se inicia la autorización.")
            else -> println("Action no reconocida.")
        }
    }

    override fun onRespondsPayme(response: PaymeResponse) {
        val gson = GsonBuilder().setPrettyPrinting().create()
        val gsonRequest = gson.toJson(this.paymeRequest)
        val gsonResponse = gson.toJson(response)

        println(gsonRequest)
        println(gsonResponse)
    }

Continuar a Mensajes de errores de Pay-me SDK ➡️

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.