Lewati ke konten
Buat akun
atau
Masuk
Logo Dokumen Stripe
/
Tanya AI
Buat akun
Masuk
Mulai
Pembayaran
Otomatisasi keuangan
Platform dan situs belanja online
Manajemen uang
Alat bantu pengembang
Mulai
Pembayaran
Otomatisasi keuangan
Mulai
Pembayaran
Otomatisasi keuangan
Platform dan situs belanja online
Manajemen uang
Gambaran Umum
Tentang pembayaran Stripe
Upgrade integrasi Anda
Analitik pembayaran
Pembayaran online
Gambaran umumTemukan contoh penggunaan AndaPembayaran Terkelola
Gunakan Payment Links
Buat halaman checkout
Bangun integrasi lanjutan
Bangun integrasi dalam aplikasi
    Gambaran umum
    Payment Sheet
    Payment Element Tersemat
    Link keluar untuk pembelian dalam aplikasi
    Kumpulkan alamat
    Kartu AS dan Kanada
Metode Pembayaran
Tambahkan metode pembayaran
Kelola metode pembayaran
Checkout lebih cepat dengan Link
Antarmuka pembayaran
Payment Links
Checkout
Web Elements
Elements dalam aplikasi
Skenario pembayaran
Alur pembayaran custom
Akuisisi fleksibel
Orkestrasi
Pembayaran di tempat
Terminal
Produk Stripe lainnya
Financial Connections
Kripto
Climate
BerandaPembayaranBuild an in-app integration

Catatan

Halaman ini belum tersedia dalam bahasa ini. Kami sedang bekerja keras untuk membuat dokumentasi tersedia dalam lebih banyak bahasa dan akan menyediakan terjemahannya secepat mungkin.

Collect physical addresses and phone numbers

Learn how to collect addresses and phone number in your mobile app.

Salin halaman

To collect complete addresses for billing or shipping, use the Address Element.

You can also use the Address Element to:

  • Collect customer phone numbers
  • Enable autocomplete
  • Prefill billing information in the Payment Element by passing in a shipping address

Stripe combines the collected address information and the payment method to create a PaymentIntent.

Examples of a checkout process where a user selects the Add Shipping Address option. They're then taken to a new screen to add their shipping address into a form (they see auto-complete suggestions as they type in their address).

Set up Stripe
Server-side
Client-side

First, you need a Stripe account. Register now.

The Stripe Android SDK is open source and fully documented.

To install the SDK, add stripe-android to the dependencies block of your app/build.gradle file:

build.gradle.kts
Kotlin
plugins { id("com.android.application") } android { ... } dependencies { // ... // Stripe Android SDK implementation("com.stripe:stripe-android:21.13.0") // Include the financial connections SDK to support US bank account as a payment method implementation("com.stripe:financial-connections:21.13.0") }

Catatan

For details on the latest SDK release and past versions, see the Releases page on GitHub. To receive notifications when a new release is published, watch releases for the repository.

Configure the SDK with your Stripe publishable key so that it can make requests to the Stripe API, such as in your Application subclass:

Kotlin
import com.stripe.android.PaymentConfiguration class MyApp : Application() { override fun onCreate() { super.onCreate() PaymentConfiguration.init( applicationContext,
"pk_test_TYooMQauvdEDq54NiTphI7jx"
) } }

Catatan

Use your test keys while you test and develop, and your live mode keys when you publish your app.

Set up address autocomplete suggestions

The address element uses the Google Places SDK to fetch address autocomplete suggestions. To enable autocomplete suggestions, you need to include the Google Places SDK dependency to your app’s build.gradle.

build.gradle
Groovy
dependencies { implementation 'com.google.android.libraries.places:places:2.6.0' }

Address autocomplete suggestions requires a Google Places API key. Follow the Google Places SDK setup guide to generate your API key.

Configure the Address Element

You can configure the Address Element with details such as displaying default values, setting allowed countries, customizing the appearance, and so on. Refer to AddressLauncher.Configuration for the complete list of configuration options.

val addressConfiguration = AddressLauncher.Configuration( additionalFields: AddressLauncher.AdditionalFieldsConfiguration( phone: AdditionalFieldsConfiguration.FieldConfiguration.Required ), allowedCountries: setOf("US", "CA", "GB"), title: "Shipping Address", googlePlacesApiKey = "(optional) YOUR KEY HERE" )

Retrieve address details

Retrieve the address details by creating an instance of AddressLauncher in the onCreate lifecycle method of your Activity or Fragment and creating a callback method that implements the AddressLauncherResultCallback interface.

private lateinit var addressLauncher: AddressLauncher private var shippingDetails: AddressDetails? = null override fun onCreate(savedInstanceState: Bundle?) { addressLauncher = AddressLauncher(this, ::onAddressLauncherResult) } private fun onAddressLauncherResult(result: AddressLauncherResult) { // TODO: Handle result and update your UI when (result) { is AddressLauncherResult.Succeeded -> { shippingDetails = result.address } is AddressLauncherResult.Canceled -> { // TODO: Handle cancel } } }

The AddressLauncherResult can be Succeeded or Canceled. See more implementation details.

Catatan

Stripe requires that you instantiate the AddressLauncher during the onCreate lifecycle event and not after. Otherwise, the callback can’t be registered properly, and your app will crash.

Present the Address Element

Present the address element using the address launcher and configuration from the previous steps.

addressLauncher.present( publishableKey = publishableKey, configuration = addressConfiguration )

OpsionalPrefill shipping addresses in the Payment Element

OpsionalCustomize the appearance

OpsionalSet default billing details

OpsionalCustomize billing details collection

Apakah halaman ini membantu?
YaTidak
Butuh bantuan? Hubungi Tim CS.
Bergabunglah dengan program akses awal kami.
Lihat log perubahan kami.
Ada pertanyaan? Hubungi Bagian Penjualan.
LLM? Baca llms.txt.
Dijalankan oleh Markdoc