To launch Razorpay ePOS using the intent flow you need to launch an intent with the follwing URI data:
rzp://epos/pay?product_name=tshirt&amount=100&contact=9876543210&description=tshirt&merchant_order_id=txn_123qwe
We have given a helper class called RazorpayInvoice
which helps in creating this URI
/*
* Amount, product name and contact are mandatory fields
* Amount should be pass in paise as a long
*/
RazorpayInvoice invoice = new RazorpayInvoice.Builder()
.setMerchantOrderId(merchantOrderId.getText().toString())
.setAmount(Long.parseLong(amountEt.getText().toString()))
.setContact(contactEt.getText().toString())
.setDescription(descriptionEt.getText().toString())
.setProductName(productNameEt.getText().toString())
.create();
invoice.launch(activityContext);
To proccess the result of a transaction you need to override the onActivityResult medthod and call RazorpayInvoice.handleActivityResult
from there
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
/**
* You need to call this function in the onActivityResult method
*/
RazorpayInvoice.handleOnActivityResult(requestCode, resultCode, data, new RazorpayInvoice.InvoiceResultCallback() {
@Override
public void onInvoiceSuccess(String invoiceId) {
/**
* The invoice has been paid for successfully
*/
}
@Override
public void onInvoicePending(String invoiceId, String errorDescription) {
/**
* The invoice has been created but the payment is pending
* You can retry the payment from the razorpay epos app
*/
}
@Override
public void onInvoiceFailure(String errorDescription) {
/**
* There was an error while creating an invoice
*/
}
});
}