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 downloading images for LUXE payment methods. #5928

Merged
merged 34 commits into from
Dec 14, 2022
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4810318
Add support for downloading images for LUXE payment methods.
jaynewstrom-stripe Nov 21, 2022
fcab65b
Fix compile errors.
jaynewstrom-stripe Nov 21, 2022
242e4fa
Fix detekt errors.
jaynewstrom-stripe Nov 21, 2022
a39de60
Minimize API breaking changes.
jaynewstrom-stripe Nov 23, 2022
c146557
Merge branch 'master' into jaynewstrom/luxe-images
jaynewstrom-stripe Nov 28, 2022
07a2650
Add support for dark theme.
jaynewstrom-stripe Nov 28, 2022
be67c70
Fix ktlint
jaynewstrom-stripe Nov 28, 2022
6d10846
Merge branch 'master' into jaynewstrom/luxe-images
jaynewstrom-stripe Nov 29, 2022
d443837
Update based on code review comments.
jaynewstrom-stripe Nov 29, 2022
02f128b
Update based on code review comments.
jaynewstrom-stripe Nov 29, 2022
8177680
Fix binary compatibility checker.
jaynewstrom-stripe Nov 29, 2022
c14e553
Merge branch 'master' into jaynewstrom/luxe-images
jaynewstrom-stripe Nov 30, 2022
65b0c1c
Some code review comments.
jaynewstrom-stripe Dec 2, 2022
ae38beb
Merge branch 'master' into jaynewstrom/luxe-images
jaynewstrom-stripe Dec 2, 2022
e662573
Fix lint.
jaynewstrom-stripe Dec 2, 2022
ce9b8e7
Not sure how this got there.
jaynewstrom-stripe Dec 2, 2022
2e16c51
Merge branch 'master' into jaynewstrom/luxe-images
jaynewstrom-stripe Dec 6, 2022
683e35d
Fix tests.
jaynewstrom-stripe Dec 6, 2022
dd26dad
Fix lint.
jaynewstrom-stripe Dec 6, 2022
c296b7a
Add a java friendly API.
jaynewstrom-stripe Dec 6, 2022
1cdea23
Fix ktlint.
jaynewstrom-stripe Dec 6, 2022
8908742
Fix apiCheck.
jaynewstrom-stripe Dec 6, 2022
6de196a
Synchronous icon Drawable via delegate.
jaynewstrom-stripe Dec 7, 2022
e0313a3
Fix loading.
jaynewstrom-stripe Dec 8, 2022
00c2e5c
Fix layout of playground activity payment method icon.
jaynewstrom-stripe Dec 8, 2022
a540037
Fix lint.
jaynewstrom-stripe Dec 8, 2022
aa9a6a7
Fix lint.
jaynewstrom-stripe Dec 8, 2022
8cd2a44
Merge branch 'master' into jaynewstrom/luxe-images-delegate
jaynewstrom-stripe Dec 12, 2022
c14f8ae
Minimize changes.
jaynewstrom-stripe Dec 12, 2022
485ae61
Merge branch 'master' into jaynewstrom/luxe-images-delegate
jaynewstrom-stripe Dec 13, 2022
3be0424
self code review.
jaynewstrom-stripe Dec 13, 2022
a98fb3d
self code review.
jaynewstrom-stripe Dec 13, 2022
b8f2347
Merge branch 'master' into jaynewstrom/luxe-images-delegate
jaynewstrom-stripe Dec 14, 2022
90570c3
Update changelog.
jaynewstrom-stripe Dec 14, 2022
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,10 @@

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

