#Charmon

1 messages · Page 1 of 1 (latest)

short crestBOT
hollow agate
#

I think the fastest way to check is look at your request log at Dashboard to see how it is converted

gray hull
hollow agate
#

Can you locate the request id? req_xxx

#

And see how your parameters look like

gray hull
#

I can't locate it, it doesn't appear under logs for some reason?

#

I see it in the webhooks section, but not in the logs section

hollow agate
#

Can you provide the Subscription Id here? sub_xxx

gray hull
#

the only difference to this subscription from what i tested before, is that the person applied 100% coupon, but I don't know if that should make any difference?

short crestBOT
hollow agate
#

This Sub was created via a Checkout Session

#

Okie probably you need to look at your dashboard request log but enable "Connect request"

gray hull
#

Where do i enable connect request?

hollow agate
#

Uhm I think you may haven't generated the request at all. You probably would want to tweak the option (comment out and in) and more log around that stripeConnectAccountOptions parameter. It looks like the SDK stopped it before even sending out the request

gray hull
#

you mean I should test it without the option?

hollow agate
#

Yep. I see the Subs belongs to acct_1CV1GkIL0HJB3ySi directly, not any Connected Account

tawdry badger
#

Hey! Taking over for my colleague. Let me catch up.

gray hull
# hollow agate Yep. I see the Subs belongs to `acct_1CV1GkIL0HJB3ySi ` directly, not any Connec...

just a question - would it be better to have 2 different functions for managing subscriptions, one for regular subscriptions and one for stripe connected account subscriptions.
at the moment I have too much of conditional logic:

          case 'customer.subscription.created':
          case 'customer.subscription.updated':
          case 'customer.subscription.deleted':
            const subscription = event.data.object as Stripe.Subscription;
            await manageSubscriptionStatusChange(
              subscription.id,
              subscription.customer as string,
              event.type === 'customer.subscription.created',
              subscription.metadata?.stripe_connect_account_id ?? null
            );
            break;
hollow agate
#

Normally you need to separate 2 different endpoints one for your Account and one for your Connected Account, and use separated logic to handle each of them

#

Then you won't have this headache TBH

#

I am stepping down for the day but my colleague will continue to assist you. Good luck!

tawdry badger
#

Let me know if there's any follow-up Qs I can answer!

gray hull
#

yes one sec

#

When you say different endpoint, ALL events are still going to be sent to both endpoints right?

Let's say I have webhooks and stripeConnectWebhooks endpoints

tawdry badger
#

ALL events are still going to be sent to both endpoints right?
Let's say I have webhooks and stripeConnectWebhooks endpoints
You'll receive Account Event on the Account Webhook Endpoint, and you'll receive Connect Events on the Connect Webhook endpoint.

gray hull
# tawdry badger > ALL events are still going to be sent to both endpoints right? > Let's say I ...

so account event endpoints still register all stripe connected account events such as:

const relevantEvents = new Set([
  'product.created',
  'product.updated',
  'price.created',
  'price.updated',
  'checkout.session.completed',
  'customer.subscription.created',
  'customer.subscription.updated',
  'customer.subscription.deleted'
  // 'charge.succeeded'
]);

Because I thought account events were only limited to things like "bank_account_connected" or something limited like that

tawdry badger
#

Actually in Stripe there is two different Account Types. The platform Accounts aka the main Account, and Connected Accounts that are connected to the platform/main accounts.... Same event, like product.created can be triggered on both types depending what account has triggered the action (In this case, the account that created a product)

gray hull
#

so if I add another endpoint and with "events on connected accounts" toggled that means that all events that happened on behalf of my stripe connected accounts will be sent to this endpoint? Whether it's subscription created, product created or etc?

#

and I wouldn't have to use any of the conditional logic to determine if I need to use stripe account headers like this:

  const tableName = stripeConnectAccountId
    ? 'stripe_connect_customers'
    : 'customers';
  const { data: customerData, error: noCustomerError } = await supabaseAdmin
    .from(tableName)
    .select('id')
    .eq('stripe_customer_id', customerId)
    .single();

  if (noCustomerError) {
    console.log('no customer error');
    throw noCustomerError;
  }

  const { id: uuid } = customerData!;

  const stripeConnectAccountOptions = stripeConnectAccountId
    ? { stripeAccount: stripeConnectAccountId }
    : {};

  console.log({
    subscriptionId,
    stripeConnectAccountOptions
  });

Instead, I would know for fact that that event was made by stripe connect account

tawdry badger
#

so if I add another endpoint and with "events on connected accounts" toggled that means that all events that happened on behalf of my stripe connected accounts will be sent to this endpoint? Whether it's subscription created, product created or etc?
Yes, check this guide to understand the concept:
https://stripe.com/docs/connect/webhooks
and I wouldn't have to use any of the conditional logic to determine if I need to use stripe account headers like this:
Yes.
Instead, I would know for fact that that event was made by stripe connect account
You may still want to check the accountId that the event was triggered for

gray hull
#

Okay, thank you very much, alot has been cleared, I'm just gonna read that and try to implement it!

tawdry badger
#

Cool!