Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add country code to PaymentIntent and SetupIntent #5472

Merged
merged 5 commits into from Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
53 changes: 29 additions & 24 deletions payments-core/api/payments-core.api
Expand Up @@ -3152,29 +3152,30 @@ public final class com/stripe/android/model/PaymentIntent : com/stripe/android/m
public static final field CREATOR Landroid/os/Parcelable$Creator;
public static final field Companion Lcom/stripe/android/model/PaymentIntent$Companion;
public final fun component1 ()Ljava/lang/String;
public final fun component10 ()Ljava/lang/String;
public final fun component10 ()J
public final fun component11 ()Ljava/lang/String;
public final fun component12 ()Z
public final fun component13 ()Lcom/stripe/android/model/PaymentMethod;
public final fun component14 ()Ljava/lang/String;
public final fun component12 ()Ljava/lang/String;
public final fun component13 ()Z
public final fun component14 ()Lcom/stripe/android/model/PaymentMethod;
public final fun component15 ()Ljava/lang/String;
public final fun component16 ()Lcom/stripe/android/model/StripeIntent$Status;
public final fun component17 ()Lcom/stripe/android/model/StripeIntent$Usage;
public final fun component18 ()Lcom/stripe/android/model/PaymentIntent$Error;
public final fun component19 ()Lcom/stripe/android/model/PaymentIntent$Shipping;
public final fun component16 ()Ljava/lang/String;
public final fun component17 ()Lcom/stripe/android/model/StripeIntent$Status;
public final fun component18 ()Lcom/stripe/android/model/StripeIntent$Usage;
public final fun component19 ()Lcom/stripe/android/model/PaymentIntent$Error;
public final fun component2 ()Ljava/util/List;
public final fun component20 ()Ljava/util/List;
public final fun component20 ()Lcom/stripe/android/model/PaymentIntent$Shipping;
public final fun component21 ()Ljava/util/List;
public final fun component22 ()Lcom/stripe/android/model/StripeIntent$NextActionData;
public final fun component22 ()Ljava/util/List;
public final fun component23 ()Lcom/stripe/android/model/StripeIntent$NextActionData;
public final fun component3 ()Ljava/lang/Long;
public final fun component4 ()J
public final fun component5 ()Lcom/stripe/android/model/PaymentIntent$CancellationReason;
public final fun component6 ()Lcom/stripe/android/model/PaymentIntent$CaptureMethod;
public final fun component7 ()Ljava/lang/String;
public final fun component8 ()Lcom/stripe/android/model/PaymentIntent$ConfirmationMethod;
public final fun component9 ()J
public final fun copy (Ljava/lang/String;Ljava/util/List;Ljava/lang/Long;JLcom/stripe/android/model/PaymentIntent$CancellationReason;Lcom/stripe/android/model/PaymentIntent$CaptureMethod;Ljava/lang/String;Lcom/stripe/android/model/PaymentIntent$ConfirmationMethod;JLjava/lang/String;Ljava/lang/String;ZLcom/stripe/android/model/PaymentMethod;Ljava/lang/String;Ljava/lang/String;Lcom/stripe/android/model/StripeIntent$Status;Lcom/stripe/android/model/StripeIntent$Usage;Lcom/stripe/android/model/PaymentIntent$Error;Lcom/stripe/android/model/PaymentIntent$Shipping;Ljava/util/List;Ljava/util/List;Lcom/stripe/android/model/StripeIntent$NextActionData;Ljava/lang/String;)Lcom/stripe/android/model/PaymentIntent;
public static synthetic fun copy$default (Lcom/stripe/android/model/PaymentIntent;Ljava/lang/String;Ljava/util/List;Ljava/lang/Long;JLcom/stripe/android/model/PaymentIntent$CancellationReason;Lcom/stripe/android/model/PaymentIntent$CaptureMethod;Ljava/lang/String;Lcom/stripe/android/model/PaymentIntent$ConfirmationMethod;JLjava/lang/String;Ljava/lang/String;ZLcom/stripe/android/model/PaymentMethod;Ljava/lang/String;Ljava/lang/String;Lcom/stripe/android/model/StripeIntent$Status;Lcom/stripe/android/model/StripeIntent$Usage;Lcom/stripe/android/model/PaymentIntent$Error;Lcom/stripe/android/model/PaymentIntent$Shipping;Ljava/util/List;Ljava/util/List;Lcom/stripe/android/model/StripeIntent$NextActionData;Ljava/lang/String;ILjava/lang/Object;)Lcom/stripe/android/model/PaymentIntent;
public final fun component9 ()Ljava/lang/String;
public final fun copy (Ljava/lang/String;Ljava/util/List;Ljava/lang/Long;JLcom/stripe/android/model/PaymentIntent$CancellationReason;Lcom/stripe/android/model/PaymentIntent$CaptureMethod;Ljava/lang/String;Lcom/stripe/android/model/PaymentIntent$ConfirmationMethod;Ljava/lang/String;JLjava/lang/String;Ljava/lang/String;ZLcom/stripe/android/model/PaymentMethod;Ljava/lang/String;Ljava/lang/String;Lcom/stripe/android/model/StripeIntent$Status;Lcom/stripe/android/model/StripeIntent$Usage;Lcom/stripe/android/model/PaymentIntent$Error;Lcom/stripe/android/model/PaymentIntent$Shipping;Ljava/util/List;Ljava/util/List;Lcom/stripe/android/model/StripeIntent$NextActionData;Ljava/lang/String;)Lcom/stripe/android/model/PaymentIntent;
public static synthetic fun copy$default (Lcom/stripe/android/model/PaymentIntent;Ljava/lang/String;Ljava/util/List;Ljava/lang/Long;JLcom/stripe/android/model/PaymentIntent$CancellationReason;Lcom/stripe/android/model/PaymentIntent$CaptureMethod;Ljava/lang/String;Lcom/stripe/android/model/PaymentIntent$ConfirmationMethod;Ljava/lang/String;JLjava/lang/String;Ljava/lang/String;ZLcom/stripe/android/model/PaymentMethod;Ljava/lang/String;Ljava/lang/String;Lcom/stripe/android/model/StripeIntent$Status;Lcom/stripe/android/model/StripeIntent$Usage;Lcom/stripe/android/model/PaymentIntent$Error;Lcom/stripe/android/model/PaymentIntent$Shipping;Ljava/util/List;Ljava/util/List;Lcom/stripe/android/model/StripeIntent$NextActionData;Ljava/lang/String;ILjava/lang/Object;)Lcom/stripe/android/model/PaymentIntent;
public fun describeContents ()I
public fun equals (Ljava/lang/Object;)Z
public static final fun fromJson (Lorg/json/JSONObject;)Lcom/stripe/android/model/PaymentIntent;
Expand All @@ -3184,6 +3185,7 @@ public final class com/stripe/android/model/PaymentIntent : com/stripe/android/m
public final fun getCaptureMethod ()Lcom/stripe/android/model/PaymentIntent$CaptureMethod;
public fun getClientSecret ()Ljava/lang/String;
public final fun getConfirmationMethod ()Lcom/stripe/android/model/PaymentIntent$ConfirmationMethod;
public fun getCountryCode ()Ljava/lang/String;
public fun getCreated ()J
public final fun getCurrency ()Ljava/lang/String;
public fun getDescription ()Ljava/lang/String;
Expand Down Expand Up @@ -4820,27 +4822,29 @@ public final class com/stripe/android/model/SetupIntent : com/stripe/android/mod
public static final field CREATOR Landroid/os/Parcelable$Creator;
public static final field Companion Lcom/stripe/android/model/SetupIntent$Companion;
public final fun component1 ()Ljava/lang/String;
public final fun component10 ()Lcom/stripe/android/model/StripeIntent$Status;
public final fun component11 ()Lcom/stripe/android/model/StripeIntent$Usage;
public final fun component12 ()Lcom/stripe/android/model/SetupIntent$Error;
public final fun component13 ()Ljava/util/List;
public final fun component10 ()Ljava/util/List;
public final fun component11 ()Lcom/stripe/android/model/StripeIntent$Status;
public final fun component12 ()Lcom/stripe/android/model/StripeIntent$Usage;
public final fun component13 ()Lcom/stripe/android/model/SetupIntent$Error;
public final fun component14 ()Ljava/util/List;
public final fun component15 ()Lcom/stripe/android/model/StripeIntent$NextActionData;
public final fun component15 ()Ljava/util/List;
public final fun component16 ()Lcom/stripe/android/model/StripeIntent$NextActionData;
public final fun component2 ()Lcom/stripe/android/model/SetupIntent$CancellationReason;
public final fun component3 ()J
public final fun component4 ()Ljava/lang/String;
public final fun component5 ()Ljava/lang/String;
public final fun component6 ()Z
public final fun component7 ()Lcom/stripe/android/model/PaymentMethod;
public final fun component8 ()Ljava/lang/String;
public final fun component9 ()Ljava/util/List;
public final fun copy (Ljava/lang/String;Lcom/stripe/android/model/SetupIntent$CancellationReason;JLjava/lang/String;Ljava/lang/String;ZLcom/stripe/android/model/PaymentMethod;Ljava/lang/String;Ljava/util/List;Lcom/stripe/android/model/StripeIntent$Status;Lcom/stripe/android/model/StripeIntent$Usage;Lcom/stripe/android/model/SetupIntent$Error;Ljava/util/List;Ljava/util/List;Lcom/stripe/android/model/StripeIntent$NextActionData;)Lcom/stripe/android/model/SetupIntent;
public static synthetic fun copy$default (Lcom/stripe/android/model/SetupIntent;Ljava/lang/String;Lcom/stripe/android/model/SetupIntent$CancellationReason;JLjava/lang/String;Ljava/lang/String;ZLcom/stripe/android/model/PaymentMethod;Ljava/lang/String;Ljava/util/List;Lcom/stripe/android/model/StripeIntent$Status;Lcom/stripe/android/model/StripeIntent$Usage;Lcom/stripe/android/model/SetupIntent$Error;Ljava/util/List;Ljava/util/List;Lcom/stripe/android/model/StripeIntent$NextActionData;ILjava/lang/Object;)Lcom/stripe/android/model/SetupIntent;
public final fun component6 ()Ljava/lang/String;
public final fun component7 ()Z
public final fun component8 ()Lcom/stripe/android/model/PaymentMethod;
public final fun component9 ()Ljava/lang/String;
public final fun copy (Ljava/lang/String;Lcom/stripe/android/model/SetupIntent$CancellationReason;JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLcom/stripe/android/model/PaymentMethod;Ljava/lang/String;Ljava/util/List;Lcom/stripe/android/model/StripeIntent$Status;Lcom/stripe/android/model/StripeIntent$Usage;Lcom/stripe/android/model/SetupIntent$Error;Ljava/util/List;Ljava/util/List;Lcom/stripe/android/model/StripeIntent$NextActionData;)Lcom/stripe/android/model/SetupIntent;
public static synthetic fun copy$default (Lcom/stripe/android/model/SetupIntent;Ljava/lang/String;Lcom/stripe/android/model/SetupIntent$CancellationReason;JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLcom/stripe/android/model/PaymentMethod;Ljava/lang/String;Ljava/util/List;Lcom/stripe/android/model/StripeIntent$Status;Lcom/stripe/android/model/StripeIntent$Usage;Lcom/stripe/android/model/SetupIntent$Error;Ljava/util/List;Ljava/util/List;Lcom/stripe/android/model/StripeIntent$NextActionData;ILjava/lang/Object;)Lcom/stripe/android/model/SetupIntent;
public fun describeContents ()I
public fun equals (Ljava/lang/Object;)Z
public static final fun fromJson (Lorg/json/JSONObject;)Lcom/stripe/android/model/SetupIntent;
public final fun getCancellationReason ()Lcom/stripe/android/model/SetupIntent$CancellationReason;
public fun getClientSecret ()Ljava/lang/String;
public fun getCountryCode ()Ljava/lang/String;
public fun getCreated ()J
public fun getDescription ()Ljava/lang/String;
public fun getId ()Ljava/lang/String;
Expand Down Expand Up @@ -5920,6 +5924,7 @@ public final class com/stripe/android/model/Stripe3ds2Fingerprint$DirectoryServe

