Search…
⌃K
Links

SDK Models

classes reference
NearPay services compatible with devices running Android API 26 or higher, otherwise UNSUPPORTED_SDK_VERSION will returned.

Transaction Receipt

Kotlin
Json
@Parcelize
@Serializable
data class TransactionReceipt(
@SerialName("id")
val receipt_id: String,
@SerialName("transaction_uuid")
val transaction_uuid: String,
@SerialName("merchant")
val merchant: Merchant,
@SerialName("start_date")
val start_date: String,
@SerialName("start_time")
val start_time: String,
@SerialName("card_scheme_sponsor")
val card_scheme_sponsor: String,
@SerialName("tid")
val tid: String,
@SerialName("system_trace_audit_number")
val system_trace_audit_number: String,
@SerialName("pos_software_version_number")
val pos_software_version_number: String,
@SerialName("retrieval_reference_number")
val retrieval_reference_number: String,
@SerialName("card_scheme")
val card_scheme: NameField<String>,
@SerialName("transaction_type")
val transaction_type: NameField<String>,
@SerialName("pan")
val pan: String,
@SerialName("card_expiration")
val card_expiration: String,
@SerialName("amount_authorized")
val amount_authorized: LabelField<String>,
@SerialName("amount_other")
val amount_other: LabelField<String>,
@SerialName("currency")
val currency: LocalizationField,
@SerialName("status_message")
val status_message: LocalizationField,
@SerialName("is_approved")
val is_approved: Boolean,
@SerialName("is_refunded")
val is_refunded: Boolean,
@SerialName("is_reversed")
val is_reversed: Boolean,
@SerialName("approval_code")
val approval_code: LabelField<String>?,
@SerialName("verification_method")
val verification_method: LocalizationField,
@SerialName("end_date")
val end_date: String,
@SerialName("end_time")
val end_time: String,
@SerialName("receipt_line_one")
val receipt_line_one: LocalizationField,
@SerialName("receipt_line_two")
val receipt_line_two: LocalizationField,
@SerialName("thanks_message")
val thanks_message: LocalizationField,
@SerialName("save_receipt_message")
val save_receipt_message: LocalizationField,
@SerialName("entry_mode")
val entry_mode: String,
@SerialName("action_code")
val action_code: String,
@SerialName("application_identifier")
val application_identifier: String,
@SerialName("terminal_verification_result")
val terminal_verification_result: String,
@SerialName("transaction_state_information")
val transaction_state_information: String,
@SerialName("cardholader_verfication_result")
val cardholader_verfication_result: String,
@SerialName("cryptogram_information_data")
val cryptogram_information_data: String,
@SerialName("application_cryptogram")
val application_cryptogram: String,
@SerialName("kernel_id")
val kernel_id: String,
@SerialName("payment_account_reference")
val payment_account_reference: String?,
@SerialName("pan_suffix")
val pan_suffix: String?,
@SerialName("created_at")
val created_at: String? = "",
@SerialName("updated_at")
val updated_at: String? = "",
@SerialName("qr_code")
val qr_code: String
): Parcelable
@Parcelize
@Serializable
data class Merchant(
@SerialName("id")
val id: String,
@SerialName("name")
val name: LocalizationField,
@SerialName("address")
val address: LocalizationField,
@SerialName("category_code")
val category_code: String
): Parcelable
{
"id": "19f9524d-407a-4d28-bd1e-89e7fb821598",
"merchant": {
"id": "100000000000001",
"name": {
"arabic": "123455",
"english": "NearPay-Test Terminal INMA"
},
"address": {
"arabic": "4321",
"english": "KAFD"
},
"category_code": "0763"
},
"card_scheme": {
"name": {
"english": "Visa",
"arabic": "فيزا"
},
"id": "VC"
},
"card_scheme_sponsor": "INMA",
"start_date": "06/11/2022",
"start_time": "16:11:09",
"end_date": "06/11/2022",
"end_time": "16:11:09",
"tid": "0200010400000104",
"system_trace_audit_number": "000043",
"pos_software_version_number": "1.0.0",
"retrieval_reference_number": "000000002031",
"transaction_type": {
"name": {
"arabic": "شراء",
"english": "PURCHASE"
},
"id": "00"
},
"is_approved": true,
"is_refunded": false,
"is_reversed": false,
"approval_code": {
"value": "587117",
"label": {
"arabic": "رمز الموافقة",
"english": "Approval Code"
}
},
"action_code": "000",
"status_message": {
"arabic": "مقبولة",
"english": "Approved"
},
"pan": "4639 17** **** 3838",
"card_expiration": "23/02",
"amount_authorized": {
"label": {
"arabic": "مبلغ الشراء",
"english": "PURCHASE AMOUNT"
},
"value": "0.01"
},
"amount_other": {
"label": {
"arabic": "مبلغ النقد",
"english": "NAQD AMOUNT"
},
"value": "0.00"
},
"currency": {
"arabic": "ر.س",
"english": "SAR"
},
"verification_method": {
"english": "NO VERIFICATION REQUIRED",
"arabic": "لا يتطلب التحقق"
},
"receipt_line_one": {
"arabic": "",
"english": ""
},
"receipt_line_two": {
"arabic": "",
"english": ""
},
"thanks_message": {
"arabic": "شكرا لاستخدامكم مدى",
"english": "Thank you for using mada"
},
"save_receipt_message": {
"arabic": "يرجى الاحتفاظ بالفاتورة",
"english": "please retain receipt"
},
"entry_mode": "CONTACTLESS",
"application_identifier": "A0000000031010",
"terminal_verification_result": "2480403800",
"transaction_state_information": "0000",
"cardholader_verfication_result": "1F0000",
"cryptogram_information_data": "80",
"application_cryptogram": "1D6B44271DC4A690",
"kernel_id": "03",
"payment_account_reference": "",
"pan_suffix": "",
"qr_code": "https://sandbox-api.nearpay.io/ui/receipt/19f9524d-407a-4d28-bd1e-89e7fb821598",
"transaction_uuid": "11d91e8b-fe1a-44c8-a4c7-eab8aab9f62a"
}
ID
Network
MC
Mastercard - credit
DM
Maestro
P1
Mada
VC
Visa
UP
Union Pay
DC
Discover
JC
JCB
AX
American Express
GN
GCCNET

