-
Notifications
You must be signed in to change notification settings - Fork 662
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add promo badge for incentives in MPE (#9662)
* Add promo badge for incentives in MPE * Address code review feedback - Add tests for PaymentMethodIncentive logic - Add tests for vertical layout interactor
- Loading branch information
1 parent
865db79
commit a11400b
Showing
31 changed files
with
295 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
paymentsheet/src/main/java/com/stripe/android/paymentsheet/model/PaymentMethodIncentive.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.stripe.android.paymentsheet.model | ||
|
||
import android.os.Parcelable | ||
import com.stripe.android.model.LinkConsumerIncentive | ||
import com.stripe.android.model.PaymentMethod | ||
import com.stripe.android.model.PaymentMethodCode | ||
import kotlinx.parcelize.Parcelize | ||
|
||
@Parcelize | ||
internal data class PaymentMethodIncentive( | ||
private val identifier: String, | ||
val displayText: String, | ||
) : Parcelable { | ||
|
||
fun matches(code: PaymentMethodCode): Boolean { | ||
return identifier == "link_instant_debits" && code == PaymentMethod.Type.Link.code | ||
} | ||
} | ||
|
||
internal fun LinkConsumerIncentive.toPaymentMethodIncentive(): PaymentMethodIncentive? { | ||
return incentiveDisplayText?.let { displayText -> | ||
PaymentMethodIncentive( | ||
identifier = incentiveParams.paymentMethod, | ||
displayText = displayText, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...entsheet/src/main/java/com/stripe/android/paymentsheet/verticalmode/BankFormInteractor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.stripe.android.paymentsheet.verticalmode | ||
|
||
import com.stripe.android.paymentsheet.model.PaymentSelection | ||
import com.stripe.android.paymentsheet.viewmodels.BaseSheetViewModel | ||
|
||
internal class BankFormInteractor( | ||
private val updateSelection: (PaymentSelection.New.USBankAccount?) -> Unit, | ||
val paymentMethodIncentiveInteractor: PaymentMethodIncentiveInteractor, | ||
) { | ||
|
||
fun handleLinkedBankAccountChanged(selection: PaymentSelection.New.USBankAccount?) { | ||
updateSelection(selection) | ||
|
||
// TODO(tillh-stripe): Update incentive badge here | ||
} | ||
|
||
companion object { | ||
|
||
fun create(viewModel: BaseSheetViewModel): BankFormInteractor { | ||
return BankFormInteractor( | ||
updateSelection = viewModel::updateSelection, | ||
paymentMethodIncentiveInteractor = PaymentMethodIncentiveInteractor.create(viewModel), | ||
) | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...ain/java/com/stripe/android/paymentsheet/verticalmode/PaymentMethodIncentiveInteractor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.stripe.android.paymentsheet.verticalmode | ||
|
||
import com.stripe.android.paymentsheet.model.PaymentMethodIncentive | ||
import com.stripe.android.paymentsheet.viewmodels.BaseSheetViewModel | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.StateFlow | ||
import kotlinx.coroutines.flow.asStateFlow | ||
|
||
internal class PaymentMethodIncentiveInteractor( | ||
private val incentive: PaymentMethodIncentive?, | ||
) { | ||
|
||
private val _displayedIncentive = MutableStateFlow(incentive) | ||
val displayedIncentive: StateFlow<PaymentMethodIncentive?> = _displayedIncentive.asStateFlow() | ||
|
||
companion object { | ||
|
||
fun create(viewModel: BaseSheetViewModel): PaymentMethodIncentiveInteractor { | ||
return PaymentMethodIncentiveInteractor( | ||
incentive = viewModel.paymentMethodMetadata.value?.paymentMethodIncentive, | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.