Skip to content

Commit

Permalink
Make external payment methods API public (#8466)
Browse files Browse the repository at this point in the history
* Expose external payment methods API

* Add params javadoc to FlowControllerCompose.kt

* formatting/small updates

* Update CHANGELOG.md

* fix typo

* update FlowControllerCompose and PaymentSheetCompose so that their changes are not binary incompatible

* update to use internal fn

* revert unnecessary change

* use builders for PS + FC

* simplify diff

* simplify diff

* simplify diff

* CI check updates

* Add more constructors instead of adding a builder
  • Loading branch information
amk-stripe committed May 17, 2024
1 parent 8eebff1 commit f6a4dec
Show file tree
Hide file tree
Showing 7 changed files with 345 additions and 49 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# CHANGELOG

## XX.XX.XX - 20XX-XX-XX
* [ADDED][8466](https://github.com/stripe/stripe-android/pull/8466) Added support for [external payment methods](https://docs.stripe.com/payments/external-payment-methods?platform=android).

## 20.43.0 - 2024-05-13

Expand Down
42 changes: 42 additions & 0 deletions paymentsheet/api/paymentsheet.api
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,19 @@ public abstract interface annotation class com/stripe/android/paymentsheet/Delic
public abstract interface annotation class com/stripe/android/paymentsheet/ExperimentalPaymentSheetDecouplingApi : java/lang/annotation/Annotation {
}

public abstract interface class com/stripe/android/paymentsheet/ExternalPaymentMethodConfirmHandler {
public abstract fun confirmExternalPaymentMethod (Ljava/lang/String;Lcom/stripe/android/model/PaymentMethod$BillingDetails;)V
}

public abstract class com/stripe/android/paymentsheet/ExternalPaymentMethodResult : android/os/Parcelable {
public static final field $stable I
public static final field Companion Lcom/stripe/android/paymentsheet/ExternalPaymentMethodResult$Companion;
public static final fun canceled ()Lcom/stripe/android/paymentsheet/ExternalPaymentMethodResult;
public static final fun completed ()Lcom/stripe/android/paymentsheet/ExternalPaymentMethodResult;
public static final fun failed ()Lcom/stripe/android/paymentsheet/ExternalPaymentMethodResult;
public static final fun failed (Ljava/lang/String;)Lcom/stripe/android/paymentsheet/ExternalPaymentMethodResult;
}

public final class com/stripe/android/paymentsheet/ExternalPaymentMethodResult$Canceled$Creator : android/os/Parcelable$Creator {
public fun <init> ()V
public final fun createFromParcel (Landroid/os/Parcel;)Lcom/stripe/android/paymentsheet/ExternalPaymentMethodResult$Canceled;
Expand All @@ -273,6 +286,14 @@ public final class com/stripe/android/paymentsheet/ExternalPaymentMethodResult$C
public synthetic fun newArray (I)[Ljava/lang/Object;
}

public final class com/stripe/android/paymentsheet/ExternalPaymentMethodResult$Companion {
public final fun canceled ()Lcom/stripe/android/paymentsheet/ExternalPaymentMethodResult;
public final fun completed ()Lcom/stripe/android/paymentsheet/ExternalPaymentMethodResult;
public final fun failed ()Lcom/stripe/android/paymentsheet/ExternalPaymentMethodResult;
public final fun failed (Ljava/lang/String;)Lcom/stripe/android/paymentsheet/ExternalPaymentMethodResult;
public static synthetic fun failed$default (Lcom/stripe/android/paymentsheet/ExternalPaymentMethodResult$Companion;Ljava/lang/String;ILjava/lang/Object;)Lcom/stripe/android/paymentsheet/ExternalPaymentMethodResult;
}

public final class com/stripe/android/paymentsheet/ExternalPaymentMethodResult$Completed$Creator : android/os/Parcelable$Creator {
public fun <init> ()V
public final fun createFromParcel (Landroid/os/Parcel;)Lcom/stripe/android/paymentsheet/ExternalPaymentMethodResult$Completed;
Expand All @@ -289,7 +310,14 @@ public final class com/stripe/android/paymentsheet/ExternalPaymentMethodResult$F
public synthetic fun newArray (I)[Ljava/lang/Object;
}

public final class com/stripe/android/paymentsheet/ExternalPaymentMethodResultHandler {
public static final field $stable I
public static final field INSTANCE Lcom/stripe/android/paymentsheet/ExternalPaymentMethodResultHandler;
public static final fun onExternalPaymentMethodResult (Landroid/content/Context;Lcom/stripe/android/paymentsheet/ExternalPaymentMethodResult;)V
}

public final class com/stripe/android/paymentsheet/FlowControllerComposeKt {
public static final fun rememberPaymentSheetFlowController (Lcom/stripe/android/paymentsheet/CreateIntentCallback;Lcom/stripe/android/paymentsheet/ExternalPaymentMethodConfirmHandler;Lcom/stripe/android/paymentsheet/PaymentOptionCallback;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;Landroidx/compose/runtime/Composer;II)Lcom/stripe/android/paymentsheet/PaymentSheet$FlowController;
public static final fun rememberPaymentSheetFlowController (Lcom/stripe/android/paymentsheet/CreateIntentCallback;Lcom/stripe/android/paymentsheet/PaymentOptionCallback;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;Landroidx/compose/runtime/Composer;I)Lcom/stripe/android/paymentsheet/PaymentSheet$FlowController;
public static final fun rememberPaymentSheetFlowController (Lcom/stripe/android/paymentsheet/PaymentOptionCallback;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;Landroidx/compose/runtime/Composer;I)Lcom/stripe/android/paymentsheet/PaymentSheet$FlowController;
}
Expand Down Expand Up @@ -341,9 +369,13 @@ public final class com/stripe/android/paymentsheet/PaymentOptionUiKt {
public final class com/stripe/android/paymentsheet/PaymentSheet {
public static final field $stable I
public static final field Companion Lcom/stripe/android/paymentsheet/PaymentSheet$Companion;
public fun <init> (Landroidx/activity/ComponentActivity;Lcom/stripe/android/paymentsheet/CreateIntentCallback;Lcom/stripe/android/paymentsheet/ExternalPaymentMethodConfirmHandler;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)V
public fun <init> (Landroidx/activity/ComponentActivity;Lcom/stripe/android/paymentsheet/CreateIntentCallback;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)V
public fun <init> (Landroidx/activity/ComponentActivity;Lcom/stripe/android/paymentsheet/ExternalPaymentMethodConfirmHandler;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)V
public fun <init> (Landroidx/activity/ComponentActivity;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)V
public fun <init> (Landroidx/fragment/app/Fragment;Lcom/stripe/android/paymentsheet/CreateIntentCallback;Lcom/stripe/android/paymentsheet/ExternalPaymentMethodConfirmHandler;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)V
public fun <init> (Landroidx/fragment/app/Fragment;Lcom/stripe/android/paymentsheet/CreateIntentCallback;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)V
public fun <init> (Landroidx/fragment/app/Fragment;Lcom/stripe/android/paymentsheet/ExternalPaymentMethodConfirmHandler;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)V
public fun <init> (Landroidx/fragment/app/Fragment;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)V
public final fun presentWithIntentConfiguration (Lcom/stripe/android/paymentsheet/PaymentSheet$IntentConfiguration;)V
public final fun presentWithIntentConfiguration (Lcom/stripe/android/paymentsheet/PaymentSheet$IntentConfiguration;Lcom/stripe/android/paymentsheet/PaymentSheet$Configuration;)V
Expand Down Expand Up @@ -655,6 +687,7 @@ public final class com/stripe/android/paymentsheet/PaymentSheet$Configuration$Bu
public final fun build ()Lcom/stripe/android/paymentsheet/PaymentSheet$Configuration;
public final fun customer (Lcom/stripe/android/paymentsheet/PaymentSheet$CustomerConfiguration;)Lcom/stripe/android/paymentsheet/PaymentSheet$Configuration$Builder;
public final fun defaultBillingDetails (Lcom/stripe/android/paymentsheet/PaymentSheet$BillingDetails;)Lcom/stripe/android/paymentsheet/PaymentSheet$Configuration$Builder;
public final fun externalPaymentMethods (Ljava/util/List;)Lcom/stripe/android/paymentsheet/PaymentSheet$Configuration$Builder;
public final fun googlePay (Lcom/stripe/android/paymentsheet/PaymentSheet$GooglePayConfiguration;)Lcom/stripe/android/paymentsheet/PaymentSheet$Configuration$Builder;
public final fun merchantDisplayName (Ljava/lang/String;)Lcom/stripe/android/paymentsheet/PaymentSheet$Configuration$Builder;
public final fun paymentMethodOrder (Ljava/util/List;)Lcom/stripe/android/paymentsheet/PaymentSheet$Configuration$Builder;
Expand Down Expand Up @@ -719,8 +752,12 @@ public abstract interface class com/stripe/android/paymentsheet/PaymentSheet$Flo
public abstract fun configureWithPaymentIntent (Ljava/lang/String;Lcom/stripe/android/paymentsheet/PaymentSheet$Configuration;Lcom/stripe/android/paymentsheet/PaymentSheet$FlowController$ConfigCallback;)V
public abstract fun configureWithSetupIntent (Ljava/lang/String;Lcom/stripe/android/paymentsheet/PaymentSheet$Configuration;Lcom/stripe/android/paymentsheet/PaymentSheet$FlowController$ConfigCallback;)V
public abstract fun confirm ()V
public static fun create (Landroidx/activity/ComponentActivity;Lcom/stripe/android/paymentsheet/ExternalPaymentMethodConfirmHandler;Lcom/stripe/android/paymentsheet/PaymentOptionCallback;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)Lcom/stripe/android/paymentsheet/PaymentSheet$FlowController;
public static fun create (Landroidx/activity/ComponentActivity;Lcom/stripe/android/paymentsheet/PaymentOptionCallback;Lcom/stripe/android/paymentsheet/CreateIntentCallback;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)Lcom/stripe/android/paymentsheet/PaymentSheet$FlowController;
public static fun create (Landroidx/activity/ComponentActivity;Lcom/stripe/android/paymentsheet/PaymentOptionCallback;Lcom/stripe/android/paymentsheet/ExternalPaymentMethodConfirmHandler;Lcom/stripe/android/paymentsheet/CreateIntentCallback;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)Lcom/stripe/android/paymentsheet/PaymentSheet$FlowController;
public static fun create (Landroidx/activity/ComponentActivity;Lcom/stripe/android/paymentsheet/PaymentOptionCallback;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)Lcom/stripe/android/paymentsheet/PaymentSheet$FlowController;
public static fun create (Landroidx/fragment/app/Fragment;Lcom/stripe/android/paymentsheet/ExternalPaymentMethodConfirmHandler;Lcom/stripe/android/paymentsheet/PaymentOptionCallback;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)Lcom/stripe/android/paymentsheet/PaymentSheet$FlowController;
public static fun create (Landroidx/fragment/app/Fragment;Lcom/stripe/android/paymentsheet/PaymentOptionCallback;Lcom/stripe/android/paymentsheet/CreateIntentCallback;Lcom/stripe/android/paymentsheet/ExternalPaymentMethodConfirmHandler;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)Lcom/stripe/android/paymentsheet/PaymentSheet$FlowController;
public static fun create (Landroidx/fragment/app/Fragment;Lcom/stripe/android/paymentsheet/PaymentOptionCallback;Lcom/stripe/android/paymentsheet/CreateIntentCallback;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)Lcom/stripe/android/paymentsheet/PaymentSheet$FlowController;
public static fun create (Landroidx/fragment/app/Fragment;Lcom/stripe/android/paymentsheet/PaymentOptionCallback;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)Lcom/stripe/android/paymentsheet/PaymentSheet$FlowController;
public abstract fun getPaymentOption ()Lcom/stripe/android/paymentsheet/model/PaymentOption;
Expand All @@ -730,8 +767,12 @@ public abstract interface class com/stripe/android/paymentsheet/PaymentSheet$Flo
}

public final class com/stripe/android/paymentsheet/PaymentSheet$FlowController$Companion {
public final fun create (Landroidx/activity/ComponentActivity;Lcom/stripe/android/paymentsheet/ExternalPaymentMethodConfirmHandler;Lcom/stripe/android/paymentsheet/PaymentOptionCallback;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)Lcom/stripe/android/paymentsheet/PaymentSheet$FlowController;
public final fun create (Landroidx/activity/ComponentActivity;Lcom/stripe/android/paymentsheet/PaymentOptionCallback;Lcom/stripe/android/paymentsheet/CreateIntentCallback;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)Lcom/stripe/android/paymentsheet/PaymentSheet$FlowController;
public final fun create (Landroidx/activity/ComponentActivity;Lcom/stripe/android/paymentsheet/PaymentOptionCallback;Lcom/stripe/android/paymentsheet/ExternalPaymentMethodConfirmHandler;Lcom/stripe/android/paymentsheet/CreateIntentCallback;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)Lcom/stripe/android/paymentsheet/PaymentSheet$FlowController;
public final fun create (Landroidx/activity/ComponentActivity;Lcom/stripe/android/paymentsheet/PaymentOptionCallback;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)Lcom/stripe/android/paymentsheet/PaymentSheet$FlowController;
public final fun create (Landroidx/fragment/app/Fragment;Lcom/stripe/android/paymentsheet/ExternalPaymentMethodConfirmHandler;Lcom/stripe/android/paymentsheet/PaymentOptionCallback;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)Lcom/stripe/android/paymentsheet/PaymentSheet$FlowController;
public final fun create (Landroidx/fragment/app/Fragment;Lcom/stripe/android/paymentsheet/PaymentOptionCallback;Lcom/stripe/android/paymentsheet/CreateIntentCallback;Lcom/stripe/android/paymentsheet/ExternalPaymentMethodConfirmHandler;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)Lcom/stripe/android/paymentsheet/PaymentSheet$FlowController;
public final fun create (Landroidx/fragment/app/Fragment;Lcom/stripe/android/paymentsheet/PaymentOptionCallback;Lcom/stripe/android/paymentsheet/CreateIntentCallback;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)Lcom/stripe/android/paymentsheet/PaymentSheet$FlowController;
public final fun create (Landroidx/fragment/app/Fragment;Lcom/stripe/android/paymentsheet/PaymentOptionCallback;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;)Lcom/stripe/android/paymentsheet/PaymentSheet$FlowController;
}
Expand Down Expand Up @@ -1129,6 +1170,7 @@ public final class com/stripe/android/paymentsheet/PaymentSheet$Typography$Creat
}

public final class com/stripe/android/paymentsheet/PaymentSheetComposeKt {
public static final fun rememberPaymentSheet (Lcom/stripe/android/paymentsheet/CreateIntentCallback;Lcom/stripe/android/paymentsheet/ExternalPaymentMethodConfirmHandler;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;Landroidx/compose/runtime/Composer;II)Lcom/stripe/android/paymentsheet/PaymentSheet;
public static final fun rememberPaymentSheet (Lcom/stripe/android/paymentsheet/CreateIntentCallback;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;Landroidx/compose/runtime/Composer;I)Lcom/stripe/android/paymentsheet/PaymentSheet;
public static final fun rememberPaymentSheet (Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;Landroidx/compose/runtime/Composer;I)Lcom/stripe/android/paymentsheet/PaymentSheet;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.stripe.android.paymentsheet

import androidx.annotation.RestrictTo
import com.stripe.android.model.PaymentMethod

/**
Expand All @@ -9,7 +8,6 @@ import com.stripe.android.model.PaymentMethod
* To learn more about external payment methods, see
* https://docs.stripe.com/payments/external-payment-methods?platform=android.
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
interface ExternalPaymentMethodConfirmHandler {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Parcelable
import androidx.annotation.RestrictTo
import com.stripe.android.core.exception.LocalStripeException
import com.stripe.android.payments.paymentlauncher.PaymentResult
import kotlinx.parcelize.IgnoredOnParcel
Expand All @@ -13,14 +12,14 @@ import kotlinx.parcelize.Parcelize
/**
* Handler used to respond to external payment method confirm results.
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
object ExternalPaymentMethodResultHandler {

/**
* Updates the PaymentSheet UI to reflect the result of confirming an external payment method.
*
* Should be called when [ExternalPaymentMethodConfirmHandler.confirmExternalPaymentMethod] completes.
*/
@JvmStatic
fun onExternalPaymentMethodResult(context: Context, externalPaymentMethodResult: ExternalPaymentMethodResult) {
context.startActivity(createResultIntent(context, externalPaymentMethodResult))
}
Expand All @@ -46,7 +45,6 @@ object ExternalPaymentMethodResultHandler {
/**
* The result of an attempt to confirm an external payment method.
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
sealed class ExternalPaymentMethodResult : Parcelable {

internal abstract fun toPaymentResult(): PaymentResult
Expand Down Expand Up @@ -84,14 +82,12 @@ sealed class ExternalPaymentMethodResult : Parcelable {
}
}

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
companion object {

/**
* The customer successfully completed the payment or setup.
*/
@JvmStatic
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
fun completed(): ExternalPaymentMethodResult {
return Completed
}
Expand All @@ -100,7 +96,6 @@ sealed class ExternalPaymentMethodResult : Parcelable {
* The customer canceled the payment or setup attempt.
*/
@JvmStatic
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
fun canceled(): ExternalPaymentMethodResult {
return Canceled
}
Expand All @@ -113,7 +108,6 @@ sealed class ExternalPaymentMethodResult : Parcelable {
*/
@JvmStatic
@JvmOverloads
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
fun failed(displayMessage: String? = null): ExternalPaymentMethodResult {
return Failed(displayMessage)
}
Expand Down

0 comments on commit f6a4dec

Please sign in to comment.