Skip to content

Commit

Permalink
code optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
samwelnyandoro committed Jul 4, 2024
1 parent 4719756 commit 19b6d55
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,25 +86,20 @@ public void onAuthError(Pair<Integer, String> result) {

@Override
public void onAuthSuccess() {

//TODO make payment
pay.setEnabled(true);
}

private void pay(String phone, int amount){
dialog.show();
STKPush.Builder builder = new STKPush.Builder(BUSINESS_SHORT_CODE, PASSKEY, amount,BUSINESS_SHORT_CODE, phone);

SharedPreferences sharedPreferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
String token = sharedPreferences.getString("InstanceID", "");

builder.setFirebaseRegID(token);
STKPush push = builder.build();



Mpesa.getInstance().pay(this, push);

}

private void showDialog(String title, String message,int code){
MaterialDialog dialog = new MaterialDialog.Builder(this)
.title(title)
Expand Down Expand Up @@ -143,14 +138,14 @@ public void onMpesaSuccess(String MerchantRequestID, String CheckoutRequestID, S
dialog.hide();
Toast.makeText(this, CustomerMessage, Toast.LENGTH_SHORT).show();
}

@Override
protected void onResume() {
super.onResume();

LocalBroadcastManager.getInstance(this).registerReceiver(mRegistrationBroadcastReceiver,
new IntentFilter(NOTIFICATION));

}

@Override
protected void onPause() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(mRegistrationBroadcastReceiver);
Expand Down

0 comments on commit 19b6d55

Please sign in to comment.