Transactions
3 min
Pay3.getInstance().openCheckout(checkout obj)
Pay3 Android SDK expects you to pass token and requestId which you get in response while creating a checkout order with Pay3's create checkout order API
Parameters
- requestId (Type string): App needs to generate a unique identifier for every checkout call. This id can be used by the App to identify and update state in App's backend.
- token (Type string): This is a unique id generated by Pay3 backend on calling create checkout order. This is to identify the request created by Application's backend.
createOrder { response, error ->
if (response != null) {
val token = response.token
val requestId = response.requestId
Pay3.getInstance().openCheckout(
context = this,
requestId = requestId,
token = token,
onClosed = {
// Handle payment completion or cancellation
Log.d("Payment", "Payment flow closed")
}
)
} else {
// Handle error
Log.e("Payment", "Failed to create order: $error")
}
}Payment Flow
The SDK handles the complete payment flow, including:
- Displaying available payment methods
- UPI app selection and deep linking
- Card and net banking options
- Payment status tracking
- Success/failure handling
Example Implementatation:
import com.pay3.sdk.Pay3
class PaymentActivity : ComponentActivity() {
private val TAG = "PaymentActivity"
fun processPayment(productId: String, amount: Double) {
// Create order with your backend with Pay3's creat checkout order API
val orderRequest = OrderRequest(productId, amount)
createOrder(orderRequest) { response, error ->
if (response != null) {
// Start payment flow
Pay3.getInstance().openCheckout( // call to Pay3 Android SDK
context = this,
requestId = response.requestId,
token = response.token,
onClosed = {
// Payment completed or cancelled
// Verify payment status with your backend
verifyPaymentStatus(response.requestId)
}
)
} else {
Log.e(TAG, "Failed to create order: $error")
showError("Unable to process payment. Please try again.")
}
}
}
private fun verifyPaymentStatus(requestId: String) {
// Check payment status with your backend
}
}