Skip to content

Commit

Permalink
Enable specifying Payment Method type to use in UI components (#1738)
Browse files Browse the repository at this point in the history
- Make `PaymentSessionConfig#setPaymentMethodTypes()` public
- Make `PaymentMethodsActivityStarter.Args.Builder#setPaymentMethodTypes()` public
- Make `AddPaymentMethodActivityStarter.Args.Builder#setPaymentMethodType()` public
  • Loading branch information
mshafrir-stripe authored Oct 22, 2019
1 parent 6c3956f commit 54ec498
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
11 changes: 8 additions & 3 deletions stripe/src/main/java/com/stripe/android/PaymentSessionConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,18 @@ data class PaymentSessionConfig internal constructor(
return this
}

// TODO(mshafrir-stripe): make public
/**
* @param paymentMethodTypes a list of [PaymentMethod.Type] that indicates the types of
* Payment Methods that the customer can select or add via the Stripe UI components.
* Payment Methods that the customer can select or add via Stripe UI components.
*
* The order of the [PaymentMethod.Type] values in the list will be used to
* arrange the add buttons in the Stripe UI components. They will be arranged vertically
* from first to last.
*
* Currently only [PaymentMethod.Type.Card] and [PaymentMethod.Type.Fpx] are supported.
* If not specified or empty, [PaymentMethod.Type.Card] will be used.
*/
internal fun setPaymentMethodTypes(paymentMethodTypes: List<PaymentMethod.Type>): Builder {
fun setPaymentMethodTypes(paymentMethodTypes: List<PaymentMethod.Type>): Builder {
this.paymentMethodTypes = paymentMethodTypes
return this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class AddPaymentMethodActivityStarter internal constructor(
private var shouldRequirePostalCode: Boolean = false
private var isPaymentSessionActive = false
private var shouldInitCustomerSessionTokens = true
private var paymentMethodType: PaymentMethod.Type? = null
private var paymentMethodType: PaymentMethod.Type? = PaymentMethod.Type.Card
private var paymentConfiguration: PaymentConfiguration? = null
@LayoutRes
private var addPaymentMethodFooter: Int = 0
Expand All @@ -65,6 +65,17 @@ class AddPaymentMethodActivityStarter internal constructor(
return this
}

/**
* Optional: specify the [PaymentMethod.Type] of the payment method to create based on
* the customer's input (i.e. the form that will be presented to the customer).
* If unspecified, defaults to [PaymentMethod.Type.Card].
* Currently only [PaymentMethod.Type.Card] and [PaymentMethod.Type.Fpx] are supported.
*/
fun setPaymentMethodType(paymentMethodType: PaymentMethod.Type): Builder {
this.paymentMethodType = paymentMethodType
return this
}

internal fun setIsPaymentSessionActive(isPaymentSessionActive: Boolean): Builder {
this.isPaymentSessionActive = isPaymentSessionActive
return this
Expand All @@ -77,11 +88,6 @@ class AddPaymentMethodActivityStarter internal constructor(
return this
}

internal fun setPaymentMethodType(paymentMethodType: PaymentMethod.Type): Builder {
this.paymentMethodType = paymentMethodType
return this
}

internal fun setPaymentConfiguration(
paymentConfiguration: PaymentConfiguration?
): Builder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,18 @@ class PaymentMethodsActivityStarter : ActivityStarter<PaymentMethodsActivity, Ar
return this
}

internal fun setPaymentMethodTypes(
/**
* @param paymentMethodTypes a list of [PaymentMethod.Type] that indicates the types of
* Payment Methods that the customer can select or add via Stripe UI components.
*
* The order of the [PaymentMethod.Type] values in the list will be used to
* arrange the add buttons in the Stripe UI components. They will be arranged vertically
* from first to last.
*
* Currently only [PaymentMethod.Type.Card] and [PaymentMethod.Type.Fpx] are supported.
* If not specified or empty, [PaymentMethod.Type.Card] will be used.
*/
fun setPaymentMethodTypes(
paymentMethodTypes: List<PaymentMethod.Type>
): Builder {
this.paymentMethodTypes = paymentMethodTypes
Expand Down

0 comments on commit 54ec498

Please sign in to comment.