diff --git a/build.gradle b/build.gradle index 9788666..d371af7 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ buildscript { ] repositories { - jcenter() + mavenCentral() google() } dependencies { diff --git a/example/src/main/java/co/paystack/example/MainActivity.java b/example/src/main/java/co/paystack/example/MainActivity.java index 5b8901d..7588db6 100644 --- a/example/src/main/java/co/paystack/example/MainActivity.java +++ b/example/src/main/java/co/paystack/example/MainActivity.java @@ -211,6 +211,13 @@ public void beforeValidate(Transaction transaction) { updateTextViews(); } + @Override + public void showLoading(Boolean isProcessing) { + if (isProcessing) { + Toast.makeText(MainActivity.this, "Processing...", Toast.LENGTH_LONG).show(); + } + } + @Override public void onError(Throwable error, Transaction transaction) { // If an access code has expired, simply ask your server for a new one diff --git a/paystack/src/main/java/co/paystack/android/Paystack.java b/paystack/src/main/java/co/paystack/android/Paystack.java index 7c7aaa6..1002b90 100644 --- a/paystack/src/main/java/co/paystack/android/Paystack.java +++ b/paystack/src/main/java/co/paystack/android/Paystack.java @@ -82,7 +82,7 @@ private interface BaseCallback { public interface TransactionCallback extends BaseCallback { void onSuccess(Transaction transaction); void beforeValidate(Transaction transaction); - + void showLoading(Boolean isProcessing); void onError(Throwable error, Transaction transaction); } diff --git a/paystack/src/main/java/co/paystack/android/TransactionManager.java b/paystack/src/main/java/co/paystack/android/TransactionManager.java index bf6faf4..fb874de 100644 --- a/paystack/src/main/java/co/paystack/android/TransactionManager.java +++ b/paystack/src/main/java/co/paystack/android/TransactionManager.java @@ -66,6 +66,7 @@ class TransactionManager { @Override public void onResponse(Call call, Response response) { handleApiResponse(response.body()); + transactionCallback.showLoading(false); } @Override @@ -166,6 +167,7 @@ private void chargeWithAvs(Address address) { HashMap fields = address.toHashMap(); fields.put("trans", transaction.getId()); try { + this.transactionCallback.showLoading(true); Call call = apiService.submitCardAddress(fields); call.enqueue(serverCallback); } catch (Exception e) { @@ -175,20 +177,23 @@ private void chargeWithAvs(Address address) { } private void validateChargeOnServer() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException { + this.transactionCallback.showLoading(true); HashMap params = validateRequestBody.getParamsHashMap(); Call call = apiService.validateCharge(params); call.enqueue(serverCallback); } private void reQueryChargeOnServer() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException { + this.transactionCallback.showLoading(true); Call call = apiService.requeryTransaction(transaction.getId()); call.enqueue(serverCallback); } private void initiateChargeOnServer() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException { - + this.transactionCallback.showLoading(true); Call call = apiService.charge(chargeRequestBody.getParamsHashMap()); call.enqueue(serverCallback); + } private void handleApiResponse(TransactionApiResponse transactionApiResponse) { @@ -275,6 +280,7 @@ public void onTick(long millisUntilFinished) { private void notifyProcessingError(Throwable t) { setProcessingOff(); + transactionCallback.showLoading(false); transactionCallback.onError(t, transaction); }