# Mit Treasury für Plattformen und Issuing Finanzkonten und Karten einrichten

Schauen Sie sich ein Beispiel für die Integration von Treasury für Plattformen und Issuing an, bei dem ein Finanzkonto eingerichtet wird und Karten erstellt werden.

Homebox ist ein fiktives vertikales SaaS-Unternehmen, das Software für Hausmeisterunternehmen entwickelt, wie etwa Heizungs- und Sanitärinstallateure, Reinigungsanbieter und Gas-/Wasserinstallateure. Homebox beginnt seine Integration von Treasury für Plattformen durch mit der Einrichtung eines Finanzkontos und der Erstellung von Zahlungskarten. Um zu sehen, wie Homebox Geldbewegungen auf und von externen Konten bewerkstelligt, siehe die Beispielintegration [Mit Treasury für Plattformen Geldbewegungen durchführen](https://docs.stripe.com/treasury/connect/examples/moving-money.md).

## Plattform-Onboarding

Homebox ist bereits eine Stripe-Plattform, bei der [Payments](https://docs.stripe.com/payments.md) und [Connect](https://docs.stripe.com/connect.md) aktiviert sind. Homebox verwendet [nutzerdefinierte verbundene Konten](https://docs.stripe.com/connect/accounts.md), und für diese verbundenen Konten ist die Funktion `card_payments` bereits aktiviert.

## Funktionen hinzufügen

> #### Kompatibilität mit der Accounts v2 API
> 
> Die Accounts&nbsp;v2&nbsp;API unterstützt keine Treasury for platforms-Workflows. Wenn Sie Konten mit Accounts&nbsp;v2 erstellt haben, können Sie Accounts&nbsp;v1 verwenden, um die Funktionen `treasury` and `card_issuing` zu verwalten. Weitere Informationen finden Sie unter [Konten als Kundinnen und Kunden verwenden](https://docs.stripe.com/connect/use-accounts-as-customers.md).

Um Treasury für Plattformen und Issuing nutzen zu können, muss Homebox die zusätzlichen Funktionen `treasury` und `card_issuing` für die verbundenen Konten der Plattform anfordern. Alle verbundenen Konten müssen dann das Onboarding durchlaufen, bevor Stripe ein zugehöriges Finanzkonto erstellen kann.

Um ACH-Überweisungen mit Treasury für Plattformen zu verwenden, muss Homebox auch die Funktion `us_bank_account_ach_payments` anfordern.

Um die Funktionen `treasury`, `card_issuing` und `us_bank_account_ach_payments` anzufordern, stellt Homebox eine Anfrage an die [Accounts API](https://docs.stripe.com/api/accounts.md).

```curl
curl https://api.stripe.com/v1/accounts/{{CONNECTED_ACCOUNT_ID}} \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d "capabilities[treasury][requested]=true" \
  -d "capabilities[card_issuing][requested]=true" \
  -d "capabilities[us_bank_account_ach_payments][requested]=true"
```

Um das gehostete Onboarding zu verwenden, ruft Homebox [Konto-Links](https://docs.stripe.com/api/account_links.md) auf, um eine URL abzurufen, die ihr verbundenes Konto zum Übermitteln von Onboarding-Informationen für das Finanzkonto verwenden kann.

```curl
curl https://api.stripe.com/v1/account_links \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d "account={{CONNECTEDACCOUNT_ID}}" \
  --data-urlencode "refresh_url=https://example.com/reauth" \
  --data-urlencode "return_url=https://example.com/return" \
  -d type=account_onboarding
```

Die Antwort darauf enthält eine URL, mit der verbundene Konten auf das Anmeldeformular zugreifen können. Dies muss vor Ablauf des Links geschehen.

```json
{
  "object": "account_link",
  "created": 1612927106,
  "expires_at": 1612927406,"url": "https://connect.stripe.com/setup/s/iCtLfmYb2tEU"
}
```

Homebox hört den Webhook `account.updated` ab, um die folgenden Felder und Funktionen auf den verbundenen Konten zu bestätigen.

```json
{
  "object": {
    "id": "{{CONNECTED_ACCOUNT_ID}}",
    "object": "account",
    "capabilities": {
      "card_payments": "active",
      "treasury": "active",
      "card_issuing": "active", // Only appears if requesting the `card_issuing` capability.
      "us_bank_account_ach_payments": "active", // Only appears if requesting the `us_bank_account_ach_payments` capability.
    },
    ...
  }
}
```

## FinancialAccount erstellen

Sobald Stripe einem Konto die Funktion `treasury` hinzufügt, kann Homebox das `FinancialAccount`-Objekt für das Konto erstellen. Hierfür ruft Homebox die [Financial Accounts API](https://docs.stripe.com/api/treasury/financial_accounts.md) auf und fordert die `Features` an, die das Unternehmen bereitstellen möchte.

```curl
curl https://api.stripe.com/v1/treasury/financial_accounts \
  -u "<<YOUR_SECRET_KEY>>:" \
  -H "Stripe-Account: {{CONNECTEDACCOUNT_ID}}" \
  -d "supported_currencies[]=usd" \
  -d "features[card_issuing][requested]=true" \
  -d "features[deposit_insurance][requested]=true" \
  -d "features[financial_addresses][aba][requested]=true" \
  -d "features[inbound_transfers][ach][requested]=true" \
  -d "features[intra_stripe_flows][requested]=true" \
  -d "features[outbound_payments][ach][requested]=true" \
  -d "features[outbound_payments][us_domestic_wire][requested]=true" \
  -d "features[outbound_transfers][ach][requested]=true" \
  -d "features[outbound_transfers][us_domestic_wire][requested]=true"
```

Die Antwort bestätigt, dass das Konto bearbeitet wird. Nachdem die Verarbeitung abgeschlossen ist und alle relevanten Funktionen aktiviert wurden, erhält die Homebox eine Bestätigung vom Webhook-Listener `treasury.financial_account.features_status_updated`.

```json
{
  "object": "treasury.financial_account",
  "created": 1612927106,
  "id": "{{FINANCIAL_ACCOUNT_ID}}",
  "country": "US",
  "supported_currencies": ["usd"],
  "financial_addresses": [ // This field is empty until the "financial_addresses.aba" feature becomes active
    {
      "type": "aba",
      "supported_networks": ["ach", "us_domestic_wire"],
      "aba": {
        "account_number_last4": "7890",
        // Use the expand[] parameter to view the `account_number` field hidden by default
        "account_number": "1234567890",
        "routing_number": "000000001",
        "bank_name": "Bank of Earth"
      }
    }
  ],
  "livemode": true,

  // State machine:
  // open - the account is ready to be used
  // closed - the account is closed
  "status": "open",
  "status_details": {
    // `closed` is null if financial account is not closed
    "closed": {
      // List of one or more reasons why the FinancialAccount was closed:
      // - account_rejected
      // - closed_by_platform
      // - other
      "reasons": []
    }
  },

  "active_features": ["card_issuing"],
  "pending_features": ["deposit_insurance", "financial_addresses.aba", "outbound_payments.ach", "us_domestic_wire", "inbound_transfers.ach", "outbound_transfers.ach", "outbound_transfers.us_domestic_wire"],
  "restricted_features": [],

  "features": {
    "object": "treasury.financial_account_features",
    "card_issuing": {
      "status": "active",
      "status_details": [],
      "access": "active"
    },
    "deposit_insurance": {
      "requested": true,
      "status": "pending", // Becomes "active" after the financial account is set up
      "status_details": [{"code": "activating", "resolution": null}]
    },
    "financial_addresses": {
      "aba": {
        "requested": true,
        "status": "pending", // Becomes "active" after the financial account is set up
        "status_details": [{"code": "activating", "resolution": null}]
      }
    },
    "outbound_payments": {
      "ach": {
        "requested": true,
        "status": "pending", // Becomes "active" after the financial account is set up
        "status_details": [{"code": "activating", "resolution": null}]
      },
      "us_domestic_wire": {
        "requested": true,
        "status": "pending", // Becomes "active" after the financial account is set up
        "status_details": [{"code": "activating", "resolution": null}]
      }
    },
    "inbound_transfers": {
      "ach": {
        "requested": true,
        "status": "pending", // Becomes "active" after the financial account is set up
        "status_details": [{"code": "activating", "resolution": null}]
      }
    },
    "outbound_transfers": {
      "ach": {
        "requested": true,
        "status": "pending", // Becomes "active" after the financial account is set up
        "status_details": [{"code": "activating", "resolution": null}]
      },
      "us_domestic_wire": {
        "requested": true,
        "status": "pending", // Becomes "active" once the financial account is set up
        "status_details": [{"code": "activating", "resolution": null}]
      }
    }
  },
  "platform_restrictions": {
    "inbound_flows": "unrestricted",
    "outbound_flows": "unrestricted"
  },
  "metadata": {},
  ...
}

```

## Zahlungskarteninhaber/in erstellen

Bevor Homebox Karten für Finanzkonten erstellen kann, muss es zunächst Karteninhaber/innen anlegen. In diesem Beispiel handelt es sich dabei um Klempnerfirmen, die die Dienstleistungen von Homebox nutzen und denen die die verbundenen Konten der Plattform gehören.

# Dashboard

> This is a Dashboard for when testing-method is without-code. View the full page at https://docs.stripe.com/treasury/connect/examples/financial-accounts?testing-method=without-code.

1. Rufen Sie die Seite [Verbundene Konten](https://dashboard.stripe.com/test/issuing/cards) im Dashboard auf.
1. Wählen Sie das verbundene Konto aus, für das Sie eine/n Karteninhaber/in erstellen möchten, um dessen Details zu erweitern.
1. Wählen Sie die Registerkarte **Kartenausstellung** aus.
1. Klicken Sie auf die Schaltfläche **+** neben **Karteninhaber/innen**.
1. Geben Sie die Daten der Karteninhaberin/des Karteninhabers ein und klicken Sie auf **Karteninhaber/in erstellen**.


# API

> This is a API for when testing-method is with-code. View the full page at https://docs.stripe.com/treasury/connect/examples/financial-accounts?testing-method=with-code.

```curl
curl https://api.stripe.com/v1/issuing/cardholders \
  -u "<<YOUR_SECRET_KEY>>:" \
  -H "Stripe-Account: {{CONNECTEDACCOUNT_ID}}" \
  -d "name=Jenny Bath Remodeling" \
  -d type=company \
  --data-urlencode "email=jenny@example.com" \
  --data-urlencode "phone_number=+18008675309" \
  -d status=active \
  -d "billing[address][line1]=1234 Main Street" \
  -d "billing[address][city]=San Francisco" \
  -d "billing[address][state]=CA" \
  -d "billing[address][postal_code]=94111" \
  -d "billing[address][country]=US"
```

Die Antwort bestätigt, dass der/die Karteninhaber/in erstellt wurde.

```json
{
    "id": "{{CARDHOLDER_ID}}",
    "object": "issuing.cardholder",
    "billing": {
        "address": {
            "city": "\"San Francisco\"",
            "country": "US",
            "line1": "\"1234 Main Street\"",
            "postal_code": "94111",
            "state": "CA"
        }
    },
    "created": 1623803705,
    "email": "jenny@example.com",
    "livemode": false,
    "metadata": {},
    "name": "Jenny Bath Remodeling",
    "phone_number": "+18008675309",
    "requirements": {
        "disabled_reason": "under_review",
        "past_due": []
    },
    "spending_controls": {
        "allowed_categories": [],
        "blocked_categories": [],
        "spending_limits": []
    },
    "status": "active",
    "type": "company"
}
```


## Zahlungskarten erstellen

Nachdem das verbundene Konto nun mit einem `FinancialAccount`-Objekt und einem/einer verfügbaren Karteninhaber/in verknüpft ist, kann Homebox eine Zahlungskarte mit dem Guthaben des `FinancialAccount` als verfügbarem Saldo der Karte erstellen.

# Dashboard

> This is a Dashboard for when testing-method is without-code. View the full page at https://docs.stripe.com/treasury/connect/examples/financial-accounts?testing-method=without-code.

> Sie können keine [Finanzkonten](https://docs.stripe.com/treasury/connect/account-management/financial-accounts.md) im Dashboard erstellen. Sie müssen die API verwenden, um sie zu erstellen.

1. Rufen Sie die Seite [Verbundene Konten](https://dashboard.stripe.com/test/issuing/cards) im Dashboard auf.
1. Wählen Sie das verbundene Konto aus, für das Sie eine/n Karteninhaber/in erstellen möchten, um dessen Details zu erweitern.
1. Wählen Sie die Registerkarte **Kartenausstellung** aus.
1. Klicken Sie auf die Schaltfläche **+** neben **Karten**.
1. Wählen Sie den Kartentyp und das Finanzkonto aus, über das Sie die Karte aufladen möchten, und klicken Sie auf **Erstellen**.


# API

> This is a API for when testing-method is with-code. View the full page at https://docs.stripe.com/treasury/connect/examples/financial-accounts?testing-method=with-code.

```curl
curl https://api.stripe.com/v1/issuing/cards \
  -u "<<YOUR_SECRET_KEY>>:" \
  -H "Stripe-Account: {{CONNECTEDACCOUNT_ID}}" \
  -d currency=usd \
  -d type=virtual \
  -d "cardholder={{ISSUINGCARDHOLDER_ID}}" \
  -d "financial_account={{TREASURYFINANCIALACCOUNT_ID}}"
```

Die Antwort bestätigt, dass die Karte ausgestellt wurde.

```json
{
  "id": "{{CARD_ID}}",
  "object": "issuing.card",
  "cardholder": {
    "id": "{{CARDHOLDER_ID}}",
    "object": "issuing.cardholder",
    "billing": {
      "address": {
        "city": "San Francisco",
        "country": "US",
        "line1": "123 Main Street",
        "line2": null,
        "postal_code": "94111",
        "state": "CA"
      }
    },
    ...
  },
  "created": 1643293629,
  "currency": "usd",
  "exp_month": 12,
  "exp_year": 2024,
  "last4": "0930",
  "livemode": false,
  ...
}

```


## See also

- [Mit Treasury für Plattformen Geldbewegungen durchführen](https://docs.stripe.com/treasury/connect/examples/moving-money.md)
- [API-Dokumentation](https://docs.stripe.com/api/treasury/financial_accounts.md)