### PaymentSheet
* [DEPRECATED][5928](https://github.com/stripe/stripe-android/pull/5928) Deprecated `PaymentOption` public constructor, and `drawableResourceId` property.
* [ADDED][5928](https://github.com/stripe/stripe-android/pull/5928) Added `PaymentOption.icon()`, which returns a `Drawable`, and replaces `PaymentOption.drawableResourceId`.

## 20.17.0 - 2022-12-12

### Payments
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.stripe.android.ui.core.elements

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
@SerialName("next_action_spec")
internal data class SelectorIcon internal constructor(
@SerialName("light_theme_png") val lightThemePng: String? = null,
@SerialName("dark_theme_png") val darkThemePng: String? = null,
)
Original file line number Diff line number Diff line change
@@ -18,5 +18,8 @@ internal data class SharedDataSpec(
val fields: ArrayList<FormItemSpec> = arrayListOf(EmptyFormSpec),

@SerialName("next_action_spec")
val nextActionSpec: NextActionSpec? = null
val nextActionSpec: NextActionSpec? = null,

@SerialName("selector_icon")
val selectorIcon: SelectorIcon? = null,
)
Original file line number Diff line number Diff line change
@@ -224,6 +224,8 @@ class LpmRepository constructor(
false,
R.string.stripe_paymentsheet_payment_method_card,
R.drawable.stripe_ic_paymentsheet_pm_card,
sharedDataSpec.selectorIcon?.lightThemePng,
sharedDataSpec.selectorIcon?.darkThemePng,
true,
CardRequirement,
if (sharedDataSpec.fields.isEmpty() || sharedDataSpec.fields == listOf(EmptyFormSpec)) {
@@ -237,6 +239,8 @@ class LpmRepository constructor(
true,
R.string.stripe_paymentsheet_payment_method_bancontact,
R.drawable.stripe_ic_paymentsheet_pm_bancontact,
sharedDataSpec.selectorIcon?.lightThemePng,
sharedDataSpec.selectorIcon?.darkThemePng,
false,
BancontactRequirement,
LayoutSpec(sharedDataSpec.fields)
@@ -246,6 +250,8 @@ class LpmRepository constructor(
true,
R.string.stripe_paymentsheet_payment_method_sofort,
R.drawable.stripe_ic_paymentsheet_pm_klarna,
sharedDataSpec.selectorIcon?.lightThemePng,
sharedDataSpec.selectorIcon?.darkThemePng,
false,
SofortRequirement,
LayoutSpec(sharedDataSpec.fields)
@@ -255,6 +261,8 @@ class LpmRepository constructor(
true,
R.string.stripe_paymentsheet_payment_method_ideal,
R.drawable.stripe_ic_paymentsheet_pm_ideal,
sharedDataSpec.selectorIcon?.lightThemePng,
sharedDataSpec.selectorIcon?.darkThemePng,
false,
IdealRequirement,
LayoutSpec(sharedDataSpec.fields)
@@ -264,6 +272,8 @@ class LpmRepository constructor(
true,
R.string.stripe_paymentsheet_payment_method_sepa_debit,
R.drawable.stripe_ic_paymentsheet_pm_sepa_debit,
sharedDataSpec.selectorIcon?.lightThemePng,
sharedDataSpec.selectorIcon?.darkThemePng,
false,
SepaDebitRequirement,
LayoutSpec(sharedDataSpec.fields)
@@ -273,6 +283,8 @@ class LpmRepository constructor(
true,
R.string.stripe_paymentsheet_payment_method_eps,
R.drawable.stripe_ic_paymentsheet_pm_eps,
sharedDataSpec.selectorIcon?.lightThemePng,
sharedDataSpec.selectorIcon?.darkThemePng,
false,
EpsRequirement,
LayoutSpec(sharedDataSpec.fields)
@@ -282,6 +294,8 @@ class LpmRepository constructor(
false,
R.string.stripe_paymentsheet_payment_method_p24,
R.drawable.stripe_ic_paymentsheet_pm_p24,
sharedDataSpec.selectorIcon?.lightThemePng,
sharedDataSpec.selectorIcon?.darkThemePng,
false,
P24Requirement,
LayoutSpec(sharedDataSpec.fields)
@@ -291,6 +305,8 @@ class LpmRepository constructor(
false,
R.string.stripe_paymentsheet_payment_method_giropay,
R.drawable.stripe_ic_paymentsheet_pm_giropay,
sharedDataSpec.selectorIcon?.lightThemePng,
sharedDataSpec.selectorIcon?.darkThemePng,
false,
GiropayRequirement,
LayoutSpec(sharedDataSpec.fields)
@@ -304,6 +320,8 @@ class LpmRepository constructor(
R.string.stripe_paymentsheet_payment_method_afterpay
},
R.drawable.stripe_ic_paymentsheet_pm_afterpay_clearpay,
sharedDataSpec.selectorIcon?.lightThemePng,
sharedDataSpec.selectorIcon?.darkThemePng,
false,
AfterpayClearpayRequirement,
LayoutSpec(sharedDataSpec.fields)
@@ -313,6 +331,8 @@ class LpmRepository constructor(
false,
R.string.stripe_paymentsheet_payment_method_klarna,
R.drawable.stripe_ic_paymentsheet_pm_klarna,
sharedDataSpec.selectorIcon?.lightThemePng,
sharedDataSpec.selectorIcon?.darkThemePng,
false,
KlarnaRequirement,
LayoutSpec(sharedDataSpec.fields)
@@ -322,6 +342,8 @@ class LpmRepository constructor(
false,
R.string.stripe_paymentsheet_payment_method_paypal,
R.drawable.stripe_ic_paymentsheet_pm_paypal,
sharedDataSpec.selectorIcon?.lightThemePng,
sharedDataSpec.selectorIcon?.darkThemePng,
false,
PaypalRequirement,
LayoutSpec(sharedDataSpec.fields)
@@ -331,6 +353,8 @@ class LpmRepository constructor(
false,
R.string.stripe_paymentsheet_payment_method_affirm,
R.drawable.stripe_ic_paymentsheet_pm_affirm,
sharedDataSpec.selectorIcon?.lightThemePng,
sharedDataSpec.selectorIcon?.darkThemePng,
false,
AffirmRequirement,
LayoutSpec(sharedDataSpec.fields)
@@ -340,6 +364,8 @@ class LpmRepository constructor(
true,
R.string.stripe_paymentsheet_payment_method_au_becs_debit,
R.drawable.stripe_ic_paymentsheet_pm_bank,
sharedDataSpec.selectorIcon?.lightThemePng,
sharedDataSpec.selectorIcon?.darkThemePng,
true,
AuBecsDebitRequirement,
LayoutSpec(sharedDataSpec.fields)
@@ -349,6 +375,8 @@ class LpmRepository constructor(
true,
R.string.stripe_paymentsheet_payment_method_us_bank_account,
R.drawable.stripe_ic_paymentsheet_pm_bank,
sharedDataSpec.selectorIcon?.lightThemePng,
sharedDataSpec.selectorIcon?.darkThemePng,
true,
USBankAccountRequirement,
LayoutSpec(sharedDataSpec.fields)
@@ -358,6 +386,8 @@ class LpmRepository constructor(
requiresMandate = false,
displayNameResource = R.string.stripe_paymentsheet_payment_method_upi,
iconResource = R.drawable.stripe_ic_paymentsheet_pm_upi,
lightThemeIconUrl = sharedDataSpec.selectorIcon?.lightThemePng,
darkThemeIconUrl = sharedDataSpec.selectorIcon?.darkThemePng,
tintIconOnSelection = false,
requirement = UpiRequirement,
formSpec = LayoutSpec(sharedDataSpec.fields)
@@ -389,6 +419,12 @@ class LpmRepository constructor(
/** This describes the image in the LPM selector. These can be found internally [here](https://www.figma.com/file/2b9r3CJbyeVAmKi1VHV2h9/Mobile-Payment-Element?node-id=1128%3A0) */
@DrawableRes val iconResource: Int,

/** An optional light theme icon url if it's supported. */
val lightThemeIconUrl: String?,

/** An optional dark theme icon url if it's supported. */
val darkThemeIconUrl: String?,

/** Indicates if the lpm icon in the selector is a single color and should be tinted
* on selection.
*/
@@ -450,6 +486,8 @@ class LpmRepository constructor(
false,
R.string.stripe_paymentsheet_payment_method_card,
R.drawable.stripe_ic_paymentsheet_pm_card,
null,
null,
true,
CardRequirement,
LayoutSpec(listOf(CardDetailsSectionSpec(), CardBillingSpec(), SaveForFutureUseSpec()))
Original file line number Diff line number Diff line change
@@ -538,16 +538,12 @@ class PaymentSheetPlaygroundActivity : AppCompatActivity() {
private fun onPaymentOption(paymentOption: PaymentOption?) {
if (paymentOption != null) {
viewBinding.paymentMethod.text = paymentOption.label
viewBinding.paymentMethod.setCompoundDrawablesRelativeWithIntrinsicBounds(
paymentOption.drawableResourceId,
0,
0,
0
)
val iconDrawable = paymentOption.icon()
viewBinding.paymentMethodIcon.setImageDrawable(iconDrawable)
viewBinding.customCheckoutButton.isEnabled = true
} else {
viewBinding.paymentMethod.setText(R.string.select)
viewBinding.paymentMethod.setCompoundDrawables(null, null, null, null)
viewBinding.paymentMethodIcon.setImageDrawable(null)
viewBinding.customCheckoutButton.isEnabled = false
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.stripe.android.paymentsheet.example.samples.activity

import android.graphics.drawable.Drawable
import androidx.activity.viewModels
import androidx.annotation.DrawableRes
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
@@ -28,7 +28,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
@@ -41,6 +40,7 @@ import com.stripe.android.paymentsheet.PaymentSheet
import com.stripe.android.paymentsheet.PaymentSheetResult
import com.stripe.android.paymentsheet.example.R
import com.stripe.android.paymentsheet.example.samples.viewmodel.PaymentSheetViewModel
import com.stripe.android.paymentsheet.example.utils.rememberDrawablePainter

internal abstract class BasePaymentSheetActivity : AppCompatActivity() {
protected val viewModel: PaymentSheetViewModel by viewModels()
@@ -209,7 +209,7 @@ fun ReceiptRow(
fun PaymentMethodSelector(
isEnabled: Boolean,
paymentMethodLabel: String,
@DrawableRes paymentMethodIcon: Int?,
paymentMethodIcon: Drawable?,
onClick: () -> Unit,
) {
Row(
@@ -231,7 +231,7 @@ fun PaymentMethodSelector(
) {
paymentMethodIcon?.let {
Icon(
painter = painterResource(id = paymentMethodIcon),
painter = rememberDrawablePainter(paymentMethodIcon),
contentDescription = null, // decorative element
modifier = Modifier.padding(horizontal = 4.dp),
tint = Color.Unspecified
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ internal class LaunchPaymentSheetCustomActivity : BasePaymentSheetActivity() {
it?.label ?: resources.getString(R.string.select)
}
val selectedPaymentMethodIcon = selectedPaymentMethod.map {
it?.drawableResourceId
it?.icon()
}

setContent {
Loading