Payments
To start the payment flow you must call the make Payment method of the First Data SDK instance.
FirstDataSDK
.instance
.makePayment(
activity = [email protected],
amount = amount,
description = saleDescription,
requestCode = PAYMENT_CODE,
externalReferenceNumber = extRef)
Please refer to methods documentation for details about these parameters.
This method will start a new flow of activities and the result of this invocation will be presented on the Activity Result method of your activity or fragment.
In case of having an error you are going to receive an error code and an error message.
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (data != null) {
if (data.hasExtra(SdkConstants.KEY_ERROR_CODE) && data.hasExtra(SdkConstants.KEY_ERROR_MESSAGE)) {
val errorCode = data.getIntExtra(SdkConstants.KEY_ERROR_CODE, 0)
val errorMessage = data.getStringExtra(SdkConstants.KEY_ERROR_MESSAGE)
if (errorCode != 0) {
val message = "$errorCode $errorMessage"
resultDescription.text = message
}
} else if (resultCode == RESULT_OK) {
when (requestCode) {
REFUND_CODE, PAYMENT_CODE -> resultDescription.text = data.getStringExtra(SdkConstants.KEY_SDK_RESPONSE)
}
}
else{
resultDescription.text = "failed"
}
}
else{
resultDescription.text = "failed"
}
super.onActivityResult(requestCode, resultCode, data)
}
You can find all the error codes in Sdk Constants class.
In case of success, you are going to receive a String with json format with the operation result. In this json you can find the operation detail, like the amount charged, customer name, masked card number and the transaction currency. Also, you will find the operation id for later querys.
jsonResult = data.getStringExtra(SdkConstants.KEY_SDK_RESPONSE)
Updated 12 months ago