diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/subscription/DonationPaymentRepository.kt b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/subscription/DonationPaymentRepository.kt index 1ecef3ef28..cd4d49f394 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/subscription/DonationPaymentRepository.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/subscription/DonationPaymentRepository.kt @@ -70,6 +70,7 @@ class DonationPaymentRepository(activity: Activity) : StripeApi.PaymentIntentFet } fun requestTokenFromGooglePay(price: FiatMoney, label: String, requestCode: Int) { + Log.d(TAG, "Requesting a token from google pay...") googlePayApi.requestPayment(price, label, requestCode) } @@ -80,6 +81,7 @@ class DonationPaymentRepository(activity: Activity) : StripeApi.PaymentIntentFet expectedRequestCode: Int, paymentsRequestCallback: GooglePayApi.PaymentRequestCallback ) { + Log.d(TAG, "Processing possible google pay result...") googlePayApi.onActivityResult(requestCode, resultCode, data, expectedRequestCode, paymentsRequestCallback) } @@ -99,26 +101,36 @@ class DonationPaymentRepository(activity: Activity) : StripeApi.PaymentIntentFet } fun continueSubscriptionSetup(paymentData: PaymentData): Completable { + Log.d(TAG, "Continuing subscription setup...", true) return stripeApi.createSetupIntent() .flatMapCompletable { result -> - stripeApi.confirmSetupIntent(GooglePayPaymentSource(paymentData), result.setupIntent) + Log.d(TAG, "Retrieved SetupIntent, confirming...", true) + stripeApi.confirmSetupIntent(GooglePayPaymentSource(paymentData), result.setupIntent).doOnComplete { + Log.d(TAG, "Confirmed SetupIntent...", true) + } } } fun cancelActiveSubscription(): Completable { + Log.d(TAG, "Canceling active subscription...", true) val localSubscriber = SignalStore.donationsValues().requireSubscriber() return ApplicationDependencies.getDonationsService() .cancelSubscription(localSubscriber.subscriberId) - .flatMap(ServiceResponse::flattenResult).ignoreElement() + .flatMap(ServiceResponse::flattenResult) + .ignoreElement() + .doOnComplete { Log.d(TAG, "Cancelled active subscription.", true) } } fun ensureSubscriberId(): Completable { + Log.d(TAG, "Ensuring SubscriberId exists on Signal service...", true) val subscriberId = SignalStore.donationsValues().getSubscriber()?.subscriberId ?: SubscriberId.generate() return ApplicationDependencies .getDonationsService() .putSubscription(subscriberId) .flatMap(ServiceResponse::flattenResult).ignoreElement() .doOnComplete { + Log.d(TAG, "Successfully set SubscriberId exists on Signal service.", true) + SignalStore .donationsValues() .setSubscriber(Subscriber(subscriberId, SignalStore.donationsValues().getSubscriptionCurrency().currencyCode)) @@ -245,6 +257,7 @@ class DonationPaymentRepository(activity: Activity) : StripeApi.PaymentIntentFet } private fun getOrCreateLevelUpdateOperation(subscriptionLevel: String): Single = Single.fromCallable { + Log.d(TAG, "Retrieving level update operation for $subscriptionLevel") val levelUpdateOperation = SignalStore.donationsValues().getLevelOperation(subscriptionLevel) if (levelUpdateOperation == null) { val newOperation = LevelUpdateOperation( @@ -254,36 +267,48 @@ class DonationPaymentRepository(activity: Activity) : StripeApi.PaymentIntentFet SignalStore.donationsValues().setLevelOperation(newOperation) LevelUpdate.updateProcessingState(true) + Log.d(TAG, "Created a new operation for $subscriptionLevel") newOperation } else { LevelUpdate.updateProcessingState(true) + Log.d(TAG, "Reusing operation for $subscriptionLevel") levelUpdateOperation } } override fun fetchPaymentIntent(price: FiatMoney, description: String?): Single { + Log.d(TAG, "Fetching payment intent from Signal service...") return ApplicationDependencies .getDonationsService() .createDonationIntentWithAmount(price.minimumUnitPrecisionString, price.currency.currencyCode, description) .flatMap(ServiceResponse::flattenResult) .map { StripeApi.PaymentIntent(it.id, it.clientSecret) + }.doOnSuccess { + Log.d(TAG, "Got payment intent from Signal service!") } } override fun fetchSetupIntent(): Single { + Log.d(TAG, "Fetching setup intent from Signal service...") return Single.fromCallable { SignalStore.donationsValues().requireSubscriber() } .flatMap { ApplicationDependencies.getDonationsService().createSubscriptionPaymentMethod(it.subscriberId) } .flatMap(ServiceResponse::flattenResult) .map { StripeApi.SetupIntent(it.id, it.clientSecret) } + .doOnSuccess { + Log.d(TAG, "Got setup intent from Signal service!") + } } override fun setDefaultPaymentMethod(paymentMethodId: String): Completable { + Log.d(TAG, "Setting default payment method via Signal service...") return Single.fromCallable { SignalStore.donationsValues().requireSubscriber() }.flatMap { ApplicationDependencies.getDonationsService().setDefaultPaymentMethodId(it.subscriberId, paymentMethodId) - }.flatMap(ServiceResponse::flattenResult).ignoreElement() + }.flatMap(ServiceResponse::flattenResult).ignoreElement().doOnComplete { + Log.d(TAG, "Set default payment method via Signal service!") + } } companion object {