Stripe 付款流程

API SOP

完整付款序列:建立客戶、建立付款意圖、確認付款、檢查狀態、發送收據。

5 個節點 · 5 條連接api sops
apistripepaymentsop
視覺化
POST /v1/customersapi

建立含電子郵件與後設資料的 Stripe 客戶

sequentialPOST /v1/payment_intents
POST /v1/payment_intentsapi

為客戶建立付款意圖

sequentialPOST /v1/payment_intents/{id}/confirm
POST /v1/payment_intents/{id}/confirmapi

使用付款方式確認付款意圖

sequentialGET /v1/payment_intents/{id}
fallbackPOST /v1/payment_intents
GET /v1/payment_intents/{id}api

確認付款成功

conditional產生收據電子郵件
產生收據電子郵件agent

AI 根據付款詳情產生個人化收據電子郵件

ex-sop-stripe-payment.osop.yaml
osop_version: "1.0"
id: "sop-stripe-payment"
name:"Stripe 付款流程"
description:"完整付款序列:建立客戶、建立付款意圖、確認付款、檢查狀態、發送收據。"
tags: [api, stripe, payment, sop]

nodes:
  - id: "create_customer"
    type: "api"
    subtype: "rest"
    name: "POST /v1/customers"
    description: "建立含電子郵件與後設資料的 Stripe 客戶"
    runtime:
      method: "POST"
      url: "https://api.stripe.com"
      endpoint: "/v1/customers"
      headers:
        Authorization: "Bearer ${secrets.STRIPE_SECRET_KEY}"
        Content-Type: "application/x-www-form-urlencoded"
      body:
        email: "user@example.com"
        name: "John Doe"
    outputs:
      - customer_id: "data.id"

  - id: "create_intent"
    type: "api"
    subtype: "rest"
    name: "POST /v1/payment_intents"
    description: "為客戶建立付款意圖"
    runtime:
      method: "POST"
      url: "https://api.stripe.com"
      endpoint: "/v1/payment_intents"
      headers:
        Authorization: "Bearer ${secrets.STRIPE_SECRET_KEY}"
      body:
        amount: 2000
        currency: "usd"
        customer: "${create_customer.customer_id}"
    outputs:
      - intent_id: "data.id"
      - client_secret: "data.client_secret"

  - id: "confirm_payment"
    type: "api"
    subtype: "rest"
    name: "POST /v1/payment_intents/{id}/confirm"
    description: "使用付款方式確認付款意圖"
    runtime:
      method: "POST"
      url: "https://api.stripe.com"
      endpoint: "/v1/payment_intents/${create_intent.intent_id}/confirm"
      headers:
        Authorization: "Bearer ${secrets.STRIPE_SECRET_KEY}"
      body:
        payment_method: "pm_card_visa"

  - id: "check_status"
    type: "api"
    subtype: "rest"
    name: "GET /v1/payment_intents/{id}"
    description: "確認付款成功"
    runtime:
      method: "GET"
      url: "https://api.stripe.com"
      endpoint: "/v1/payment_intents/${create_intent.intent_id}"
      headers:
        Authorization: "Bearer ${secrets.STRIPE_SECRET_KEY}"
    outputs:
      - status: "data.status"

  - id: "send_receipt"
    type: "agent"
    subtype: "llm"
    name: "產生收據電子郵件"
    description: "AI 根據付款詳情產生個人化收據電子郵件"
    runtime:
      provider: "anthropic"
      model: "claude-sonnet-4-6"
      system_prompt: "Generate a payment receipt email. Be concise and professional."

edges:
  - from: "create_customer"
    to: "create_intent"
    mode: "sequential"
  - from: "create_intent"
    to: "confirm_payment"
    mode: "sequential"
  - from: "confirm_payment"
    to: "check_status"
    mode: "sequential"
  - from: "check_status"
    to: "send_receipt"
    mode: "conditional"
    condition: "check_status.status == 'succeeded'"
  - from: "confirm_payment"
    to: "create_intent"
    mode: "fallback"