mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 13:08:46 +00:00
Implement start of backups payment integration work.
This commit is contained in:
committed by
Greyson Parrelli
parent
680223c4b6
commit
6b50be78c0
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2024 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.signal.donations
|
||||
|
||||
import org.signal.core.util.Serializer
|
||||
|
||||
enum class InAppPaymentType(val code: Int, val recurring: Boolean) {
|
||||
/**
|
||||
* Used explicitly for mapping DonationErrorSource. Writing this value
|
||||
* into an InAppPayment is an error.
|
||||
*/
|
||||
UNKNOWN(-1, false),
|
||||
|
||||
/**
|
||||
* This payment is for a gift badge
|
||||
*/
|
||||
ONE_TIME_GIFT(0, false),
|
||||
|
||||
/**
|
||||
* This payment is for a one-time donation
|
||||
*/
|
||||
ONE_TIME_DONATION(1, false),
|
||||
|
||||
/**
|
||||
* This payment is for a recurring donation
|
||||
*/
|
||||
RECURRING_DONATION(2, true),
|
||||
|
||||
/**
|
||||
* This payment is for a recurring backup payment
|
||||
*/
|
||||
RECURRING_BACKUP(3, true);
|
||||
|
||||
companion object : Serializer<InAppPaymentType, Int> {
|
||||
override fun serialize(data: InAppPaymentType): Int = data.code
|
||||
override fun deserialize(input: Int): InAppPaymentType = entries.first { it.code == input }
|
||||
}
|
||||
}
|
||||
@@ -62,9 +62,9 @@ class StripeApi(
|
||||
data class Failure(val reason: Throwable) : CreatePaymentSourceFromCardDataResult()
|
||||
}
|
||||
|
||||
fun createSetupIntent(sourceType: PaymentSourceType.Stripe): Single<CreateSetupIntentResult> {
|
||||
fun createSetupIntent(inAppPaymentType: InAppPaymentType, sourceType: PaymentSourceType.Stripe): Single<CreateSetupIntentResult> {
|
||||
return setupIntentHelper
|
||||
.fetchSetupIntent(sourceType)
|
||||
.fetchSetupIntent(inAppPaymentType, sourceType)
|
||||
.map { CreateSetupIntentResult(it) }
|
||||
.subscribeOn(Schedulers.io())
|
||||
}
|
||||
@@ -588,6 +588,7 @@ class StripeApi(
|
||||
|
||||
interface SetupIntentHelper {
|
||||
fun fetchSetupIntent(
|
||||
inAppPaymentType: InAppPaymentType,
|
||||
sourceType: PaymentSourceType.Stripe
|
||||
): Single<StripeIntentAccessor>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user