Confirm Transaction with User
In the payments screen, when the user clicks on BharatX for payment, we need to confirm the transaction first. To do that, add the following:
- Java
- Kotlin
- React Native
- Flutter
Your Android App
public class PaymentActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { // ... bharatxPaymentOption.setOnClickListener(new View.OnClickListener() { @Override void onClick(View view) { BharatXCommonUtilManager.confirmTransactionWithUser( PaymentActivity.this, amountInPaise, phoneNumber, new BharatXCommonUtilManager.TransactionConfirmationListener() { @Override public void onUserConfirmedTransaction() { // user confirmed that they want to proceed with the transaction! }
@Override public void onUserAcceptedPrivacyPolicy() { // user accepted privacy policy. // register our Alternate Data manager. AlternateDataManager.register(MainActivity.this); }
@Override public void onUserCancelledTransaction() { // user cancelled transaction. // allow user to choose other payment options. }
// optional @Override public void onFailure( @NotNull BharatXCommonUtilManager.TransactionFailureReason transactionFailureReason ) { // could not get transaction confirmation // from the user due to a failure } }); } }); // ... }}
Your Android App
class PaymentActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { // ... bharatxPaymentOption.setOnClickListener { BharatXCommonUtilManager.confirmTransactionWithUser( this@PaymentActivity, amountInPaise, phoneNumber, object : BharatXCommonUtilManager.TransactionConfirmationListener() { override fun onUserConfirmedTransaction() { // user confirmed that they want to proceed with the transaction! }
override fun onUserAcceptedPrivacyPolicy() { // user accepted privacy policy. // register our Alternate Data manager. AlternateDataManager.register(this@MainActivity) }
override fun onUserCancelledTransaction() { // user cancelled transaction. // allow user to choose other payment options. }
// optional override fun onFailure( transactionFailureReason: BharatXCommonUtilManager.TransactionFailureReason ) { // could not get transaction confirmation // from the user due to a failure } }) } // ... }}
React Native App
import AlternateDataManager from '@bharatx/bharatx-reactnative-alternatedata';import BharatXCommonUtilManager from '@bharatx/bharatx-reactnative-common';
// ...
const onUserConfirmedTransaction = () => { // user confirmed that they want to proceed with the transaction!};
const onUserAcceptedPrivacyPolicy = () => { // user accepted privacy policy. // register our Alternate Data manager. AlternateDataManager.register();};
const onUserCancelledTransaction = () => { // user cancelled transaction. // allow user to choose other payment options.};
BharatXCommonUtilManager.confirmTransactionWithUser(amountInPaise, onUserConfirmedTransaction, onUserAcceptedPrivacyPolicy, onUserCancelledTransaction);
Flutter App
import 'package:bharatx_flutter_alternatedata/bharatx_flutter_alternatedata.dart';import 'package:bharatx_flutter_common/bharatx_flutter_common.dart';
// ...
final onUserConfirmedTransaction = () { // user confirmed that they want to proceed with the transaction!};
final onUserAcceptedPrivacyPolicy = () { // user accepted privacy policy. // register our Alternate Data manager. AlternateDataManager.register();};
final onUserCancelledTransaction = () { // user cancelled transaction. // allow user to choose other payment options.};
BharatXCommonUtilManager.confirmTransactionWithUser(amountInPaise, onUserConfirmedTransaction, onUserAcceptedPrivacyPolicy, onUserCancelledTransaction);