Setup Errors

sealed class SetupFailure {
object AlreadyInstalled : SetupFailure()
object NotInstalled : SetupFailure()
data class AuthenticationFailed(val message: String) : SetupFailure()
data class InvalidStatus(val status: List<StatusCheckError>) : SetupFailure()
}

Purchase Errors

sealed class PurchaseFailure {
data class PurchaseDeclined(val receipt: TransactionReceipt?): PurchaseFailure()
data class PurchaseRejected(val message: String): PurchaseFailure()
data class AuthenticationFailed(val message: String): PurchaseFailure()
data class InvalidStatus(val status: List<StatusCheckError>): PurchaseFailure()
object GeneralFailure: PurchaseFailure()
}

Refund Errors

sealed class RefundFailure {
data class RefundDeclined(val receipt: TransactionReceipt?): RefundFailure()
data class RefundRejected(val message: String): RefundFailure()
data class AuthenticationFailed(val message: String): RefundFailure()
data class InvalidStatus(val status: List<StatusCheckError>): RefundFailure()
object GeneralFailure: RefundFailure()
}

Reconcile Errors

sealed class ReconcileFailure {
data class FailureMessage(val message: String) : ReconcileFailure()
data class AuthenticationFailed(val message: String): ReconcileFailure()
data class InvalidStatus(val status: List<StatusCheckError>): ReconcileFailure()
object GeneralFailure: ReconcileFailure()
}

Reconcile Data

Kotlin
Json
@Parcelize
@Serializable
data class ReconciliationReceipt(
@SerialName("id")
val id: String,
@SerialName("date")
val date: String,
@SerialName("time")
val time: String,
@SerialName("is_balanced")
val is_balanced: LabelField<Boolean>,
@SerialName("details")
val details: ReconciliationDetails,
@SerialName("schemes")
val schemes: List<ReconciliationSchemes> = emptyList(),
@SerialName("currency")
val currency: LocalizationField,
@SerialName("qr_code")
val qr_code: String
): Parcelable
@Parcelize
@Serializable
data class ReconciliationDetails(
@SerialName("purchase")
val purchase: ReconciliationLabelField,
@SerialName("refund")
val refund: ReconciliationLabelField,
@SerialName("purchase_reversal")
val purchase_reversal: ReconciliationLabelField,
@SerialName("refund_reversal")
val refund_reversal: ReconciliationLabelField,
@SerialName("total")
val total: ReconciliationLabelField
) : Parcelable
@Parcelize
@Serializable
data class ReconciliationSchemes(
@SerialName("name")
val name: LabelField<String>,
@SerialName("pos")
val pos: ReconciliationSchemesDetails,
@SerialName("host")
val host: ReconciliationSchemesDetails
) : Parcelable
@Parcelize
@Serializable
data class ReconciliationSchemesDetails(
@SerialName("debit")
val debit: ReconciliationLabelField,
@SerialName("credit")
val credit: ReconciliationLabelField,
@SerialName("total")
val total: ReconciliationLabelField,
) : Parcelable
@Parcelize
@Serializable
data class ReconciliationLabelField(
@SerialName("label")
val label: LocalizationField,
@SerialName("total")
val total: String,
@SerialName("count")
val count: Int
) : Parcelable
{
"id": "c3110f9b-8206-4f4d-8519-1ddd4972af25",
"merchant": {
"id": "000000000000001",
"name": {
"arabic": "123455",
"english": "NearPay-Test Terminal INMA"
},
"address": {
"arabic": "4321",
"english": "KAFD"
},
"category_code": "0763"
},
"card_scheme": {
"name": {
"english": "mada",
"arabic": "مدى"
},
"id": "P1"
},
"card_scheme_sponsor": "INMA",
"start_date": "14/11/2022",
"start_time": "15:48:54",
"end_date": "14/11/2022",
"end_time": "15:48:54",
"tid": "0000000000000058",
"system_trace_audit_number": "000608",
"pos_software_version_number": "1.0.0",
"retrieval_reference_number": "000000002437",
"transaction_type": {
"name": {
"arabic": "استرداد",
"english": "REFUND"
},
"id": "20"
},
"is_approved": true,
"is_refunded": false,
"is_reversed": false,
"approval_code": {
"value": "488439",
"label": {
"arabic": "رمز الموافقة",
"english": "Approval Code"
}
},
"action_code": "000",
"status_message": {
"arabic": "مقبولة",
"english": "Approved"
},
"pan": "5069 68** **** 4655",
"card_expiration": "24/04",
"amount_authorized": {
"label": {
"arabic": "المبلغ المسترد",
"english": "REFUND AMOUNT"
},
"value": "10.00"
},
"amount_other": {
"label": {
"arabic": "مبلغ النقد",
"english": "NAQD AMOUNT"
},
"value": "0.00"
},
"currency": {
"arabic": "ر.س",
"english": "SAR"
},
"verification_method": {
"english": "NO VERIFICATION REQUIRED",
"arabic": "لا يتطلب التحقق"
},
"receipt_line_one": {
"arabic": "",
"english": ""
},
"receipt_line_two": {
"arabic": "",
"english": ""
},
"thanks_message": {
"arabic": "شكرا لاستخدامكم مدى",
"english": "Thank you for using mada"
},
"save_receipt_message": {
"arabic": "يرجى الاحتفاظ بالفاتورة",
"english": "please retain receipt"
},
"entry_mode": "CONTACTLESS",
"application_identifier": "A0000002281010",
"terminal_verification_result": "0080008000",
"transaction_state_information": "0000",
"cardholader_verfication_result": "3F0000",
"cryptogram_information_data": "80",
"application_cryptogram": "079293C17D8EA247",
"kernel_id": "2d",
"payment_account_reference": "",
"pan_suffix": "",
"qr_code": "https://sandbox-api.nearpay.io/ui/receipt/c3110f9b-8206-4f4d-8519-1ddd4972af25",
"transaction_uuid": "874ba7ac-00e7-4743-85cc-038fd5478589"
}

