APIリファレンス保存したカード

保存したカード

取引先が同意して保存したカードを使う(テスト環境のみ)

GET/v1/clients/{id}/saved-cards

取引先が保存したカードの一覧

取引先が同意して保存したカードを、新しい順に返します。カード番号は返さず、ブランド・末尾4桁・期限・同意した文言だけです。

パスの値

  • idstring必須

    100文字まで

返る項目data の中身 · 200

  • idstring
  • clientIdstring
  • brandstring | null
  • last4string | null
  • expMonthinteger | null
  • expYearinteger | null
  • statusenum
    activerevoked
  • testModeboolean

    テストモードで保存したカード

  • consentTextstring

    取引先が同意した文言

  • consentedAtstring (date-time)
  • revokedAtstring (date-time) | null

起こりうるエラー共通のエラー

  • 403insufficient_scope

    キーにこの入口の権限(scope)が付いていない。requiredScopes に必要な権限が入ります

  • 404not_found

    対象がない、またはこのワークスペースのものではない

GET/v1/…/{id}/saved-cards
curl https://tooon.app/api/v1/clients/clx8k2m0a0001/saved-cards \
  -H "Authorization: Bearer $TOOON_API_KEY"
レスポンス
{
  "data": [
    {
      "id": "clx8k2m0a0001",
      "clientId": "clx8k2m0a0001",
      "brand": "…",
      "last4": "…",
      "expMonth": 0,
      "expYear": 0,
      "status": "active",
      "testMode": true,
      "consentText": "…",
      "consentedAt": "2026-11-01T09:00:00.000Z",
      "revokedAt": "2026-11-01T09:00:00.000Z"
    }
  ]
}
POST/v1/saved-cards/{id}/revoke

保存したカードを解除する

取引先から解除を頼まれたときなどに、理由つきで解除します。Stripe からも外し、次から請求に使えません。

パスの値

  • idstring必須

    100文字まで

送る項目JSON · 1項目

  • reasonstring必須

    300文字まで

返る項目data の中身 · 200

  • idstring
  • clientIdstring
  • brandstring | null
  • last4string | null
  • expMonthinteger | null
  • expYearinteger | null
  • statusenum
    activerevoked
  • testModeboolean

    テストモードで保存したカード

  • consentTextstring

    取引先が同意した文言

  • consentedAtstring (date-time)
  • revokedAtstring (date-time) | null

起こりうるエラー共通のエラー

  • 400invalid_request

    送った値が正しくない。message にどこが違うかが入ります

  • 403insufficient_scope

    キーにこの入口の権限(scope)が付いていない。requiredScopes に必要な権限が入ります

  • 404not_found

    対象がない、またはこのワークスペースのものではない

POST/v1/…/{id}/revoke
curl -X POST https://tooon.app/api/v1/saved-cards/clx8k2m0a0001/revoke \
  -H "Authorization: Bearer $TOOON_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
  "reason": "…"
}'
レスポンス
{
  "data": {
    "id": "clx8k2m0a0001",
    "clientId": "clx8k2m0a0001",
    "brand": "…",
    "last4": "…",
    "expMonth": 0,
    "expYear": 0,
    "status": "active",
    "testMode": true,
    "consentText": "…",
    "consentedAt": "2026-11-01T09:00:00.000Z",
    "revokedAt": "2026-11-01T09:00:00.000Z"
  }
}
POST/v1/invoices/{id}/card-charges

保存したカードで請求書を払ってもらう

請求書の取引先が保存したカードで、請求額を払ってもらいます(画面のカード決済と同じ金額・手数料)。入金済みになるのは決済が確定したときで、invoice.paid の Webhook で届きます。カード会社の本人確認が要るときは requires_customer_action を返すので、取引先に支払いページを案内してください。同じ Idempotency-Key の再送は同じ結果を返します。いまはテストモードだけです。

パスの値

  • idstring必須

    100文字まで

送る項目JSON · 1項目

  • savedCardIdstring必須

    100文字まで

返る項目data の中身 · 200

  • idstring

    請求書のID

  • paymentIntentIdstring
  • resultenum
    succeededprocessingrequires_customer_actionfailed
  • failureCodestring | null
  • failureMessagestring | null

起こりうるエラー共通のエラー

  • 400invalid_request

    送った値が正しくない。message にどこが違うかが入ります

  • 403insufficient_scope

    キーにこの入口の権限(scope)が付いていない。requiredScopes に必要な権限が入ります

  • 404not_found

    対象がない、またはこのワークスペースのものではない

POST/v1/…/{id}/card-charges
curl -X POST https://tooon.app/api/v1/invoices/clx8k2m0a0001/card-charges \
  -H "Authorization: Bearer $TOOON_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
  "savedCardId": "clx8k2m0a0001"
}'
レスポンス
{
  "data": {
    "id": "clx8k2m0a0001",
    "paymentIntentId": "clx8k2m0a0001",
    "result": "succeeded",
    "failureCode": "…",
    "failureMessage": "…"
  }
}