public abstract interface class com/stripe/android/model/StripeIntent : com/stripe/android/core/model/StripeModel {
public abstract fun getClientSecret ()Ljava/lang/String;
public abstract fun getCountryCode ()Ljava/lang/String;
public abstract fun getCreated ()J
public abstract fun getDescription ()Ljava/lang/String;
public abstract fun getId ()Ljava/lang/String;
Expand Down
Expand Up @@ -81,6 +81,11 @@ data class PaymentIntent internal constructor(
*/
val confirmationMethod: ConfirmationMethod = ConfirmationMethod.Automatic,

/**
* Country code of the user.
*/
override val countryCode: String?,

/**
* Time at which the object was created. Measured in seconds since the Unix epoch.
*/
Expand Down
Expand Up @@ -30,6 +30,11 @@ data class SetupIntent internal constructor(
*/
override val created: Long,

/**
* Country code of the user.
*/
override val countryCode: String?,

/**
* The client secret of this SetupIntent. Used for client-side retrieval using a
* publishable key.
Expand Down
Expand Up @@ -21,6 +21,11 @@ sealed interface StripeIntent : StripeModel {
*/
val created: Long

/**
* Country code of the user.
*/
val countryCode: String?

/**
* An arbitrary string attached to the object. Often useful for displaying to users.
*/
Expand Down
Expand Up @@ -90,6 +90,8 @@ class PaymentIntentJsonParser(
val linkFundingSources = jsonArrayToList(json.optJSONArray(FIELD_LINK_FUNDING_SOURCES))
.map { it.lowercase() }

val countryCode = optString(json, FIELD_COUNTRY_CODE)

return PaymentIntent(
id = id,
paymentMethodTypes = paymentMethodTypes,
Expand All @@ -99,6 +101,7 @@ class PaymentIntentJsonParser(
captureMethod = captureMethod,
clientSecret = clientSecret,
confirmationMethod = confirmationMethod,
countryCode = countryCode,
created = created,
currency = currency,
description = description,
Expand Down Expand Up @@ -181,6 +184,7 @@ class PaymentIntentJsonParser(
private const val FIELD_CAPTURE_METHOD = "capture_method"
private const val FIELD_CLIENT_SECRET = "client_secret"
private const val FIELD_CONFIRMATION_METHOD = "confirmation_method"
private const val FIELD_COUNTRY_CODE = "country_code"
private const val FIELD_CURRENCY = "currency"
private const val FIELD_DESCRIPTION = "description"
private const val FIELD_LAST_PAYMENT_ERROR = "last_payment_error"
Expand Down
Expand Up @@ -22,6 +22,8 @@ internal sealed class PaymentMethodPreferenceJsonParser<StripeIntentType : Strip
return null
}

val countryCode = paymentMethodPreference.optString(FIELD_COUNTRY_CODE)

val paymentMethodSpecs = json.optJSONArray(FIELD_TYPE_PAYMENT_METHOD_SCHEMA)

val linkFundingSources =
Expand Down Expand Up @@ -49,6 +51,10 @@ internal sealed class PaymentMethodPreferenceJsonParser<StripeIntentType : Strip
FIELD_LINK_FUNDING_SOURCES,
linkFundingSources
)
stripeIntentJsonObject.put(
FIELD_COUNTRY_CODE,
countryCode
)
parseStripeIntent(stripeIntentJsonObject)
}?.let {
PaymentMethodPreference(
Expand All @@ -64,6 +70,7 @@ internal sealed class PaymentMethodPreferenceJsonParser<StripeIntentType : Strip
private const val OBJECT_TYPE_PREFERENCE = "payment_method_preference"

private const val FIELD_OBJECT = "object"
private const val FIELD_COUNTRY_CODE = "country_code"
private const val FIELD_ORDERED_PAYMENT_METHOD_TYPES = "ordered_payment_method_types"
private const val FIELD_PAYMENT_METHOD_TYPES = "payment_method_types"
private const val FIELD_UNACTIVATED_PAYMENT_METHOD_TYPES =
Expand Down
Expand Up @@ -37,6 +37,7 @@ class SetupIntentJsonParser : ModelJsonParser<SetupIntent> {
cancellationReason = SetupIntent.CancellationReason.fromCode(
optString(json, FIELD_CANCELLATION_REASON)
),
countryCode = optString(json, FIELD_COUNTRY_CODE),
description = optString(json, FIELD_DESCRIPTION),
isLiveMode = json.optBoolean(FIELD_LIVEMODE),
paymentMethod = paymentMethod,
Expand Down Expand Up @@ -91,6 +92,7 @@ class SetupIntentJsonParser : ModelJsonParser<SetupIntent> {
private const val FIELD_CANCELLATION_REASON = "cancellation_reason"
private const val FIELD_CREATED = "created"
private const val FIELD_CLIENT_SECRET = "client_secret"
private const val FIELD_COUNTRY_CODE = "country_code"
private const val FIELD_DESCRIPTION = "description"
private const val FIELD_LAST_SETUP_ERROR = "last_setup_error"
private const val FIELD_LIVEMODE = "livemode"
Expand Down
Expand Up @@ -26,6 +26,7 @@ class PaymentIntentResultTest {
isLiveMode = false,
id = "pi_12345",
currency = "usd",
countryCode = null,
paymentMethodTypes = listOf(PaymentMethod.Type.Oxxo.code),
status = StripeIntent.Status.Processing,
unactivatedPaymentMethods = emptyList(),
Expand Down Expand Up @@ -69,6 +70,7 @@ class PaymentIntentResultTest {
isLiveMode = false,
id = "pi_12345",
currency = "usd",
countryCode = null,
paymentMethodTypes = listOf("card"),
status = StripeIntent.Status.Processing,
unactivatedPaymentMethods = emptyList()
Expand All @@ -90,6 +92,7 @@ class PaymentIntentResultTest {
isLiveMode = false,
id = "pi_12345",
currency = "usd",
countryCode = null,
paymentMethodTypes = listOf(PaymentMethod.Type.Oxxo.code),
status = StripeIntent.Status.Processing,
unactivatedPaymentMethods = emptyList(),
Expand All @@ -112,6 +115,7 @@ class PaymentIntentResultTest {
isLiveMode = false,
id = "pi_12345",
currency = "usd",
countryCode = null,
paymentMethodTypes = listOf(PaymentMethod.Type.USBankAccount.code),
status = StripeIntent.Status.RequiresAction,
unactivatedPaymentMethods = emptyList(),
Expand All @@ -138,6 +142,7 @@ class PaymentIntentResultTest {
isLiveMode = false,
id = "pi_12345",
currency = "usd",
countryCode = null,
paymentMethodTypes = listOf("card"),
status = StripeIntent.Status.Processing,
unactivatedPaymentMethods = emptyList()
Expand Down