To initiate a UPI transaction, use the startPayment
method:
sdk.startPayment("AMOUNT", // Amount to be paid
"ORDER_ID", // Unique Order ID
"CUSTOMER_NAME", // Customer's name
"CUSTOMER_EMAIL", // Customer's email
"CUSTOMER_NUMBER", // Customer's contact number
new PaymentCallback() {
@Override
public void onPaymentSuccess(String order_id, String message) {
Toast.makeText(MainActivity.this, message, Toast.LENGTH_SHORT).show();
}
@Override
public void onPaymentFailed(String order_id, String message) {
String logMessage = message + " Order Id " + order_id;
Toast.makeText(MainActivity.this, logMessage, Toast.LENGTH_SHORT).show();
Log.d("PaymentFailed", logMessage);
}
});
Parameters
AMOUNT
: The payment amount.ORDER_ID
: A unique order identifier generated by your app.CUSTOMER_NAME
: The name of the customer making the payment.CUSTOMER_EMAIL
: The customer's email address.CUSTOMER_NUMBER
: The customer's contact number.PaymentCallback
: Handles success and failure responses.
Payment Callback
Implement the PaymentCallback
interface to handle payment responses:
onPaymentSuccess(String order_id, String message)
: Called when the payment is successful.onPaymentFailed(String order_id, String message)
: Called when the payment fails.
Logging and Debugging
For debugging failed transactions, use:
Log.d("PaymentFailed", logMessage);
This helps in tracking payment issues by logging the failure message and order ID.