Skip to content

Commit

Permalink
Fix afterpay end to end test (#5395)
Browse files Browse the repository at this point in the history
  • Loading branch information
jameswoo-stripe authored Aug 11, 2022
1 parent f02c2b8 commit 338105f
Showing 1 changed file with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ internal class PaymentMethodEndToEndTest {
}

@Test
fun `createPaymentMethod with Afterpay should require name, email, and address`() {
fun `createPaymentMethod with Afterpay should require name, email`() {
val stripe = Stripe(context, ApiKeyFixtures.AFTERPAY_PUBLISHABLE_KEY)
val missingNameException = assertFailsWith<InvalidRequestException>(
"Name is required to create an Afterpay payment method"
Expand All @@ -337,6 +337,30 @@ internal class PaymentMethodEndToEndTest {

assertThat(missingNameException.message)
.isEqualTo("Missing required param: billing_details[name].")

val missingEmailException = assertFailsWith<InvalidRequestException>(
"Email is required to create an Afterpay payment method"
) {
stripe
.createPaymentMethodSynchronous(
PaymentMethodCreateParams.createAfterpayClearpay(
billingDetails = PaymentMethodCreateParamsFixtures.BILLING_DETAILS.copy(email = null)
)
)
}

assertThat(missingEmailException.message)
.isEqualTo("Missing required param: billing_details[email].")

// Address is optional
assertThat(
stripe
.createPaymentMethodSynchronous(
PaymentMethodCreateParams.createAfterpayClearpay(
billingDetails = PaymentMethodCreateParamsFixtures.BILLING_DETAILS.copy(address = null)
)
)
).isNotNull()
}

@Test
Expand Down

0 comments on commit 338105f

Please sign in to comment.