Skip to content

Express Quick Card Payment

zik-edfa edited this page Feb 9, 2023 · 4 revisions

Pay By Card


ExpressCardPay

ExpressCardPay class allows you to implement payment via CREDIT/DEBIT CARD by following easy steps:

Step 1: Create an instance of ExpressCardPay

var expressCardPay = ExpressCardPay()

Step 2: Create an instance of ExpressPaySaleOrder

 /* Required */
val order = ExpresspaySaleOrder(
    id = UUID.randomUUID().toString(),
    amount = 0.10,
    currency = "SAR",
    description = "Test Order"
)

Step 3: Create an instance of ExpressPayPayerOptions (Optional)

/*
Optional
[if you don't want to pass these detail keep it nil ]
*/
val payerOptions = ExpresspayPayerOptions(
    middleName = "Muhammd Iqbal",
    address2 = "Hyderabad Pakistan",
    state = "Sindh",
    birthdate = Date(),
) 

Step 4: Create an instance of ExpressPayPayer

/* Required (all fields are mandatory except `options`)*/
val payer = ExpresspayPayer(
    firstName = "Zohaib",
    lastName = "Kambrani",
    address = "Riyadh Olaya KSA",
    country = "SA",
    city = "Riyadh",
    zip = "12271",
    email = "a2zzuhaib@gmail.com",
    phone = "+966500409598",
    ip = "188.54.52.147", // fetch your public IP -> https://github.com/chintan369/Ipify-Android
    options = payerOptions
)

Step 5: Set order, payer, payerOptions details to the ExpressCardPay instance.

expressCardPay
    .setOrder(order)
    .setPayer(payer)

Step 6: Set the callbacks to the ExpressCardPay instance to notify you of the different statuses.

.onTransactionFailure(callback:(ExpresspaySaleResponse?, Any?) -> Unit) This will be called when the process receives any type of failure during processing payment (must inspect the 'res' before proceeding)

.onTransactionFailure { res, data ->
    print("$res $data")
    Toast.makeText(this, "Transaction Failure", Toast.LENGTH_LONG).show()
}

.onTransactionSuccess(callback:(ExpresspaySaleResponse?, Any?) -> Unit) This will be called when the process is completed with success status (must inspect the 'res' before proceeding)

.onTransactionSuccess { res, data ->
    print("$res $data")
    Toast.makeText(this, "Transaction Success", Toast.LENGTH_LONG).show()
}

Step 7.1: Initialize/Start the Card Payment

.initialize(context:Activity, onError:(Any) -> Unit, onPresent:(Activity) -> Unit) Facing Issue? Call/Message | Email

expressCardPay.initialize(
    context = this, // this == Activity
    onError = { error ->

    },
    onPresent = { activity -> 

    }
)

ExpressPay

The ExpressPay Android SDK - https://expresspay.sa

Clone this wiki locally