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

Remove assertion that address is required for Klarna #10270

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.test.core.app.ApplicationProvider
import com.google.common.truth.Truth.assertThat
import com.stripe.android.core.exception.InvalidRequestException
import com.stripe.android.core.networking.ApiRequest
import com.stripe.android.model.Address
import com.stripe.android.model.PaymentMethod
import com.stripe.android.model.PaymentMethodCreateParams
import com.stripe.android.model.PaymentMethodCreateParamsFixtures
Expand Down Expand Up @@ -376,36 +375,6 @@ internal class PaymentMethodEndToEndTest {

@Test
fun createPaymentMethod_withKlarna_shouldCreateObject() {
val missingAddressException = assertFailsWith<InvalidRequestException>(
"Address is required to create a klarna payment method"
) {
val params = PaymentMethodCreateParams.createKlarna(
billingDetails =
PaymentMethodCreateParamsFixtures.BILLING_DETAILS.copy(address = null)
)
Stripe(context, ApiKeyFixtures.KLARNA_PUBLISHABLE_KEY)
.createPaymentMethodSynchronous(params)
}

assertThat(missingAddressException.message)
.isEqualTo("You must provide `billing_details[address][country]` to use Klarna.")

val missingCountryException = assertFailsWith<InvalidRequestException>(
"Country is required to create a klarna payment method"
) {
val address = Address(country = null)
val params = PaymentMethodCreateParams.createKlarna(
billingDetails =
PaymentMethodCreateParamsFixtures.BILLING_DETAILS.copy(address = address)
)

Stripe(context, ApiKeyFixtures.KLARNA_PUBLISHABLE_KEY)
.createPaymentMethodSynchronous(params)
}

assertThat(missingCountryException.message)
.isEqualTo("You must provide `billing_details[address][country]` to use Klarna.")

val params = PaymentMethodCreateParams.createKlarna(
billingDetails = PaymentMethodCreateParamsFixtures.BILLING_DETAILS.copy()
)
Expand Down
Loading