Import the SDK
import Payme
Create and invoke the client
let person = PaymePersonData(
firstName: "Ana",
lastName: "Perez",
email: "ana@example.com",
addrLine1: "123 Main Avenue",
addrLine2: "",
countryCode: "PE",
countryNumber: "604",
zip: "15000",
city: "Lima",
state: "Lima",
mobilePhone: "51-999999999"
)
let request = PaymeRequest(
merchant: PaymeMerchantData(
operation: PaymeOperationData(
operationNumber: "000001",
operationDescription: "Purchase",
amount: "10.55",
currency: PaymeCurrencyData(code: "604", symbol: "S/")
),
addrMatch: true,
billing: person,
shipping: person
),
setting: PaymeSettingData(
locale: "en_US",
brands: ["VISA", "MSCD", "AMEX", "DINC"]
)
)
let client = PaymeClient(delegate: self, key: "COMMERCE_KEY")
client.setEnvironment(environment: PaymeEnviroment.development)
client.authorizeTransaction(
controller: navigationController!,
usePresent: false,
paymeRequest: request
)
usePresent: true presents the flow modally; false uses the navigationController.
Implement the delegate
extension PaymentController: PaymeClientDelegate {
func onNotificate(action: PaymeInternalAction) {
// Flow telemetry: scoring, 3DS, and authorization.
}
func onRespondsPayme(response: PaymeResponse) {
if response.success, response.payment?.accepted == true {
// Confirm the order using operationNumber.
} else {
// Process resultCode, resultMessage, and resultDetail.
}
}
}
Keep a client reference during the flow, do not log sensitive data, and switch to production only with the Key approved for that environment.

