Stripe Integration

作者 wshobson46891e7e60da無授權條款收錄於 2026年10月8日更新於 2026年10月8日

Implement Stripe payment processing for robust, PCI-compliant payment flows including checkout, subscriptions, and webhooks. Use when integrating Stripe payments, building subscription systems, or implementing secure checkout flows.

AI 產生的概覽

指導 Stripe 付款整合:結帳、訂閱、Webhook、退款及符合 PCI 的付款流程。

功能
此技能提供實作 Stripe 付款處理的指引,涵蓋結帳工作階段、付款意圖、設定意圖、訂閱、客戶管理、Webhook 與退款。它說明核心概念、列出關鍵 Webhook 事件,並附上快速開始與測試的程式碼範例及測試卡號。詳細模式與完整範例放在另一份參考檔案中,當主要說明不足時由代理讀取。
適用情境
適用於為網頁或行動應用程式加入付款處理、建立訂閱計費、處理單次或週期性扣款,以及處理退款與爭議。也適合管理客戶付款方式、為歐洲付款實作 SCA,以及使用 Stripe Connect 建立市集平台的付款流程。
執行需求
需要 Stripe 帳戶與 API 金鑰(測試與正式)、Stripe Python 函式庫,以及連線至 Stripe API 的網路存取。此技能未附帶指令碼,只有說明文件與一份參考檔案。

Stripe Integration

Master Stripe payment processing integration for robust, PCI-compliant payment flows including checkout, subscriptions, webhooks, and refunds.

When to Use This Skill

  • Implementing payment processing in web/mobile applications
  • Setting up subscription billing systems
  • Handling one-time payments and recurring charges
  • Processing refunds and disputes
  • Managing customer payment methods
  • Implementing SCA (Strong Customer Authentication) for European payments
  • Building marketplace payment flows with Stripe Connect

Core Concepts

1. Payment Flows

Checkout Sessions

  • Recommended for most integrations
  • Supports all UI paths:
    • Stripe-hosted checkout page
    • Embedded checkout form
    • Custom UI with Elements (Payment Element, Express Checkout Element) using ui_mode='custom'
  • Provides built-in checkout capabilities (line items, discounts, tax, shipping, address collection, saved payment methods, and checkout lifecycle events)
  • Lower integration and maintenance burden than Payment Intents

Payment Intents (Bespoke control)

  • You calculate the final amount with taxes, discounts, subscriptions, and currency conversion yourself.
  • More complex implementation and long-term maintenance burden
  • Requires Stripe.js for PCI compliance

Setup Intents (Save Payment Methods)

  • Collect payment method without charging
  • Used for subscriptions and future payments
  • Requires customer confirmation

2. Webhooks

Critical Events:

  • payment_intent.succeeded: Payment completed
  • payment_intent.payment_failed: Payment failed
  • customer.subscription.updated: Subscription changed
  • customer.subscription.deleted: Subscription canceled
  • charge.refunded: Refund processed
  • invoice.payment_succeeded: Subscription payment successful

3. Subscriptions

Components:

  • Product: What you're selling
  • Price: How much and how often
  • Subscription: Customer's recurring payment
  • Invoice: Generated for each billing cycle

4. Customer Management

  • Create and manage customer records
  • Store multiple payment methods
  • Track customer metadata
  • Manage billing details

Quick Start

python
import stripe
stripe.api_key = "sk_test_..."
# Create a checkout sessionsession = stripe.checkout.Session.create(    line_items=[{        'price_data': {            'currency': 'usd',            'product_data': {                'name': 'Premium Subscription',            },            'unit_amount': 2000,  # $20.00            'recurring': {                'interval': 'month',            },        },        'quantity': 1,    }],    mode='subscription',    success_url='https://yourdomain.com/success?session_id={CHECKOUT_SESSION_ID}',    cancel_url='https://yourdomain.com/cancel')
# Redirect user to session.urlprint(session.url)

Detailed patterns and worked examples

Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.

Testing

python
# Use test mode keysstripe.api_key = "sk_test_..."
# Test card numbersTEST_CARDS = {    'success': '4242424242424242',    'declined': '4000000000000002',    '3d_secure': '4000002500003155',    'insufficient_funds': '4000000000009995'}
def test_payment_flow():    """Test complete payment flow."""    # Create test customer    customer = stripe.Customer.create(        email="[email protected]"    )
    # Create payment intent    intent = stripe.PaymentIntent.create(        amount=1000,        automatic_payment_methods={            'enabled': True        },        currency='usd',        customer=customer.id    )
    # Confirm with test card    confirmed = stripe.PaymentIntent.confirm(        intent.id,        payment_method='pm_card_visa'  # Test payment method    )
    assert confirmed.status == 'succeeded'

來源與署名

來源:wshobson/agents位於plugins/payment-processing/skills/stripe-integration提交46891e7

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架