Create Payments
The startPayment
method is the primary entry point for initiating a payment flow within your application using the Nayax eCom SDK. The method internally handles the calls to validateMerchant
and initialize
(the Nayax eCom API calls, not the SDK initialization). This means that you do not need to explicitly make these API calls before initiating a payment. The SDK will do the following:
- Perform the necessary
validateMerchant
call to authenticate the transaction securely. - Execute the
initialize
call to set up the payment session with Nayax servers and the billing provider. - Trigger the Drop-In UI for the user to complete the payment.
This allows you to focus on providing the PaymentData
and handling the payment results, while the SDK takes care of the communication and security protocols.
Payment Data
The startPayment
method requires a PaymentData
object that encapsulates all the necessary details for the transaction.
data class TransactionData(
val validationKey: String,
val amount: Double,
val currencyCode: String,
val countryCode: String,
val machineId: String,
val requestType: Int,
val sessionExpiration: String? = null,
val entryMode: Int? = null,
val tokenModel: Int? = null,
val showSaveCardConsent: Boolean? = null,
val cardHolderInfo: CardHolderInfo? = null,
val additionalData: String? = null
)
data class CardHolderInfo(
val cardHolderUniqId: String? = null,
val cardholderEmail: String? = null
)
public struct PaymentData {
public let merchantTranId: String
public let actorId: String
public let machineId: String
public let amount: Double
public let currencyCode: String
public let countryCode: String
public let requestType: Int
public let sessionExpiration: String?
public let entryMode: Int?
public let tokenModel: Int?
public let showSaveCardConsent: Bool?
public let cardHolderInfo: CardHolderInfo?
public let additionalData: String?
public init(
merchantTranId: String,
actorId: String,
machineId: String,
amount: Double,
currencyCode: String,
countryCode: String,
requestType: Int,
sessionExpiration: String? = nil,
entryMode: Int? = nil,
tokenModel: Int? = nil,
showSaveCardConsent: Bool? = nil,
cardHolderInfo: CardHolderInfo? = nil,
additionalData: String? = nil
) {
self.merchantTranId = merchantTranId
self.actorId = actorId
self.machineId = machineId
self.amount = amount
self.currencyCode = currencyCode
self.countryCode = countryCode
self.requestType = requestType
self.sessionExpiration = sessionExpiration
self.entryMode = entryMode
self.tokenModel = tokenModel
self.showSaveCardConsent = showSaveCardConsent
self.cardHolderInfo = cardHolderInfo
self.additionalData = additionalData
}
}
public struct CardHolderInfo {
public let cardHolderUniqId: String?
public let cardholderEmail: String?
public init(
cardHolderUniqId: String? = nil,
cardholderEmail: String? = nil
) {
self.cardHolderUniqId = cardHolderUniqId
self.cardholderEmail = cardholderEmail
}
}
Key parameters include:
Parameter | Type | Description |
---|---|---|
validationKey | String (Unique GUID) | This is the eCom Transaction ID, a unique identifier generated during the /validate-merchant authentication flow. It links the current payment attempt to a securely authenticated session. |
amount | Double (Android/iOS), or equivalent numeric type | The requested transaction amount in minor units (e.g., 15.00 for $15.00). |
currencyCode | String (Alpha-3 format, e.g., "USD", "EUR", "ILS") | The currency of the transaction, adhering to ISO 4217 standards. |
countryCode | String (2 or 3 letters, e.g., "US", "GB", "IL") | The country code where the cardholder is located, typically following ISO 3166. |
machineId | String | The Machine ID as defined and saved in the Nayax Backoffice, received as part of the onboarding process. |
requestType | Integer | Specifies the desired transaction type. Common values include: 0 : Sale (Authorization + automatic Capture), 1 : Auth (Authorization only), 2 : Capture (for pre-authorized transactions). (Refer to the full API documentation for a comprehensive list ofrequestType values, including void, refund, incremental auth, etc.) |
sessionExpiration | String (ISO8601 format, e.g., "2023-11-23T12:25:28Z" ) (Optional) | The session expiry date. If not provided, the default is typically 1 hour. |
entryMode | Integer (Optional) | Indicates the cardholder entry mode (e.g., COF for Card On File, ECOM for E-Commerce, MIT for Merchant Initiated Transaction, CIT for Customer Initiated Transaction). Default is ECOM . |
tokenModel | Integer (Conditional) | If entryMode is COF , indicates the token model (e.g., subscription , top-up , Stored.card ). |
showSaveCardConsent | Boolean (Conditional) | If entryMode is COF , determines whether the "Ask for Consent" question appears on the payment page for saving card details. |
cardHolderInfo | Object containing cardHolderUniqId and cardholderEmail (Optional) | Provides cardholder details, especially relevant for tokenized transactions. |
See Also
Updated about 5 hours ago