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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Swish in PaymentSheet and bindings #7337

Merged
merged 10 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## XX.XX.XX - 2023-XX-XX

### PaymentSheet
* [ADDED][7337](https://github.com/stripe/stripe-android/pull/7337) PaymentSheet now supports Swish for PaymentIntents in private beta.

### Payments
* [ADDED][7337](https://github.com/stripe/stripe-android/pull/7337) Added support for Swish for PaymentIntents in private beta.

### Financial Connections
* [FIXED][7331](https://github.com/stripe/stripe-android/pull/7331) When cancelling out of a auth session, going back to the consent screen required two back taps.

Expand Down
1 change: 1 addition & 0 deletions example/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
<activity android:name=".activity.CashAppPayActivity"/>
<activity android:name=".activity.BlikPaymentMethodActivity"/>
<activity android:name=".activity.RevolutPayActivity"/>
<activity android:name=".activity.SwishExampleActivity"/>
</application>

</manifest>
1 change: 1 addition & 0 deletions example/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<string name="manual_us_bank_account_example">"Manual US Bank Account Example"</string>
<string name="cash_app_pay_example">Cash App Pay</string>
<string name="revolut_pay_example">Revolut Pay</string>
<string name="swish_example">Swish</string>
<string name="card_brands">Card Brands</string>
<string name="card_brands_hint">Card number</string>
<string name="possible_card_brands">Possible Card Brands</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ class LauncherActivity : AppCompatActivity() {
activity.getString(R.string.revolut_pay_example),
RevolutPayActivity::class.java
),
Item(
activity.getString(R.string.swish_example),
SwishExampleActivity::class.java
),
// This is for internal use so as not to confuse the user.
Item(
"StripeImage Example",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package com.stripe.example.activity

import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.Button
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.Divider
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.google.accompanist.themeadapter.material.MdcTheme
import com.stripe.android.model.PaymentMethodCreateParams

class SwishExampleActivity : StripeIntentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setContent {
val isProcessing by viewModel.inProgress.observeAsState(initial = false)
val status by viewModel.status.observeAsState(initial = "")

SwishScreen(
isProcessing = isProcessing,
status = status,
onButtonPressed = { payWithSwish() },
)
}
}

private fun payWithSwish() {
val params = PaymentMethodCreateParams.createSwish()

createAndConfirmPaymentIntent(
country = "FR",
currency = "SEK",
paymentMethodCreateParams = params,
supportedPaymentMethods = "swish",
)
}
}

@Composable
private fun SwishScreen(
isProcessing: Boolean,
status: String,
onButtonPressed: () -> Unit,
) {
MdcTheme {
Column(modifier = Modifier.fillMaxSize()) {
Row(verticalAlignment = Alignment.CenterVertically) {
Button(
onClick = onButtonPressed,
enabled = !isProcessing,
modifier = Modifier.padding(16.dp),
) {
Text("Pay with Swish")
}

if (isProcessing) {
CircularProgressIndicator(modifier = Modifier.size(24.dp))
}
}

if (status.isNotBlank()) {
Divider(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
)

Text(
text = status,
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
)
}
}
}
}
56 changes: 53 additions & 3 deletions payments-core/api/payments-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -3799,6 +3799,7 @@ public final class com/stripe/android/model/PaymentMethod$Type : java/lang/Enum,
public static final field RevolutPay Lcom/stripe/android/model/PaymentMethod$Type;
public static final field SepaDebit Lcom/stripe/android/model/PaymentMethod$Type;
public static final field Sofort Lcom/stripe/android/model/PaymentMethod$Type;
public static final field Swish Lcom/stripe/android/model/PaymentMethod$Type;
public static final field USBankAccount Lcom/stripe/android/model/PaymentMethod$Type;
public static final field Upi Lcom/stripe/android/model/PaymentMethod$Type;
public static final field WeChatPay Lcom/stripe/android/model/PaymentMethod$Type;
Expand Down Expand Up @@ -3968,12 +3969,13 @@ public final class com/stripe/android/model/PaymentMethodCreateParams : android/
public synthetic fun <init> (Lcom/stripe/android/model/PaymentMethodCreateParams$Netbanking;Lcom/stripe/android/model/PaymentMethod$BillingDetails;Ljava/util/Map;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Lcom/stripe/android/model/PaymentMethodCreateParams$SepaDebit;Lcom/stripe/android/model/PaymentMethod$BillingDetails;Ljava/util/Map;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Lcom/stripe/android/model/PaymentMethodCreateParams$Sofort;Lcom/stripe/android/model/PaymentMethod$BillingDetails;Ljava/util/Map;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Lcom/stripe/android/model/PaymentMethodCreateParams$Swish;Lcom/stripe/android/model/PaymentMethod$BillingDetails;Ljava/util/Map;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Lcom/stripe/android/model/PaymentMethodCreateParams$USBankAccount;Lcom/stripe/android/model/PaymentMethod$BillingDetails;Ljava/util/Map;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Lcom/stripe/android/model/PaymentMethodCreateParams$Upi;Lcom/stripe/android/model/PaymentMethod$BillingDetails;Ljava/util/Map;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component15 ()Lcom/stripe/android/model/PaymentMethod$BillingDetails;
public final fun component16 ()Lcom/stripe/android/model/PaymentMethod$BillingDetails;
public final fun component3 ()Lcom/stripe/android/model/PaymentMethodCreateParams$Card;
public final fun copy (Ljava/lang/String;ZLcom/stripe/android/model/PaymentMethodCreateParams$Card;Lcom/stripe/android/model/PaymentMethodCreateParams$Ideal;Lcom/stripe/android/model/PaymentMethodCreateParams$Fpx;Lcom/stripe/android/model/PaymentMethodCreateParams$SepaDebit;Lcom/stripe/android/model/PaymentMethodCreateParams$AuBecsDebit;Lcom/stripe/android/model/PaymentMethodCreateParams$BacsDebit;Lcom/stripe/android/model/PaymentMethodCreateParams$Sofort;Lcom/stripe/android/model/PaymentMethodCreateParams$Upi;Lcom/stripe/android/model/PaymentMethodCreateParams$Netbanking;Lcom/stripe/android/model/PaymentMethodCreateParams$USBankAccount;Lcom/stripe/android/model/PaymentMethodCreateParams$Link;Lcom/stripe/android/model/PaymentMethodCreateParams$CashAppPay;Lcom/stripe/android/model/PaymentMethod$BillingDetails;Ljava/util/Map;Ljava/util/Set;Ljava/util/Map;)Lcom/stripe/android/model/PaymentMethodCreateParams;
public static synthetic fun copy$default (Lcom/stripe/android/model/PaymentMethodCreateParams;Ljava/lang/String;ZLcom/stripe/android/model/PaymentMethodCreateParams$Card;Lcom/stripe/android/model/PaymentMethodCreateParams$Ideal;Lcom/stripe/android/model/PaymentMethodCreateParams$Fpx;Lcom/stripe/android/model/PaymentMethodCreateParams$SepaDebit;Lcom/stripe/android/model/PaymentMethodCreateParams$AuBecsDebit;Lcom/stripe/android/model/PaymentMethodCreateParams$BacsDebit;Lcom/stripe/android/model/PaymentMethodCreateParams$Sofort;Lcom/stripe/android/model/PaymentMethodCreateParams$Upi;Lcom/stripe/android/model/PaymentMethodCreateParams$Netbanking;Lcom/stripe/android/model/PaymentMethodCreateParams$USBankAccount;Lcom/stripe/android/model/PaymentMethodCreateParams$Link;Lcom/stripe/android/model/PaymentMethodCreateParams$CashAppPay;Lcom/stripe/android/model/PaymentMethod$BillingDetails;Ljava/util/Map;Ljava/util/Set;Ljava/util/Map;ILjava/lang/Object;)Lcom/stripe/android/model/PaymentMethodCreateParams;
public final fun copy (Ljava/lang/String;ZLcom/stripe/android/model/PaymentMethodCreateParams$Card;Lcom/stripe/android/model/PaymentMethodCreateParams$Ideal;Lcom/stripe/android/model/PaymentMethodCreateParams$Fpx;Lcom/stripe/android/model/PaymentMethodCreateParams$SepaDebit;Lcom/stripe/android/model/PaymentMethodCreateParams$AuBecsDebit;Lcom/stripe/android/model/PaymentMethodCreateParams$BacsDebit;Lcom/stripe/android/model/PaymentMethodCreateParams$Sofort;Lcom/stripe/android/model/PaymentMethodCreateParams$Upi;Lcom/stripe/android/model/PaymentMethodCreateParams$Netbanking;Lcom/stripe/android/model/PaymentMethodCreateParams$USBankAccount;Lcom/stripe/android/model/PaymentMethodCreateParams$Link;Lcom/stripe/android/model/PaymentMethodCreateParams$CashAppPay;Lcom/stripe/android/model/PaymentMethodCreateParams$Swish;Lcom/stripe/android/model/PaymentMethod$BillingDetails;Ljava/util/Map;Ljava/util/Set;Ljava/util/Map;)Lcom/stripe/android/model/PaymentMethodCreateParams;
public static synthetic fun copy$default (Lcom/stripe/android/model/PaymentMethodCreateParams;Ljava/lang/String;ZLcom/stripe/android/model/PaymentMethodCreateParams$Card;Lcom/stripe/android/model/PaymentMethodCreateParams$Ideal;Lcom/stripe/android/model/PaymentMethodCreateParams$Fpx;Lcom/stripe/android/model/PaymentMethodCreateParams$SepaDebit;Lcom/stripe/android/model/PaymentMethodCreateParams$AuBecsDebit;Lcom/stripe/android/model/PaymentMethodCreateParams$BacsDebit;Lcom/stripe/android/model/PaymentMethodCreateParams$Sofort;Lcom/stripe/android/model/PaymentMethodCreateParams$Upi;Lcom/stripe/android/model/PaymentMethodCreateParams$Netbanking;Lcom/stripe/android/model/PaymentMethodCreateParams$USBankAccount;Lcom/stripe/android/model/PaymentMethodCreateParams$Link;Lcom/stripe/android/model/PaymentMethodCreateParams$CashAppPay;Lcom/stripe/android/model/PaymentMethodCreateParams$Swish;Lcom/stripe/android/model/PaymentMethod$BillingDetails;Ljava/util/Map;Ljava/util/Set;Ljava/util/Map;ILjava/lang/Object;)Lcom/stripe/android/model/PaymentMethodCreateParams;
public static final fun create (Lcom/stripe/android/model/PaymentMethodCreateParams$AuBecsDebit;Lcom/stripe/android/model/PaymentMethod$BillingDetails;)Lcom/stripe/android/model/PaymentMethodCreateParams;
public static final fun create (Lcom/stripe/android/model/PaymentMethodCreateParams$AuBecsDebit;Lcom/stripe/android/model/PaymentMethod$BillingDetails;Ljava/util/Map;)Lcom/stripe/android/model/PaymentMethodCreateParams;
public static final fun create (Lcom/stripe/android/model/PaymentMethodCreateParams$BacsDebit;Lcom/stripe/android/model/PaymentMethod$BillingDetails;)Lcom/stripe/android/model/PaymentMethodCreateParams;
Expand Down Expand Up @@ -4038,6 +4040,9 @@ public final class com/stripe/android/model/PaymentMethodCreateParams : android/
public static final fun createRevolutPay ()Lcom/stripe/android/model/PaymentMethodCreateParams;
public static final fun createRevolutPay (Lcom/stripe/android/model/PaymentMethod$BillingDetails;)Lcom/stripe/android/model/PaymentMethodCreateParams;
public static final fun createRevolutPay (Lcom/stripe/android/model/PaymentMethod$BillingDetails;Ljava/util/Map;)Lcom/stripe/android/model/PaymentMethodCreateParams;
public static final fun createSwish ()Lcom/stripe/android/model/PaymentMethodCreateParams;
public static final fun createSwish (Lcom/stripe/android/model/PaymentMethod$BillingDetails;)Lcom/stripe/android/model/PaymentMethodCreateParams;
public static final fun createSwish (Lcom/stripe/android/model/PaymentMethod$BillingDetails;Ljava/util/Map;)Lcom/stripe/android/model/PaymentMethodCreateParams;
public static final fun createUSBankAccount ()Lcom/stripe/android/model/PaymentMethodCreateParams;
public static final fun createUSBankAccount (Lcom/stripe/android/model/PaymentMethod$BillingDetails;)Lcom/stripe/android/model/PaymentMethodCreateParams;
public static final fun createUSBankAccount (Lcom/stripe/android/model/PaymentMethod$BillingDetails;Ljava/util/Map;)Lcom/stripe/android/model/PaymentMethodCreateParams;
Expand Down Expand Up @@ -4254,6 +4259,10 @@ public final class com/stripe/android/model/PaymentMethodCreateParams$Companion
public final fun createRevolutPay (Lcom/stripe/android/model/PaymentMethod$BillingDetails;)Lcom/stripe/android/model/PaymentMethodCreateParams;
public final fun createRevolutPay (Lcom/stripe/android/model/PaymentMethod$BillingDetails;Ljava/util/Map;)Lcom/stripe/android/model/PaymentMethodCreateParams;
public static synthetic fun createRevolutPay$default (Lcom/stripe/android/model/PaymentMethodCreateParams$Companion;Lcom/stripe/android/model/PaymentMethod$BillingDetails;Ljava/util/Map;ILjava/lang/Object;)Lcom/stripe/android/model/PaymentMethodCreateParams;
public final fun createSwish ()Lcom/stripe/android/model/PaymentMethodCreateParams;
public final fun createSwish (Lcom/stripe/android/model/PaymentMethod$BillingDetails;)Lcom/stripe/android/model/PaymentMethodCreateParams;
public final fun createSwish (Lcom/stripe/android/model/PaymentMethod$BillingDetails;Ljava/util/Map;)Lcom/stripe/android/model/PaymentMethodCreateParams;
public static synthetic fun createSwish$default (Lcom/stripe/android/model/PaymentMethodCreateParams$Companion;Lcom/stripe/android/model/PaymentMethod$BillingDetails;Ljava/util/Map;ILjava/lang/Object;)Lcom/stripe/android/model/PaymentMethodCreateParams;
public final fun createUSBankAccount ()Lcom/stripe/android/model/PaymentMethodCreateParams;
public final fun createUSBankAccount (Lcom/stripe/android/model/PaymentMethod$BillingDetails;)Lcom/stripe/android/model/PaymentMethodCreateParams;
public final fun createUSBankAccount (Lcom/stripe/android/model/PaymentMethod$BillingDetails;Ljava/util/Map;)Lcom/stripe/android/model/PaymentMethodCreateParams;
Expand Down Expand Up @@ -4414,6 +4423,23 @@ public final class com/stripe/android/model/PaymentMethodCreateParams$Sofort$Cre
public synthetic fun newArray (I)[Ljava/lang/Object;
}

public final class com/stripe/android/model/PaymentMethodCreateParams$Swish : android/os/Parcelable, com/stripe/android/model/StripeParamsModel {
public static final field $stable I
public static final field CREATOR Landroid/os/Parcelable$Creator;
public fun <init> ()V
public fun describeContents ()I
public fun toParamMap ()Ljava/util/Map;
public fun writeToParcel (Landroid/os/Parcel;I)V
}

public final class com/stripe/android/model/PaymentMethodCreateParams$Swish$Creator : android/os/Parcelable$Creator {
public fun <init> ()V
public final fun createFromParcel (Landroid/os/Parcel;)Lcom/stripe/android/model/PaymentMethodCreateParams$Swish;
public synthetic fun createFromParcel (Landroid/os/Parcel;)Ljava/lang/Object;
public final fun newArray (I)[Lcom/stripe/android/model/PaymentMethodCreateParams$Swish;
public synthetic fun newArray (I)[Ljava/lang/Object;
}

public final class com/stripe/android/model/PaymentMethodCreateParams$USBankAccount : android/os/Parcelable, com/stripe/android/model/StripeParamsModel {
public static final field $stable I
public static final field CREATOR Landroid/os/Parcelable$Creator;
Expand Down Expand Up @@ -6210,6 +6236,29 @@ public final class com/stripe/android/model/StripeIntent$NextActionData$SdkData$
public synthetic fun newArray (I)[Ljava/lang/Object;
}

public final class com/stripe/android/model/StripeIntent$NextActionData$SwishRedirect : com/stripe/android/model/StripeIntent$NextActionData {
public static final field $stable I
public static final field CREATOR Landroid/os/Parcelable$Creator;
public fun <init> (Ljava/lang/String;)V
public final fun component1 ()Ljava/lang/String;
public final fun copy (Ljava/lang/String;)Lcom/stripe/android/model/StripeIntent$NextActionData$SwishRedirect;
public static synthetic fun copy$default (Lcom/stripe/android/model/StripeIntent$NextActionData$SwishRedirect;Ljava/lang/String;ILjava/lang/Object;)Lcom/stripe/android/model/StripeIntent$NextActionData$SwishRedirect;
public fun describeContents ()I
public fun equals (Ljava/lang/Object;)Z
public final fun getMobileAuthUrl ()Ljava/lang/String;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
public fun writeToParcel (Landroid/os/Parcel;I)V
}

public final class com/stripe/android/model/StripeIntent$NextActionData$SwishRedirect$Creator : android/os/Parcelable$Creator {
public fun <init> ()V
public final fun createFromParcel (Landroid/os/Parcel;)Lcom/stripe/android/model/StripeIntent$NextActionData$SwishRedirect;
public synthetic fun createFromParcel (Landroid/os/Parcel;)Ljava/lang/Object;
public final fun newArray (I)[Lcom/stripe/android/model/StripeIntent$NextActionData$SwishRedirect;
public synthetic fun newArray (I)[Ljava/lang/Object;
}

public final class com/stripe/android/model/StripeIntent$NextActionData$UpiAwaitNotification : com/stripe/android/model/StripeIntent$NextActionData {
public static final field $stable I
public static final field CREATOR Landroid/os/Parcelable$Creator;
Expand Down Expand Up @@ -6271,6 +6320,7 @@ public final class com/stripe/android/model/StripeIntent$NextActionType : java/l
public static final field DisplayKonbiniDetails Lcom/stripe/android/model/StripeIntent$NextActionType;
public static final field DisplayOxxoDetails Lcom/stripe/android/model/StripeIntent$NextActionType;
public static final field RedirectToUrl Lcom/stripe/android/model/StripeIntent$NextActionType;
public static final field SwishRedirect Lcom/stripe/android/model/StripeIntent$NextActionType;
public static final field UpiAwaitNotification Lcom/stripe/android/model/StripeIntent$NextActionType;
public static final field UseStripeSdk Lcom/stripe/android/model/StripeIntent$NextActionType;
public static final field VerifyWithMicrodeposits Lcom/stripe/android/model/StripeIntent$NextActionType;
Expand Down
1 change: 1 addition & 0 deletions payments-core/detekt-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<ID>ComplexCondition:ExpiryDateEditText.kt$ExpiryDateEditText.&lt;no name provided>$expirationDate.month.length == 2 &amp;&amp; latestInsertionSize > 0 &amp;&amp; !inErrorState || rawNumericInput.length > 2</ID>
<ID>ConstructorParameterNaming:Source.kt$Source$private val _klarna: Klarna? = null</ID>
<ID>ConstructorParameterNaming:Source.kt$Source$private val _weChat: WeChat? = null</ID>
<ID>CyclomaticComplexMethod:NextActionDataParser.kt$NextActionDataParser$override fun parse( json: JSONObject ): StripeIntent.NextActionData?</ID>
<ID>CyclomaticComplexMethod:PaymentMethodJsonParser.kt$PaymentMethodJsonParser$override fun parse(json: JSONObject): PaymentMethod</ID>
<ID>CyclomaticComplexMethod:Source.kt$Source.Companion$@SourceType @JvmStatic fun asSourceType(sourceType: String?): String</ID>
<ID>CyclomaticComplexMethod:SourceJsonParser.kt$SourceJsonParser.Companion$@Source.SourceType private fun asSourceType(sourceType: String?): String</ID>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ abstract class StripeIntentResult<out T : StripeIntent> internal constructor(
StripeIntent.NextActionType.AlipayRedirect,
StripeIntent.NextActionType.WeChatPayRedirect,
StripeIntent.NextActionType.CashAppRedirect,
StripeIntent.NextActionType.SwishRedirect,
null -> {
false
}
Expand Down
Loading
Loading