Add new error strings for credit cards.

This commit is contained in:
Alex Hart
2022-11-29 11:01:07 -04:00
committed by GitHub
parent f6356c9720
commit eee4ff3f87
14 changed files with 200 additions and 34 deletions
@@ -8,6 +8,7 @@ import org.json.JSONObject
class CreditCardPaymentSource(
private val payload: JSONObject
) : StripeApi.PaymentSource {
override val type = StripePaymentSourceType.CREDIT_CARD
override fun parameterize(): JSONObject = payload
override fun getTokenId(): String = parameterize().getString("id")
override fun email(): String? = null
@@ -4,6 +4,8 @@ import com.google.android.gms.wallet.PaymentData
import org.json.JSONObject
class GooglePayPaymentSource(private val paymentData: PaymentData) : StripeApi.PaymentSource {
override val type = StripePaymentSourceType.GOOGLE_PAY
override fun parameterize(): JSONObject {
val jsonData = JSONObject(paymentData.toJson())
val paymentMethodJsonData = jsonData.getJSONObject("paymentMethodData")
@@ -520,6 +520,7 @@ class StripeApi(
) : Parcelable
interface PaymentSource {
val type: StripePaymentSourceType
fun parameterize(): JSONObject
fun getTokenId(): String
fun email(): String?
@@ -0,0 +1,12 @@
package org.signal.donations
enum class StripePaymentSourceType(val code: String) {
CREDIT_CARD("credit_card"),
GOOGLE_PAY("google_pay");
companion object {
fun fromCode(code: String?): StripePaymentSourceType {
return values().firstOrNull { it.code == code } ?: GOOGLE_PAY
}
}
}