Lewati ke konten
Buat akun atau Masuk
Logo Dokumen Stripe
/
Tanya AI
Buat akunMasuk
Mulai
Pembayaran
Pendapatan
Platform dan situs belanja online
Manajemen uang
Sumber daya pengembang
API & SDKBantuan
Gambaran UmumTerima pembayaranUpgrade integrasi Anda
Pembayaran online
Gambaran umumTemukan contoh penggunaan Anda
Gunakan Payment Links
Gunakan halaman checkout bawaan
Buat integrasi kustom dengan Elements
Bangun integrasi dalam aplikasi
    Gambaran umum
    Payment Sheet
    Payment Element
      Terima pembayaran dalam aplikasi
      Sesuaikan tampilan dan nuansa
      Tambahkan metode pembayaran custom
      Filter brand kartu
    Element Alamat
    Element Pengiriman Pesan Metode Pembayaran
    Link keluar untuk pembelian dalam aplikasi
    Kelola metode pembayaran di pengaturan
    Migrasikan ke Token Konfirmasi
    Kartu AS dan Kanada
Gunakan Managed Payments
Pembayaran rutin
Pembayaran di tempat
Terminal
Metode Pembayaran
Tambahkan metode pembayaran
Kelola metode pembayaran
Checkout lebih cepat dengan Link
Operasi pembayaran
Analitik
Saldo dan waktu pelunasan
Kepatuhan dan keamanan
Mata uang
Penolakan
Sengketa
Pencegahan penipuan
Perlindungan penipuan Radar
Payout
ResiPengembalian dana dan pembatalan
Integrasi lanjutan
Alur pembayaran custom
Akuisisi fleksibel
Pembayaran di Luar Sesi
Orkestrasi multi-pemroses
Di luar pembayaran
Dirikan perusahaan Anda
Kripto
Perdagangan agen
Pembayaran mesin
Financial Connections
Climate
Verifikasikan identitas
Amerika Serikat
Bahasa Indonesia
BerandaPembayaranBuild an in-app integrationPayment Element

Tambahkan metode pembayaran custom

Tambahkan metode pembayaran custom ke Payment Element.

In-app Payments let your users pay with many payment methods through a single integration. Use custom payment methods if you need to display additional payment methods that aren’t processed through Stripe. If you use custom payment methods, you can optionally record purchases processed outside of Stripe to your Stripe account for reporting purposes.

To configure a custom payment method, create it in your Stripe Dashboard, and provide a display name and icon that In-app Payments also display. The Stripe Dashboard also provides access to over 50 preset custom payment methods. After you create the payment method, follow the guide below to configure the In-app Payments. Setting up the In-app Payments requires some additional configuration work because custom payment method transactions process and finalize outside of Stripe.

Catatan

When integrating with a third-party payment processor, you’re responsible for complying with applicable legal requirements, including your agreement with your PSP, applicable laws, and so on.

Sebelum Anda memulai

  1. Buat akun Stripe atau masuk.
  2. Follow the guide to accept in-app payments to complete a payments integration.

Create your custom payment method in the Dashboard
Dashboard

Go to Settings > Payments > Custom Payment Methods to get to the custom payment methods page. Create a new custom payment method and provide the display name and logo that the Payment Element displays.

Choose the right logo

  • If you provide a logo with a transparent background, consider the background color of the Payment Element on your page and make sure that it displays clearly.
  • If you provide a logo with a background fill, provide rounded corners in your file because we won’t provide them.
  • Choose a logo variant that can scale down to 16 pixels × 16 pixels. This is often the standalone logo mark for a brand.

After creating the custom payment method, the Dashboard displays the custom payment method ID (beginning with cpmt_) needed in step 2.

Add custom payment method types

When you create your EmbeddedPaymentElement.Configuration object and initialize the EmbeddedPaymentElement, specify the custom payment methods that you want to add to the Payment Element and a handler to complete the payment.

