Import classes
import com.alignet.payme.PaymeClient
import com.alignet.payme.PaymeClientDelegate
import com.alignet.payme.util.PaymeEnvironment
import com.alignet.payme.model.*
Create and invoke the client
val person = PaymePersonData(
firstName = "Ana",
lastName = "Perez",
email = "ana@example.com",
addrLine1 = "123 Main Avenue",
addrLine2 = "",
city = "Lima",
countryCode = "PE",
countryNumber = "604",
zip = "15000",
state = "Lima",
mobilePhone = "51-999999999"
)
val request = PaymeRequest(
merchant = PaymeMerchantData(
operation = PaymeOperationData(
operationNumber = "000001",
operationDescription = "Purchase",
amount = "10.55",
currency = PaymeCurrencyData(code = "604", symbol = "S/")
),
addrMatch = true,
shipping = person,
billing = person
),
setting = PaymeSettingData(
locale = "en_US",
brands = listOf("VISA", "MSCD", "AMEX", "DINC")
)
)
val client = PaymeClient(this, "COMMERCE_KEY")
client.setEnvironment(PaymeEnvironment.DEVELOPMENT)
client.authorizeTransaction(activity = this, paymeRequest = request)
Implement the delegate
TheActivity must implement PaymeClientDelegate:
override fun onNotificate(action: PaymeInternalAction) {
// Flow telemetry: scoring, 3DS, and authorization.
}
override fun onRespondsPayme(response: PaymeResponse) {
if (response.success && response.payment?.accepted == true) {
// Confirm the order using operationNumber.
} else {
// Process resultCode, resultMessage, and resultDetail.
}
}
Do not log real personal data. Switch to
PRODUCTION only with the production Key and configuration approved for that environment.