Session Data

@Parcelize
@Serializable
data class Session(
@SerialName("id")
val id: String,
@SerialName("status")
val status: String,
@SerialName("type")
val type: String,
@SerialName("client_id")
val client_id: String,
@SerialName("amount")
val amount: String,
@SerialName("expired_at")
val expired_at: String,
@SerialName("reference_id")
val reference_id: String?,
@SerialName("created_at")
val created_at: String,
@SerialName("updated_at")
val updated_at: String,
@SerialName("transaction")
val transaction: Transaction?,
) : Parcelable
@Parcelize
@Serializable
data class Transaction(
@SerialName("id")
val id: String?,
@SerialName("uuid")
val uuid: String?,
@SerialName("amount_authorized")
val amount_authorized: String?,
@SerialName("transaction_currency_code")
val transaction_currency_code: String?,
@SerialName("cardholder_verification_result")
val cardholder_verification_result: String?,
@SerialName("lat")
val lat: String?,
@SerialName("lon")
val lon: String?,
@SerialName("transaction_type")
val transaction_type: String?,
@SerialName("card_scheme_id")
val card_scheme_id: String?,
@SerialName("system_trace_audit_number")
val system_trace_audit_number: String?,
@SerialName("is_approved")
val is_approved: Boolean?,
@SerialName("is_reversed")
val is_reversed: Boolean?,
@SerialName("is_reconcilied")
val is_reconcilied: Boolean?,
@SerialName("device_id")
val device_id: String?,
@SerialName("user_id")
val user_id: String?,
@SerialName("merchant_id")
val merchant_id: String?,
@SerialName("customer_reference_number")
val customer_reference_number: String?,
@SerialName("pos_confirmed")
val pos_confirmed: Boolean?,
@SerialName("created_at")
val created_at: String?,
@SerialName("updated_at")
val updated_at: String?,
@SerialName("receipts")
val receipts: List<TransactionReceipt> = emptyList(),
@SerialName("card_scheme")
val card_scheme: LocalizationField,
@SerialName("type")
val type: LocalizationField,
@SerialName("verification_method")
val verification_method: LocalizationField,
) : Parcelable

Reverse Error

sealed class ReversalFailure{
data class FailureMessage(val message: String) : ReversalFailure()
data class AuthenticationFailed(val message: String): ReversalFailure()
data class InvalidStatus(val status: List<StatusCheckError>): ReversalFailure()
object GeneralFailure: ReversalFailure()
}

Logout Error

sealed class LogoutFailure {
object AlreadyLoggedOut : LogoutFailure()
object GeneralFailure : LogoutFailure()
}

Session Data

sealed class ConnectionSession {
data class Bluetooth(val device: String): ConnectionSession()
data class WebSocket(val ipv4Address: String, val port: String): ConnectionSession()
}