Implement start of backups payment integration work.

This commit is contained in:
Alex Hart
2024-05-29 16:48:33 -03:00
committed by Greyson Parrelli
parent 680223c4b6
commit 6b50be78c0
81 changed files with 1492 additions and 1141 deletions

View File

@@ -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 }
}
}

View File

@@ -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>
}