#nerder-direct-charges

1 messages ยท Page 1 of 1 (latest)

sullen wharf
#

Hi there ๐Ÿ‘‹ it looks like you're trying to make a direct charge, and in that case you would use your platform's API key, and provide the connected account's ID in the stripeAccount parameter.

frozen dome
#

ok cool

#

but that's quite strange

#

because how can I put a price there?

#
    const stripe = new Stripe(PLATFORM_SECRET_API_KEY, { apiVersion: '2020-08-27' });
    const subscription = await stripe.subscriptions.create(
      {
        customer: customerId,
        items: [
          {
            price: priceId, //of the price created in the connected account
          },
        ],
        application_fee_percent: 0.8,
        expand: ['latest_invoice.payment_intent'],
      },
      {
        stripeAccount: 'ACCOUNT_ID_OF_CONNECTED_ACCOUNT',
      },
    );
#

should be like this?

sullen wharf
#

That looks right, is it not doing what you're expecting?

frozen dome
#

is not what we are actually doing

#

right now we are doing it like this

#
   const stripe = new Stripe(CONNECTED_ACCOUNT_SECRET_API_KEY, { apiVersion: '2020-08-27' });
    const subscription = await stripe.subscriptions.create(
      {
        customer: customerId,
        items: [
          {
            price: priceId, //of the price created in the connected account
          },
        ],
        application_fee_percent: 0.8,
        expand: ['latest_invoice.payment_intent'],
      },
      {
        stripeAccount: 'ACCOUNT_ID_OF_PLATFORM',
      },
    );
sullen wharf
#

Ah, so in that approach you're actually making the call as the connected account, which won't allow you to collect an application fee percent.

frozen dome
#

ok now I got it!

#

that's very interesting

#

because we put in place a whole structure to choose base on the caller which private key to use

#

but in this way it makes way more simpler

#

every account is connected to our, so we create the subscription using our secret key

#

i'll try that real quick, but it makes much sense it was like that

sullen wharf
#

๐Ÿ‘ glad to hear, let us know if it gives you any trouble though

frozen dome
#

It worked! ๐ŸŽ‰

#

thank you so much

sullen wharf
#

๐Ÿฅณ Woohoo!