Show UI

TerraCore v0

Usage#

Finally we just call as below to start new transaction

// start activity result
//if using activity
paymentGateway.payWith(yourActivity, paymentRequestBuilder.build())
//if using fragment
paymentGateway.payWith(yourFragment, paymentRequestBuilder.build())

Handle payment result#

After payment, the PaymentActivity will be return the result in onActivityResult with the following data:

  • requestCode: PaymentActivity.RC_PAYMENT

  • resultCode:

  • PaymentActivity.RESULT_CANCELED: when use cancels payment process: press Cancel button, ...

  • PaymentActivity.RESULT_SUCCEEDED: when payment process is succeeded

  • PaymentActivity.RESULT_FAILED: when payment process is failed or activity is stopped and received a Activity.RESULT_CANCELED from system.

  • data: a nullable PaymentResult object which depends on result
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
when (requestCode) {
PaymentActivity.RC_PAYMENT -> {
when (resultCode) {
PaymentActivity.RESULT_CANCELED -> {
// Payment is canceled
}
PaymentActivity.RESULT_FAILED -> {
val result = data?.getParcelableExtra<PaymentResult>(PaymentActivity.PAYMENT_RESULT_KEY)
// TODO: Payment is failed
}
PaymentActivity.RESULT_SUCCEEDED -> {
val result = data?.getParcelableExtra<PaymentResult>(PaymentActivity.PAYMENT_RESULT_KEY)
// TODO: Payment is succeeded
}
}
}
else -> super.onActivityResult(requestCode, resultCode, data)
}
}

Notes:

  1. For using VNPayEWallet method:
implementation(name: 'sdkwallet_release_x_x.x.x', ext: 'aar')
  • Add tools:replace="label,allowBackup,android:theme" to <application> tag in AndroidManifest.xml file

Note: Currently, sdkwallet has only allowed running on the emulator. Please use real device for testing this feature.

References#