mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-08 09:18:39 +01:00
Add new error strings for credit cards.
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user