mcpField
S
Stripe Payments

Stripe Payments

github.com/claude-office-skills其他5454.9k 次安装39 周前更新
代码仓库

关于 Stripe Payments

Stripe Payments 是用于自动化 Stripe 支付处理和订阅管理的技能,涵盖 Webhook 处理、发票、结账、收入分析、欺诈规则和客户门户配置。

主要功能

  1. 01支付与 Webhook 工作流
  2. 02订阅生命周期自动化
  3. 03发票与催款配置
  4. 04结账与支付示例
  5. 05收入和客户群组分析
  6. 06欺诈规则与客户门户

适用场景

  1. 01自动处理支付失败
  2. 02管理订阅升级与续订
  3. 03配置发票和重试流程
  4. 04分析收入与订阅群组

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/claude-office-skills/skills --skill stripe-payments

安装后在 Claude Code 中输入/stripe-payments确认已加载。

详细介绍

Stripe 支付

用于自动化 Stripe 支付处理和订阅管理的综合技能。

核心工作流

1. 支付流程
STRIPE PAYMENT FLOW:
┌─────────────────┐
│    Customer     │
│  Payment Intent │
└────────┬────────┘
         ▼
┌─────────────────┐
│    Checkout     │
│  - Card Input   │
│  - Validation   │
└────────┬────────┘
         ▼
┌─────────────────┐
│   Processing    │
│  - Auth         │
│  - Capture      │
└────────┬────────┘
         ▼
┌─────────────────┐
│   Confirmation  │
│  - Receipt      │
│  - Webhook      │
└─────────────────┘
2. Webhook 事件
webhook_handlers:
  payment_intent.succeeded:
    actions:
      - fulfill_order
      - send_receipt
      - update_crm
      
  payment_intent.payment_failed:
    actions:
      - notify_customer
      - retry_payment
      - log_failure
      
  customer.subscription.created:
    actions:
      - provision_access
      - send_welcome_email
      - update_metrics
      
  customer.subscription.deleted:
    actions:
      - revoke_access
      - send_offboarding_email
      - trigger_retention_flow
      
  invoice.payment_failed:
    actions:
      - send_dunning_email
      - update_subscription_status
      - create_support_ticket

订阅管理

方案配置
subscription_plans:
  - name: Starter
    id: plan_starter
    price: 29
    currency: usd
    interval: month
    features:
      - "5 users"
      - "10GB storage"
      - "Email support"
    metadata:
      tier: 1
      
  - name: Growth
    id: plan_growth
    price: 79
    currency: usd
    interval: month
    features:
      - "25 users"
      - "100GB storage"
      - "Priority support"
    metadata:
      tier: 2
      
  - name: Enterprise
    id: plan_enterprise
    price: custom
    interval: month
    features:
      - "Unlimited users"
      - "Unlimited storage"
      - "24/7 support"
      - "Custom integrations"
    metadata:
      tier: 3
订阅生命周期
subscription_automation:
  on_create:
    - provision_service
    - send_welcome_email
    - create_customer_record
    - schedule_onboarding_call
    
  on_upgrade:
    - adjust_limits
    - prorate_billing
    - send_upgrade_confirmation
    - unlock_features
    
  on_downgrade:
    - schedule_limit_reduction
    - send_downgrade_notice
    - offer_retention_discount
    
  on_cancel:
    - schedule_access_revocation
    - send_exit_survey
    - trigger_win_back_campaign
    
  on_renewal:
    - send_renewal_receipt
    - update_usage_quotas
    - check_plan_eligibility

发票管理

发票自动化
invoice_settings:
  defaults:
    auto_advance: true
    collection_method: charge_automatically
    days_until_due: 30
    
  templates:
    header:
      company_name: "{{company}}"
      logo: "{{logo_url}}"
      
    footer:
      payment_terms: "Net 30"
      thank_you: "Thank you for your business!"
      
  automation:
    - event: invoice.created
      actions:
        - add_line_items
        - apply_discounts
        - calculate_tax
        
    - event: invoice.finalized
      actions:
        - send_to_customer
        - log_to_accounting
        
    - event: invoice.paid
      actions:
        - send_receipt
        - update_revenue
逾期催收管理
dunning_sequence:
  - day: 0
    event: payment_failed
    actions:
      - retry_payment
      - email_template: payment_failed_1
      
  - day: 3
    actions:
      - retry_payment
      - email_template: payment_failed_2
      - sms_reminder
      
  - day: 7
    actions:
      - retry_payment
      - email_template: payment_failed_3
      - mark_at_risk
      
  - day: 14
    actions:
      - final_retry
      - email_template: final_notice
      - pause_subscription
      
  - day: 30
    actions:
      - cancel_subscription
      - email_template: cancellation
      - revoke_access

结账集成

