App Development
Phonepe payment gateway integration Android [2024]
AAdminDecember 22, 20236 min read
![Phonepe payment gateway integration Android [2024]](/_next/image?url=https%3A%2F%2Fpub-6260987aa5e84a04b470576604a2f319.r2.dev%2Fblog-images%2F1791291253631-How-to-Integrate-Phonepe-Payment-Gateway-in-Android-1.jpg&w=1920&q=75)
public class YourApplication extends Application { @Override public void onCreate() { super.onCreate(); PhonePe.init(getApplicationContext(), "YOUR_PHONEPE_CLIENT_ID"); } }
public class PaymentActivity extends AppCompatActivity {
private void initiatePayment() {
PaymentRequest paymentRequest = new PaymentRequest.PaymentRequestBuilder()
.setOrderId("YOUR_ORDER_ID")
.setAmount(100) // Set the amount in paisa
.setTransactionId("YOUR_TRANSACTION_ID")
.build();
PhonePe.startPayment(this, paymentRequest, new PhonePe.PaymentResultListener() {
@Override
public void onPaymentSuccess() {
// Handle payment success
}
@Override
public void onPaymentError(PhonePeError phonePeError) {
// Handle payment failure
}
@Override
public void onPaymentCancel() {
// Handle payment cancellation
}
});
}
}
PhonePe.startTransaction(MainActivity.this, paymentRequest, new PaymentStatusListener() { @Override public void onPaymentSuccess(String s) { // Handle payment success }
@Override
public void onPaymentError(int i, String s) {
// Handle payment error
}
});
Need help with your project?
Talk to the Papaya Coders team for a free consultation.