#_nerder

1 messages ยท Page 1 of 1 (latest)

misty oreBOT
glacial stream
#

Hi ๐Ÿ‘‹

You should see one PM on the Platform account that you then clone to the Connected Account and attach to a customer.

frail storm
#

nope, i'm using payment methods not tokens

#

i'm doing this

glacial stream
#

I can't use dashboard links. They only go to your dashboard for you

frail storm
#

ah ok, sorry

#

this is the customer inside the PLATFORM: cus_Oo5UUhY5BPcT7P
this is the customer inside the CONNECTED ACCOUNT: cus_Oo95SnumAvkIaB

#

not sure if you can see them right now

glacial stream
#

Okay I can take a look at those

#

I see one Payment Method attached to the customer, 10 minutes ago

#

But two attached payment methods

#

Weird

#

Oh wait

frail storm
#

I don't really get where the other one is coming from

glacial stream
frail storm
#

Ok, i might know why is this happening

glacial stream
#

It looks like both requests came from your Node.js server so I'd double check

frail storm
#

Yes, let me check real quick with some logs

#

i'll come back to you

glacial stream
#

Okay cool

frail storm
#

No luck

#

I really have no clue from where the other payment method is coming from

#

since it gets attached after the subscription is created

glacial stream
#

Well both API calls were triggered from the Node.js server-side integration.

frail storm
#

might be a webhook

glacial stream
#

You can check your code for all the places where these two calls occur

frail storm
#

Ok, i spot something i'll test it

glacial stream
#

๐Ÿ‘

misty oreBOT
frail storm
#

I have a weird feeling that the second payment method is a temporary payment method which is created by stripe to clone

minor rapids
#

Hello! I'm taking over and catching up...

#

So you're seeing three total? One on the platform and two on the connected account?

frail storm
#

yes

#

but i don't have any other places in my codebase where i update the customer to attach a payment method

#

the only suspect I have is for when i confirm the payment intent in the frontend

#

this is the code i have in the backend

#
  async cloneIntoGym(gym: Gym, account: Account, customer: Customer, profileId: string): Promise<Customer> {
    this.logger.log(`Cloning customer with id [${customer.id}] inside account [${gym.accountId.value}]`);
    const clonedPaymentMethod = await this.stripe.paymentMethods.create(
      {
        customer: customer.id,
        payment_method: customer.paymentMethodId,
      },
      {
        stripeAccount: gym.accountId.value,
      },
    );

    const customerInGym = await this.stripe.customers.create(
      {
        email: account.primaryEmail,
        payment_method: clonedPaymentMethod.id,
        metadata: {
          uid: account.uid,
          profileId,
        },
      },
      {
        stripeAccount: gym.accountId.value,
      },
    );

    return Customer.of({ id: customerInGym.id, paymentMethodId: clonedPaymentMethod.id });
  }
#

And i've tested that if I don't complete the payment intent of the subscription only one payment method is created

minor rapids
#

Can you give me the three Payment Method IDs so I can take a look?

frail storm
#

yes gimme a sec

#

From the PLATFORM: pm_1O0XPwHTyY8xD8aG74Ahlg3r
From the CA:

pm_1O0XQ6LAVB3C1lDIxNO73dlp (this one is the correctly cloned)
pm_1O0XQ8LAVB3C1lDID6c4sDdP (this is the unexpected one)

#

what's very sus to me is that the expiry date is right 1 year from now

minor rapids
#

Looking, hang on...

frail storm
#

Damn, i've spotted it

minor rapids
#

Looks like one is being created client-side, one is being created server-side.

frail storm
#

this was my frontend code in Flutter:

  Future<void> confirmPayment({
    required User profile,
    required String clientSecret,
    required String paymentMethodId,
    String? onBehalfOf,
  }) async {
    _setupConnectedAccount(onBehalfOf);
    await _stripe.confirmPayment(
        paymentIntentClientSecret: clientSecret,
        data: const PaymentMethodParams.cardFromMethodId(
          paymentMethodData: PaymentMethodDataCardFromMethod(
            paymentMethodId: 'pm_card_visa',
          ),
        ));
  }
#

i forgot to pass the payment method down

minor rapids
#

Ah, yep.

frail storm
#

copilot suggested me that pm_card_visa id

#

I thought it would fail

minor rapids
#

No, that's a special test mode Payment Method ID that always works.

frail storm
#

TIL

#

wow

#

I'm so sorry for the confusion

minor rapids
#

No worries!

frail storm
#

๐Ÿคฆ

#

let me test by passing the correct ID instead

minor rapids
frail storm
#

I totally wasn't aware of those ids

#

it's good to know

#

All good now!

#

thank you again