Add additional logging around boost amounts.
This commit is contained in:
parent
d028165b51
commit
9434894dff
3 changed files with 15 additions and 4 deletions
|
@ -86,11 +86,11 @@ class DonationPaymentRepository(activity: Activity) : StripeApi.PaymentIntentFet
|
|||
}
|
||||
|
||||
fun continuePayment(price: FiatMoney, paymentData: PaymentData): Completable {
|
||||
Log.d(TAG, "Creating payment intent...", true)
|
||||
Log.d(TAG, "Creating payment intent for $price...", true)
|
||||
return stripeApi.createPaymentIntent(price, application.getString(R.string.Boost__thank_you_for_your_donation))
|
||||
.onErrorResumeNext { Single.error(DonationExceptions.SetupFailed(it)) }
|
||||
.flatMapCompletable { result ->
|
||||
Log.d(TAG, "Created payment intent.", true)
|
||||
Log.d(TAG, "Created payment intent for $price.", true)
|
||||
when (result) {
|
||||
is StripeApi.CreatePaymentIntentResult.AmountIsTooSmall -> Completable.error(DonationExceptions.SetupFailed(Exception("Boost amount is too small")))
|
||||
is StripeApi.CreatePaymentIntentResult.AmountIsTooLarge -> Completable.error(DonationExceptions.SetupFailed(Exception("Boost amount is too large")))
|
||||
|
@ -277,7 +277,7 @@ class DonationPaymentRepository(activity: Activity) : StripeApi.PaymentIntentFet
|
|||
}
|
||||
|
||||
override fun fetchPaymentIntent(price: FiatMoney, description: String?): Single<StripeApi.PaymentIntent> {
|
||||
Log.d(TAG, "Fetching payment intent from Signal service...")
|
||||
Log.d(TAG, "Fetching payment intent from Signal service for $price... (Locale.US minimum precision: ${price.minimumUnitPrecisionString})")
|
||||
return ApplicationDependencies
|
||||
.getDonationsService()
|
||||
.createDonationIntentWithAmount(price.minimumUnitPrecisionString, price.currency.currencyCode, description)
|
||||
|
|
|
@ -179,8 +179,10 @@ class BoostViewModel(
|
|||
store.update { it.copy(stage = BoostState.Stage.TOKEN_REQUEST) }
|
||||
|
||||
val boost = if (snapshot.isCustomAmountFocused) {
|
||||
Log.d(TAG, "Boosting with custom amount ${snapshot.customAmount}")
|
||||
Boost(snapshot.customAmount)
|
||||
} else {
|
||||
Log.d(TAG, "Boosting with preset amount ${snapshot.selectedBoost.price}")
|
||||
snapshot.selectedBoost
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public class FiatMoney {
|
|||
NumberFormat formatter = NumberFormat.getInstance(Locale.US);
|
||||
formatter.setMaximumFractionDigits(0);
|
||||
formatter.setGroupingUsed(false);
|
||||
|
||||
|
||||
BigDecimal multiplicand = BigDecimal.TEN.pow(currency.getCurrencyCode().equals("UGX") ? 2 : currency.getDefaultFractionDigits());
|
||||
|
||||
return formatter.format(amount.multiply(multiplicand));
|
||||
|
@ -73,4 +73,13 @@ public class FiatMoney {
|
|||
Objects.equals(left.currency, right.currency) &&
|
||||
Objects.equals(left.timestamp, right.timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FiatMoney{" +
|
||||
"amount=" + amount +
|
||||
", currency=" + currency +
|
||||
", timestamp=" + timestamp +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue