-
Notifications
You must be signed in to change notification settings - Fork 644
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move
CustoemrSheet
card tests to their own file.
- Loading branch information
1 parent
92496a8
commit 142b059
Showing
2 changed files
with
131 additions
and
114 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
131 changes: 131 additions & 0 deletions
131
paymentsheet-example/src/androidTest/java/com/stripe/android/lpm/TestCardInCustomerSheet.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,131 @@ | ||
package com.stripe.android.lpm | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import com.stripe.android.BasePlaygroundTest | ||
import com.stripe.android.paymentsheet.PaymentSheet | ||
import com.stripe.android.paymentsheet.example.playground.settings.CollectAddressSettingsDefinition | ||
import com.stripe.android.paymentsheet.example.playground.settings.CollectEmailSettingsDefinition | ||
import com.stripe.android.paymentsheet.example.playground.settings.CollectNameSettingsDefinition | ||
import com.stripe.android.paymentsheet.example.playground.settings.CollectPhoneSettingsDefinition | ||
import com.stripe.android.paymentsheet.example.playground.settings.Country | ||
import com.stripe.android.paymentsheet.example.playground.settings.CountrySettingsDefinition | ||
import com.stripe.android.paymentsheet.example.playground.settings.CustomerSettingsDefinition | ||
import com.stripe.android.paymentsheet.example.playground.settings.CustomerSheetPaymentMethodModeDefinition | ||
import com.stripe.android.paymentsheet.example.playground.settings.CustomerType | ||
import com.stripe.android.paymentsheet.example.playground.settings.DefaultBillingAddress | ||
import com.stripe.android.paymentsheet.example.playground.settings.DefaultBillingAddressSettingsDefinition | ||
import com.stripe.android.paymentsheet.example.playground.settings.PaymentMethodMode | ||
import com.stripe.android.test.core.TestParameters | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
internal class TestCardInCustomerSheet : BasePlaygroundTest() { | ||
@Test | ||
fun testCard() { | ||
testDriver.savePaymentMethodInCustomerSheet( | ||
TestParameters.create(paymentMethodCode = "card").copyPlaygroundSettings { settings -> | ||
settings[CustomerSettingsDefinition] = CustomerType.NEW | ||
settings[CountrySettingsDefinition] = Country.US | ||
settings[CustomerSheetPaymentMethodModeDefinition] = PaymentMethodMode.CreateAndAttach | ||
}, | ||
populateCustomLpmFields = { | ||
populateCardDetails() | ||
}, | ||
) | ||
} | ||
|
||
@Test | ||
fun testCardWithSetupIntent() { | ||
testDriver.savePaymentMethodInCustomerSheet( | ||
TestParameters.create(paymentMethodCode = "card").copyPlaygroundSettings { settings -> | ||
settings[CustomerSettingsDefinition] = CustomerType.NEW | ||
settings[CountrySettingsDefinition] = Country.US | ||
settings[CustomerSheetPaymentMethodModeDefinition] = PaymentMethodMode.SetupIntent | ||
}, | ||
populateCustomLpmFields = { | ||
populateCardDetails() | ||
}, | ||
) | ||
} | ||
|
||
@Test | ||
fun testCardWithNonUsMerchant() { | ||
testDriver.savePaymentMethodInCustomerSheet( | ||
TestParameters.create(paymentMethodCode = "card").copyPlaygroundSettings { settings -> | ||
settings[CustomerSettingsDefinition] = CustomerType.NEW | ||
settings[CountrySettingsDefinition] = Country.FR | ||
settings[CustomerSheetPaymentMethodModeDefinition] = PaymentMethodMode.CreateAndAttach | ||
}, | ||
populateCustomLpmFields = { | ||
populateCardDetails() | ||
}, | ||
) | ||
} | ||
|
||
@Test | ||
fun testCardWithSetupIntentAndNonUsMerchant() { | ||
testDriver.savePaymentMethodInCustomerSheet( | ||
TestParameters.create(paymentMethodCode = "card").copyPlaygroundSettings { settings -> | ||
settings[CustomerSettingsDefinition] = CustomerType.NEW | ||
settings[CountrySettingsDefinition] = Country.FR | ||
settings[CustomerSheetPaymentMethodModeDefinition] = PaymentMethodMode.SetupIntent | ||
}, | ||
populateCustomLpmFields = { | ||
populateCardDetails() | ||
}, | ||
) | ||
} | ||
|
||
@Test | ||
fun testCardWithBillingDetailsCollection() { | ||
testDriver.savePaymentMethodInCustomerSheet( | ||
TestParameters.create( | ||
paymentMethodCode = "card", | ||
) { settings -> | ||
settings[CustomerSettingsDefinition] = CustomerType.NEW | ||
settings[CountrySettingsDefinition] = Country.US | ||
settings[DefaultBillingAddressSettingsDefinition] = DefaultBillingAddress.Off | ||
settings[CollectNameSettingsDefinition] = | ||
PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Always | ||
settings[CollectEmailSettingsDefinition] = | ||
PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Always | ||
settings[CollectPhoneSettingsDefinition] = | ||
PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Always | ||
settings[CollectAddressSettingsDefinition] = | ||
PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode.Full | ||
}, | ||
populateCustomLpmFields = { | ||
populateCardDetails() | ||
populateEmail() | ||
populateName("Name on card") | ||
populateAddress() | ||
populatePhoneNumber() | ||
}, | ||
) | ||
} | ||
|
||
@Test | ||
fun testCardWithBillingDetailsCollectionWithDefaults() { | ||
testDriver.savePaymentMethodInCustomerSheet( | ||
TestParameters.create( | ||
paymentMethodCode = "card", | ||
) { settings -> | ||
settings[CustomerSettingsDefinition] = CustomerType.NEW | ||
settings[CountrySettingsDefinition] = Country.US | ||
settings[DefaultBillingAddressSettingsDefinition] = DefaultBillingAddress.On | ||
settings[CollectNameSettingsDefinition] = | ||
PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Always | ||
settings[CollectEmailSettingsDefinition] = | ||
PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Always | ||
settings[CollectPhoneSettingsDefinition] = | ||
PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Always | ||
settings[CollectAddressSettingsDefinition] = | ||
PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode.Full | ||
}, | ||
populateCustomLpmFields = { | ||
populateCardDetails() | ||
}, | ||
) | ||
} | ||
} |