@_spi(CustomPaymentMethodsBeta) import StripePaymentSheet class MyCheckoutVC: UIViewController { func createEmbeddedPaymentElement() async throws -> EmbeddedPaymentElement { // ... var configuration = EmbeddedPaymentElement.Configuration() let customPaymentMethod = EmbeddedPaymentElement.CustomPaymentMethodConfiguration.CustomPaymentMethod(id: "cpmt_...", subtitle: "Optional subtitle") configuration.customPaymentMethodConfiguration = .init(customPaymentMethods: [customPaymentMethod], customPaymentMethodConfirmHandler: handleCustomPaymentMethod(_:_:)) // ... } func handleCustomPaymentMethod( _ customPaymentMethodType: EmbeddedPaymentElement.CustomPaymentMethodConfiguration.CustomPaymentMethod, _ billingDetails: STPPaymentMethodBillingDetails ) async -> EmbeddedPaymentElementResult { // ...explained in the next step } }

Selesaikan pembayaran

When you call confirm on your EmbeddedPaymentElement instance and the customer has selected a custom payment method, it calls the handler with the custom payment method, and uses any billing details that you collected in the sheet.

Your implementation completes the payment (for example, by using your custom payment method provider’s SDK) and returns from the function with the result of the payment: completed, canceled, or failure(error:).

@_spi(CustomPaymentMethodsBeta) import StripePaymentSheet class MyCheckoutVC: UIViewController { func createEmbeddedPaymentElement() async throws -> EmbeddedPaymentElement { // ... var configuration = EmbeddedPaymentElement.Configuration() let customPaymentMethod = EmbeddedPaymentElement.CustomPaymentMethodConfiguration.CustomPaymentMethod(id: "cpmt_...", subtitle: "Optional subtitle") configuration.customPaymentMethodConfiguration = .init(customPaymentMethods: [customPaymentMethod], customPaymentMethodConfirmHandler: handleCustomPaymentMethod(_:_:)) // ... } func handleCustomPaymentMethod( _ customPaymentMethodType: EmbeddedPaymentElement.CustomPaymentMethodConfiguration.CustomPaymentMethod, _ billingDetails: STPPaymentMethodBillingDetails ) async -> EmbeddedPaymentElementResult { // Your implementation needs to complete the payment with the payment method provider // When the payment completes, cancels, or fails, return the result. // This example code just immediately fails: let exampleError = NSError(domain: "MyErrorDomain", code: 0, userInfo: [NSLocalizedDescriptionKey: "Failed to complete payment!"]) return .failed(error: exampleError) } }

OpsionalSpecify the order of custom payment methods

Stripe’s smart ordering logic can’t rank custom payment methods because it has no context for them. By default, they appear after Stripe-supported payment methods. To explicitly position a custom payment method in the Mobile Payment Element, set EmbeddedPaymentElement.Configuration.paymentMethodOrder. We still intelligently rank the Stripe-supported payment methods following the custom payment method.

var configuration = EmbeddedPaymentElement.Configuration() // Show cards first, followed by cpmt_, followed by all other payment methods configuration.paymentMethodOrder = ["card", "cpmt_..."]

Kumpulkan detail tagihan

You can collect billing details using billingDetailsCollectionConfiguration on the Payment Element configuration. However, custom payment methods don’t collect billing details by default. To enable billing detail collection, set disableBillingDetailCollection to false on your CustomPaymentMethod.

var customPaymentMethod = EmbeddedPaymentElement.CustomPaymentMethodConfiguration.CustomPaymentMethod(id: "cpmt_...", subtitle: "Optional subtitle") customPaymentMethod.disableBillingDetailCollection = false

Uji integrasi Anda

  1. Go through your checkout flow and verify that the Mobile Payment Element displays your custom payment method. This example configures your custom payment method in the second position after cards.
  2. Choose your custom payment method.
  3. Click Pay now to test your custom payment method integration. Verify that your integration completes the transaction and that any post-payment actions (for example, displaying a confirmation page, success message, or failure message) still work with your custom payment method integration.

OpsionalRecord the payment to your Stripe account
Sisi server

While you handle custom payment method transactions outside of Stripe, you can still record the transaction details to your Stripe account to unify reporting and build back office workflows, such as issuing receipts or creating reports.

server.js
const stripe = new Stripe(
'sk_test_BQokikJOvBiI2HlWgH4olfQ2'
, { apiVersion: '2026-01-28.clover; invoice_partial_payments_beta=v3' }); app.get('/process-cpm-payment', async (req, res) => { const paymentResult = processMyCustomPayment(...) // Create an instance of a custom payment method const paymentMethod = await stripe.paymentMethods.create({ type: 'custom', custom: { type:
'{{CUSTOM_PAYMENT_METHOD_TYPE_ID}}'
, } }); // Report successful payment const paymentRecord = await stripe.paymentRecords.reportPayment({ amount_requested: { value: paymentResult.amount, currency: paymentResult.currency }, payment_method_details: { payment_method: paymentMethod.id }, customer_details: { customer: paymentResult.customer.id }, processor_details: { type: 'custom', custom: { payment_reference: paymentResult.id } }, initiated_at: paymentResult.initiated_at, customer_presence: 'on_session', outcome: 'guaranteed', guaranteed: { guaranteed_at: paymentResult.completed_at } }); // Respond to frontend to finish buying experience return res.json(...) });
Apakah halaman ini membantu?
YaTidak
  • Butuh bantuan? Hubungi Tim CS.
  • Lihat log perubahan kami.
  • Ada pertanyaan? Hubungi Bagian Penjualan.
  • LLM? Baca llms.txt.
  • Dijalankan oleh Markdoc