-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add synthetic payment method for LinkCardBrand
- Loading branch information
1 parent
3480837
commit cfc2417
Showing
6 changed files
with
114 additions
and
28 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
50 changes: 50 additions & 0 deletions
50
...va/com/stripe/android/lpmfoundations/paymentmethod/definitions/LinkCardBrandDefinition.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,50 @@ | ||
package com.stripe.android.lpmfoundations.paymentmethod.definitions | ||
|
||
import com.stripe.android.lpmfoundations.luxe.SupportedPaymentMethod | ||
import com.stripe.android.lpmfoundations.paymentmethod.AddPaymentMethodRequirement | ||
import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodDefinition | ||
import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodMetadata | ||
import com.stripe.android.lpmfoundations.paymentmethod.UiDefinitionFactory | ||
import com.stripe.android.model.PaymentMethod | ||
import com.stripe.android.uicore.elements.FormElement | ||
import com.stripe.android.ui.core.R as PaymentsUiCoreR | ||
|
||
internal object LinkCardBrandDefinition : PaymentMethodDefinition { | ||
|
||
override val type: PaymentMethod.Type = PaymentMethod.Type.Link | ||
|
||
override val supportedAsSavedPaymentMethod: Boolean = false | ||
|
||
override fun requirementsToBeUsedAsNewPaymentMethod( | ||
hasIntentToSetup: Boolean | ||
): Set<AddPaymentMethodRequirement> = setOf( | ||
AddPaymentMethodRequirement.FinancialConnectionsSdk, | ||
AddPaymentMethodRequirement.LinkCardBrand, | ||
) | ||
|
||
override fun requiresMandate(metadata: PaymentMethodMetadata): Boolean = true | ||
|
||
override fun uiDefinitionFactory(): UiDefinitionFactory = LinkCardBrandDefinitionFactory | ||
} | ||
|
||
private object LinkCardBrandDefinitionFactory : UiDefinitionFactory.Simple { | ||
|
||
override fun createSupportedPaymentMethod(): SupportedPaymentMethod { | ||
return SupportedPaymentMethod( | ||
code = InstantDebitsDefinition.type.code, | ||
displayNameResource = PaymentsUiCoreR.string.stripe_paymentsheet_payment_method_instant_debits, | ||
iconResource = PaymentsUiCoreR.drawable.stripe_ic_paymentsheet_pm_bank, | ||
iconRequiresTinting = true, | ||
lightThemeIconUrl = null, | ||
darkThemeIconUrl = null, | ||
) | ||
} | ||
|
||
// Link Card Brand uses its own mechanism, not these form elements. | ||
override fun createFormElements( | ||
metadata: PaymentMethodMetadata, | ||
arguments: UiDefinitionFactory.Arguments, | ||
): List<FormElement> { | ||
return emptyList() | ||
} | ||
} |