Get Stripe Account ID

User
How I get stripeAccount id
Assistant
To get a **Stripe Account ID**, the method depends on whether you want:

### ✅ 1. **Your own (platform's) Stripe Account ID**
You can find this in the **Stripe Dashboard**:

– Go to [https://dashboard.stripe.com/settings/account](https://dashboard.stripe.com/settings/account)
– You’ll see something like: `acct_1ABC23XYZ456` — this is your **Stripe Account ID**

### ✅ 2. **Connected Account’s ID** (if you're using Stripe Connect)

If you are creating **connected accounts** (for platforms or marketplaces), the Stripe Account ID is returned when you create the connected account via the API.

#### Example using PHP:

StripeStripe::setApiKey('sk_test_...');

$account = StripeAccount::create([
  'type' => 'express',
  'country' => 'US',
  'email' => 'user@example.com',
]);

echo $account->id; // 👉 this is the connected account ID like 'acct_1ABC23XYZ456'

Save this ID to your database — it’s used in all further interactions with that connected account.

### ✅ 3. **Retrieve it from an existing account**

If you’ve already created a connected account and stored its ID, you can retrieve it via:

$account = StripeAccount::retrieve('acct_1ABC23XYZ456');

### 💡 Tips
– Use `acct_…` IDs only on server-side with secret keys (`sk_…`)
– Never expose secret keys on the frontend
– For platforms, this ID is used in `stripeAccount` parameter when creating charges, transfers, etc.

Let me know which case you're working on (own account vs connected accounts), and I can guide you more specifically.

User
Can only apply an application_fee_amount when the PaymentIntent is attempting a direct payment (using an OAuth key or Stripe-Account header) or destination payment (using `transfer_data[destination]`)
when using staging api jeys
Assistant
The error you're seeing:

> **"Can only apply an application_fee_amount when the PaymentIntent is attempting a direct payment (using an OAuth key or Stripe-Account header) or destination payment (using `transfer_data[destination]`)"**

means that Stripe **only allows `application_fee_amount`** if the payment is processed **on behalf of a connected account**, either:

### ✅ 1. **Direct Charge**
(using **OAuth key** or setting `Stripe-Account` header)

StripeStripe::setApiKey('sk_test_platform_key');

$paymentIntent = StripePaymentIntent::create([
  'amount' => 1000,
  'currency' => 'usd',
  'application_fee_amount' => 100, // <-- this requires one of the below
], [
  'stripe_account' => 'acct_xxx_connectedAccountId', // 👈 Required
]);

### ✅ 2. **Destination Charge**
(using `transfer_data[destination]`)

$paymentIntent = StripePaymentIntent::create([
  'amount' => 1000,
  'currency' => 'usd',
  'application_fee_amount' => 100,
  'transfer_data' => [
    'destination' => 'acct_xxx_connectedAccountId', // 👈 Required
  ],
]);

### ❌ You're Getting the Error Because:
You're setting `application_fee_amount` but **not specifying the connected account** using either:
– `stripe_account` header (for direct charge), or
– `transfer_data[destination]` (for destination charge)

### ✅ Fix

Update your code to include the connected account when creating the `PaymentIntent`.

#### Example Fix (destination charge):

$paymentIntent = StripePaymentIntent::create([
  'amount' => 1000,
  'currency' => 'usd',
  'application_fee_amount' => 100,
  'transfer_data' => [
    'destination' => 'acct_xxxx', // your connected account ID
  ],
]);

Let me know:
– Are you using **Express**, **Standard**, or **Custom** accounts?
– Are you using **destination charges** or **direct charges**?
– What language or SDK (PHP, Node, etc.) are you using?

I’ll tailor the code accordingly.

Leave a Comment

Your email address will not be published. Required fields are marked *