mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 20:48:43 +00:00
Rename DonationErrorSource value to ONE_TIME and document.
This commit is contained in:
committed by
Cody Henthorne
parent
073e138ab2
commit
940e67b1ca
@@ -40,7 +40,7 @@ class OneTimeDonationRepository(private val donationsService: DonationsService)
|
|||||||
Single.error(throwable)
|
Single.error(throwable)
|
||||||
} else {
|
} else {
|
||||||
val recipient = Recipient.resolved(badgeRecipient)
|
val recipient = Recipient.resolved(badgeRecipient)
|
||||||
val errorSource = if (recipient.isSelf) DonationErrorSource.BOOST else DonationErrorSource.GIFT
|
val errorSource = if (recipient.isSelf) DonationErrorSource.ONE_TIME else DonationErrorSource.GIFT
|
||||||
Single.error(DonationError.getPaymentSetupError(errorSource, throwable, paymentSourceType))
|
Single.error(DonationError.getPaymentSetupError(errorSource, throwable, paymentSourceType))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,7 +115,7 @@ class OneTimeDonationRepository(private val donationsService: DonationsService)
|
|||||||
): Completable {
|
): Completable {
|
||||||
val isLongRunning = paymentSourceType == PaymentSourceType.Stripe.SEPADebit
|
val isLongRunning = paymentSourceType == PaymentSourceType.Stripe.SEPADebit
|
||||||
val isBoost = gatewayRequest.recipientId == Recipient.self().id
|
val isBoost = gatewayRequest.recipientId == Recipient.self().id
|
||||||
val donationErrorSource: DonationErrorSource = if (isBoost) DonationErrorSource.BOOST else DonationErrorSource.GIFT
|
val donationErrorSource: DonationErrorSource = if (isBoost) DonationErrorSource.ONE_TIME else DonationErrorSource.GIFT
|
||||||
|
|
||||||
val waitOnRedemption = Completable.create {
|
val waitOnRedemption = Completable.create {
|
||||||
val donationReceiptRecord = if (isBoost) {
|
val donationReceiptRecord = if (isBoost) {
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ class StripeRepository(activity: Activity) : StripeApi.PaymentIntentFetcher, Str
|
|||||||
}
|
}
|
||||||
.flatMap { result ->
|
.flatMap { result ->
|
||||||
val recipient = Recipient.resolved(badgeRecipient)
|
val recipient = Recipient.resolved(badgeRecipient)
|
||||||
val errorSource = if (recipient.isSelf) DonationErrorSource.BOOST else DonationErrorSource.GIFT
|
val errorSource = if (recipient.isSelf) DonationErrorSource.ONE_TIME else DonationErrorSource.GIFT
|
||||||
|
|
||||||
Log.d(TAG, "Created payment intent for $price.", true)
|
Log.d(TAG, "Created payment intent for $price.", true)
|
||||||
when (result) {
|
when (result) {
|
||||||
@@ -131,7 +131,7 @@ class StripeRepository(activity: Activity) : StripeApi.PaymentIntentFetcher, Str
|
|||||||
badgeRecipient: RecipientId
|
badgeRecipient: RecipientId
|
||||||
): Single<StripeApi.Secure3DSAction> {
|
): Single<StripeApi.Secure3DSAction> {
|
||||||
val isBoost = badgeRecipient == Recipient.self().id
|
val isBoost = badgeRecipient == Recipient.self().id
|
||||||
val donationErrorSource: DonationErrorSource = if (isBoost) DonationErrorSource.BOOST else DonationErrorSource.GIFT
|
val donationErrorSource: DonationErrorSource = if (isBoost) DonationErrorSource.ONE_TIME else DonationErrorSource.GIFT
|
||||||
|
|
||||||
Log.d(TAG, "Confirming payment intent...", true)
|
Log.d(TAG, "Confirming payment intent...", true)
|
||||||
return stripeApi.confirmPaymentIntent(paymentSource, paymentIntent)
|
return stripeApi.confirmPaymentIntent(paymentSource, paymentIntent)
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ class DonateToSignalFragment :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun bindAdapter(adapter: MappingAdapter) {
|
override fun bindAdapter(adapter: MappingAdapter) {
|
||||||
donationCheckoutDelegate = DonationCheckoutDelegate(this, this, viewModel.uiSessionKey, DonationErrorSource.BOOST, DonationErrorSource.SUBSCRIPTION)
|
donationCheckoutDelegate = DonationCheckoutDelegate(this, this, viewModel.uiSessionKey, DonationErrorSource.ONE_TIME, DonationErrorSource.SUBSCRIPTION)
|
||||||
|
|
||||||
val recyclerView = this.recyclerView!!
|
val recyclerView = this.recyclerView!!
|
||||||
recyclerView.overScrollMode = RecyclerView.OVER_SCROLL_IF_CONTENT_SCROLLS
|
recyclerView.overScrollMode = RecyclerView.OVER_SCROLL_IF_CONTENT_SCROLLS
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ enum class DonateToSignalType(val requestCode: Short) : Parcelable {
|
|||||||
|
|
||||||
fun toErrorSource(): DonationErrorSource {
|
fun toErrorSource(): DonationErrorSource {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
ONE_TIME -> DonationErrorSource.BOOST
|
ONE_TIME -> DonationErrorSource.ONE_TIME
|
||||||
MONTHLY -> DonationErrorSource.SUBSCRIPTION
|
MONTHLY -> DonationErrorSource.SUBSCRIPTION
|
||||||
GIFT -> DonationErrorSource.GIFT
|
GIFT -> DonationErrorSource.GIFT
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ class DonationCheckoutDelegate(
|
|||||||
val error = DonationError.getGooglePayRequestTokenError(
|
val error = DonationError.getGooglePayRequestTokenError(
|
||||||
source = when (request.donateToSignalType) {
|
source = when (request.donateToSignalType) {
|
||||||
DonateToSignalType.MONTHLY -> DonationErrorSource.SUBSCRIPTION
|
DonateToSignalType.MONTHLY -> DonationErrorSource.SUBSCRIPTION
|
||||||
DonateToSignalType.ONE_TIME -> DonationErrorSource.BOOST
|
DonateToSignalType.ONE_TIME -> DonationErrorSource.ONE_TIME
|
||||||
DonateToSignalType.GIFT -> DonationErrorSource.GIFT
|
DonateToSignalType.GIFT -> DonationErrorSource.GIFT
|
||||||
},
|
},
|
||||||
throwable = googlePayException
|
throwable = googlePayException
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class CreditCardFragment : Fragment(R.layout.credit_card_fragment) {
|
|||||||
TemporaryScreenshotSecurity.bindToViewLifecycleOwner(this)
|
TemporaryScreenshotSecurity.bindToViewLifecycleOwner(this)
|
||||||
|
|
||||||
val errorSource: DonationErrorSource = when (args.request.donateToSignalType) {
|
val errorSource: DonationErrorSource = when (args.request.donateToSignalType) {
|
||||||
DonateToSignalType.ONE_TIME -> DonationErrorSource.BOOST
|
DonateToSignalType.ONE_TIME -> DonationErrorSource.ONE_TIME
|
||||||
DonateToSignalType.MONTHLY -> DonationErrorSource.SUBSCRIPTION
|
DonateToSignalType.MONTHLY -> DonationErrorSource.SUBSCRIPTION
|
||||||
DonateToSignalType.GIFT -> DonationErrorSource.GIFT
|
DonateToSignalType.GIFT -> DonationErrorSource.GIFT
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class StripePaymentInProgressViewModel(
|
|||||||
Log.d(TAG, "Proceeding with donation...", true)
|
Log.d(TAG, "Proceeding with donation...", true)
|
||||||
|
|
||||||
val errorSource = when (request.donateToSignalType) {
|
val errorSource = when (request.donateToSignalType) {
|
||||||
DonateToSignalType.ONE_TIME -> DonationErrorSource.BOOST
|
DonateToSignalType.ONE_TIME -> DonationErrorSource.ONE_TIME
|
||||||
DonateToSignalType.MONTHLY -> DonationErrorSource.SUBSCRIPTION
|
DonateToSignalType.MONTHLY -> DonationErrorSource.SUBSCRIPTION
|
||||||
DonateToSignalType.GIFT -> DonationErrorSource.GIFT
|
DonateToSignalType.GIFT -> DonationErrorSource.GIFT
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class BankTransferDetailsFragment : ComposeFragment(), DonationCheckoutDelegate.
|
|||||||
TemporaryScreenshotSecurity.bindToViewLifecycleOwner(this)
|
TemporaryScreenshotSecurity.bindToViewLifecycleOwner(this)
|
||||||
|
|
||||||
val errorSource: DonationErrorSource = when (args.request.donateToSignalType) {
|
val errorSource: DonationErrorSource = when (args.request.donateToSignalType) {
|
||||||
DonateToSignalType.ONE_TIME -> DonationErrorSource.BOOST
|
DonateToSignalType.ONE_TIME -> DonationErrorSource.ONE_TIME
|
||||||
DonateToSignalType.MONTHLY -> DonationErrorSource.SUBSCRIPTION
|
DonateToSignalType.MONTHLY -> DonationErrorSource.SUBSCRIPTION
|
||||||
DonateToSignalType.GIFT -> DonationErrorSource.GIFT
|
DonateToSignalType.GIFT -> DonationErrorSource.GIFT
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,36 @@
|
|||||||
package org.thoughtcrime.securesms.components.settings.app.subscription.errors
|
package org.thoughtcrime.securesms.components.settings.app.subscription.errors
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Descriptor of where an error originated from.
|
||||||
|
*/
|
||||||
enum class DonationErrorSource(private val code: String) {
|
enum class DonationErrorSource(private val code: String) {
|
||||||
BOOST("boost"),
|
/**
|
||||||
|
* Refers to a one-time donation where the user paying receives a badge immediately.
|
||||||
|
*/
|
||||||
|
ONE_TIME("boost"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refers to a recurring monthly donation where the user paying receives a badge immediately
|
||||||
|
* and upon each renewal period.
|
||||||
|
*/
|
||||||
SUBSCRIPTION("subscription"),
|
SUBSCRIPTION("subscription"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refers to a one-time donation where the user pays to send a badge to another individual.
|
||||||
|
*/
|
||||||
GIFT("gift"),
|
GIFT("gift"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refers to when the individual who received a gift token is redeeming it for a badge.
|
||||||
|
*/
|
||||||
GIFT_REDEMPTION("gift-redemption"),
|
GIFT_REDEMPTION("gift-redemption"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refers to the monthly keep-alive job for an active monthly subscriber, which is started in
|
||||||
|
* the background as needed.
|
||||||
|
*/
|
||||||
KEEP_ALIVE("keep-alive"),
|
KEEP_ALIVE("keep-alive"),
|
||||||
|
|
||||||
UNKNOWN("unknown");
|
UNKNOWN("unknown");
|
||||||
|
|
||||||
fun serialize(): String = code
|
fun serialize(): String = code
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class BoostReceiptRequestResponseJob extends BaseJob {
|
|||||||
private final boolean isLongRunningDonationPaymentType;
|
private final boolean isLongRunningDonationPaymentType;
|
||||||
|
|
||||||
private static String resolveQueue(DonationErrorSource donationErrorSource, boolean isLongRunning) {
|
private static String resolveQueue(DonationErrorSource donationErrorSource, boolean isLongRunning) {
|
||||||
String baseQueue = donationErrorSource == DonationErrorSource.BOOST ? BOOST_QUEUE : GIFT_QUEUE;
|
String baseQueue = donationErrorSource == DonationErrorSource.ONE_TIME ? BOOST_QUEUE : GIFT_QUEUE;
|
||||||
return isLongRunning ? baseQueue + LONG_RUNNING_SUFFIX : baseQueue;
|
return isLongRunning ? baseQueue + LONG_RUNNING_SUFFIX : baseQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ public class BoostReceiptRequestResponseJob extends BaseJob {
|
|||||||
long uiSessionKey,
|
long uiSessionKey,
|
||||||
boolean isLongRunning)
|
boolean isLongRunning)
|
||||||
{
|
{
|
||||||
BoostReceiptRequestResponseJob requestReceiptJob = createJob(paymentIntentId, DonationErrorSource.BOOST, Long.parseLong(SubscriptionLevels.BOOST_LEVEL), donationProcessor, uiSessionKey, isLongRunning);
|
BoostReceiptRequestResponseJob requestReceiptJob = createJob(paymentIntentId, DonationErrorSource.ONE_TIME, Long.parseLong(SubscriptionLevels.BOOST_LEVEL), donationProcessor, uiSessionKey, isLongRunning);
|
||||||
DonationReceiptRedemptionJob redeemReceiptJob = DonationReceiptRedemptionJob.createJobForBoost(uiSessionKey, isLongRunning);
|
DonationReceiptRedemptionJob redeemReceiptJob = DonationReceiptRedemptionJob.createJobForBoost(uiSessionKey, isLongRunning);
|
||||||
RefreshOwnProfileJob refreshOwnProfileJob = RefreshOwnProfileJob.forBoost();
|
RefreshOwnProfileJob refreshOwnProfileJob = RefreshOwnProfileJob.forBoost();
|
||||||
MultiDeviceProfileContentUpdateJob multiDeviceProfileContentUpdateJob = new MultiDeviceProfileContentUpdateJob();
|
MultiDeviceProfileContentUpdateJob multiDeviceProfileContentUpdateJob = new MultiDeviceProfileContentUpdateJob();
|
||||||
@@ -319,7 +319,7 @@ public class BoostReceiptRequestResponseJob extends BaseJob {
|
|||||||
JsonJobData data = JsonJobData.deserialize(serializedData);
|
JsonJobData data = JsonJobData.deserialize(serializedData);
|
||||||
|
|
||||||
String paymentIntentId = data.getString(DATA_PAYMENT_INTENT_ID);
|
String paymentIntentId = data.getString(DATA_PAYMENT_INTENT_ID);
|
||||||
DonationErrorSource donationErrorSource = DonationErrorSource.deserialize(data.getStringOrDefault(DATA_ERROR_SOURCE, DonationErrorSource.BOOST.serialize()));
|
DonationErrorSource donationErrorSource = DonationErrorSource.deserialize(data.getStringOrDefault(DATA_ERROR_SOURCE, DonationErrorSource.ONE_TIME.serialize()));
|
||||||
long badgeLevel = data.getLongOrDefault(DATA_BADGE_LEVEL, Long.parseLong(SubscriptionLevels.BOOST_LEVEL));
|
long badgeLevel = data.getLongOrDefault(DATA_BADGE_LEVEL, Long.parseLong(SubscriptionLevels.BOOST_LEVEL));
|
||||||
String rawDonationProcessor = data.getStringOrDefault(DATA_DONATION_PROCESSOR, DonationProcessor.STRIPE.getCode());
|
String rawDonationProcessor = data.getStringOrDefault(DATA_DONATION_PROCESSOR, DonationProcessor.STRIPE.getCode());
|
||||||
DonationProcessor donationProcessor = DonationProcessor.fromCode(rawDonationProcessor);
|
DonationProcessor donationProcessor = DonationProcessor.fromCode(rawDonationProcessor);
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public class DonationReceiptRedemptionJob extends BaseJob {
|
|||||||
return new DonationReceiptRedemptionJob(
|
return new DonationReceiptRedemptionJob(
|
||||||
NO_ID,
|
NO_ID,
|
||||||
false,
|
false,
|
||||||
DonationErrorSource.BOOST,
|
DonationErrorSource.ONE_TIME,
|
||||||
uiSessionKey,
|
uiSessionKey,
|
||||||
isLongRunningDonationPaymentType,
|
isLongRunningDonationPaymentType,
|
||||||
new Job.Parameters
|
new Job.Parameters
|
||||||
|
|||||||
Reference in New Issue
Block a user