结账会话
// Create Checkout Session
const session = await stripe.checkout.sessions.create({
  mode: 'subscription',
  payment_method_types: ['card'],
  line_items: [{
    price: 'price_xxx',
    quantity: 1,
  }],
  success_url: 'https://example.com/success?session_id={CHECKOUT_SESSION_ID}',
  cancel_url: 'https://example.com/cancel',
  customer_email: '[email protected]',
  subscription_data: {
    trial_period_days: 14,
    metadata: {
      plan_tier: 'growth'
    }
  },
  allow_promotion_codes: true,
});
支付元素
// Create Payment Intent
const paymentIntent = await stripe.paymentIntents.create({
  amount: 2000,
  currency: 'usd',
  customer: 'cus_xxx',
  payment_method_types: ['card'],
  metadata: {
    order_id: '12345'
  }
});

// Confirm Payment
const result = await stripe.confirmCardPayment(
  paymentIntent.client_secret,
  {
    payment_method: {
      card: cardElement,
      billing_details: {
        name: 'John Doe'
      }
    }
  }
);

收入分析

仪表板指标
STRIPE REVENUE DASHBOARD
═══════════════════════════════════════

MRR:          $125,450 (+8.5%)
ARR:          $1,505,400
New MRR:      $12,340
Churned MRR:  $4,120
Net MRR:      +$8,220

SUBSCRIPTION BREAKDOWN:
Active:       892
Trialing:     156
Past Due:     23
Cancelled:    45 (this month)

BY PLAN:
Starter    ████████░░░░░░░░ 45%  │ $28,500
Growth     ██████████░░░░░░ 38%  │ $47,600
Enterprise ██████░░░░░░░░░░ 17%  │ $49,350

CHURN ANALYSIS:
Monthly Churn Rate:  4.2%
MRR Churn:          $4,120
Reasons:
- Price             ████████░░░░ 35%
- Competitor        ██████░░░░░░ 25%
- No longer needed  ████░░░░░░░░ 20%
- Support issues    ███░░░░░░░░░ 12%
- Other             ██░░░░░░░░░░ 8%
队列分析
cohort_metrics:
  - cohort: "2024-01"
    customers: 150
    month_1_retention: 95%
    month_3_retention: 82%
    month_6_retention: 71%
    ltv_estimate: $890
    
  - cohort: "2024-02"
    customers: 180
    month_1_retention: 93%
    month_3_retention: 79%
    ltv_estimate: $820

欺诈防范

风险规则
radar_rules:
  - name: block_high_risk
    condition: "risk_level = 'highest'"
    action: block
    
  - name: review_elevated_risk
    condition: "risk_level = 'elevated'"
    action: review
    
  - name: block_disposable_email
    condition: "email_domain in @disposable_domains"
    action: block
    
  - name: velocity_check
    condition: "card_country != ip_country"
    action: review
    
  - name: amount_threshold
    condition: "amount > 100000"  # $1000
    action: review

客户门户

门户配置
customer_portal:
  features:
    subscription_update:
      enabled: true
      products:
        - product_starter
        - product_growth
        - product_enterprise
      proration_behavior: create_prorations
      
    subscription_cancel:
      enabled: true
      mode: at_period_end
      cancellation_reason:
        enabled: true
        options:
          - "Too expensive"
          - "Missing features"
          - "Switched to competitor"
          - "No longer needed"
          - "Other"
          
    payment_method_update:
      enabled: true
      
    invoice_history:
      enabled: true
      
  branding:
    colors:
      primary: "#5469d4"
    icon: "{{company_icon}}"

报告自动化

定期报告
reports:
  - name: daily_revenue
    schedule: "0 9 * * *"
    metrics:
      - gross_volume
      - net_volume
      - new_customers
      - failed_payments
    destination: slack_finance
    
  - name: weekly_mrr
    schedule: "0 9 * * 1"
    metrics:
      - mrr
      - arr
      - churn_rate
      - expansion_revenue
    destination: email_leadership
    
  - name: monthly_reconciliation
    schedule: "0 9 1 * *"
    metrics:
      - total_revenue
      - fees
      - refunds
      - payouts
    destination: accounting_system

API 示例

常见操作
// Create Customer
const customer = await stripe.customers.create({
  email: '[email protected]',
  name: 'John Doe',
  metadata: {
    user_id: '12345'
  }
});

// Create Subscription
const subscription = await stripe.subscriptions.create({
  customer: customer.id,
  items: [{ price: 'price_xxx' }],
  trial_period_days: 14,
  payment_behavior: 'default_incomplete',
  expand: ['latest_invoice.payment_intent']
});

// Update Subscription
await stripe.subscriptions.update(subscription.id, {
  items: [{
    id: subscription.items.data[0].id,
    price: 'price_new_xxx'
  }],
  proration_behavior: 'create_prorations'
});

// Issue Refund
const refund = await stripe.refunds.create({
  payment_intent: 'pi_xxx',
  amount: 1000  // Partial refund
});

最佳实践

  1. 使用 Webhook:不要只依赖重定向
  2. 幂等键:防止重复扣款
  3. 错误处理:优雅地恢复失败
  4. PCI 合规性:使用 Stripe Elements
  5. 测试模式:在生产环境使用前进行验证
  6. 监控争议:及时响应
  7. 逾期催收策略:挽回失败的支付
  8. 收入确认:正确跟踪 MRR

评论

支持 Markdown