#TuanPham

1 messages · Page 1 of 1 (latest)

winged comet
#

Hi, I think you might have been missing some steps

#

one moment

#

In your Platform, your PaymentMethod should be attached to a customer first

#

then you want to clone both the Payment Method and the Customer to the Connected Account

peak axle
#

yup, I'm trying to do that way

#

But when I try to attach my PlatformPaymentMethod to my platformCustomer

#

It says that no such customer even when I checked in the dashboard still have a customer with that id on the platform account

winged comet
#

When attaching do you not use the stripe-account header?

#

If you use stripe account header the API will look into the connected account

peak axle
#

I use via stripe instance like this

#

await this.stripe.paymentMethods.attach(paymentMethodId, {
customer: platformCustomer.stripe_customer_id,
});

winged comet
#

Let's confirm it by looking at your Platform requests log

#

Can you get me that request id? req_xxx

peak axle
#

You mean the request id when I attach my platformPaymentMethod to my platformCustomer right?

winged comet
#

yes

peak axle
#

just a minute

#

hmm

#

I'm sorry. It's my lunch time here

#

Can I reply you in the afternoon ?

winged comet
#

Sure np

winged comet
#

@peak axle Seeing you were typing. Any follow up?

peak axle
#

Hi @winged comet , sorry for the delay. Somehow, I managed to fix my problems. But It comes into new one. I can not catch the event customer.subscription.created in my hook service . When I create a subscription, I can catch the event charge.succeeded only. Can you help me with this ?

delicate knoll
#

do you have the ID sub_xxx of the subscription you created so I can check some details?

peak axle
#

sure

#

sub_1LFvrl2ELzgUanaaprOdquZj

delicate knoll
#

so you create this subscription on a connected account using the Stripe-Account header

#

that means to listen to the event, you need to create a "Connect endpoint" on your platform account

#

you do seem to have such an endpoint though, so let me check something

peak axle
#

yup. take your time

delicate knoll
#

as far as we can tell we sent you that event just fine

#

it's evt_1LFvrp2ELzgUanaaMGRPWp11, we sent it to your URL https://staging-api-*******/v1/hooks/connect at 2022-06-29 08:03:21 UTC and you responded with a 201 status with {"received":true}

peak axle
#

is it related to my stripe config ?

#

somehow, I still catch the event charge.succeeded

#

So I think it seems like not the problem from your server

delicate knoll
peak axle
#

hmm, it is badly weird.

#

let me check one more time

peak axle
#

It seems like my webhook type Direct not works because I do not forward it to my local listeners

delicate knoll
#

hmm, ok!

peak axle
#

But, If I forward by this command : stripe listen --forward-to localhost:8082/v1/hooks/connect.
It is supposed to forward both Direct or Connect type to my local host, right ?

delicate knoll
#

not sure, I think maybe not? you might have to use --forward-to and --forward-connect-to together

peak axle
#

lemme try this

#

hmm, It does not work.

delicate knoll
#

what does "does not work" mean exactly?

#

what command did you run, what did you expect to see, what did you see instead?

peak axle
#

hmm, I run stripe listen --forward-connect-to localhost:8082/v1/hooks/connect

#

I expected to catch event customer.subscription.created

#

I saw it said that [ERROR] Failed to POST: Post "http://localhost:8082/v1/hooks/connect": dial tcp [::1]:8082: connectex: No connection could be made because the target machine actively refused it

lavish frost
#

👋 I'm stepping in for my colleague

peak axle
#

yup

#

We just try to find a way to forward stripe hooks which has type Direct into my local host

lavish frost
#

basically when this error happens this means that the tcp port 8082 is not running on your machine

peak axle
#

hmm, but I already forwarded it by adb reverse tcp:8082 tcp:8082 in my app

#

I think I should deploy it and try the payment one more time

lavish frost
#

how are you running your server

peak axle
#

I just run it in local

#

and my app connects via the localhost, then I use the stripe cli to forward the stripe hook into my localhost

lavish frost
#

what language are you using for your server?

peak axle
#

I use typescript with nestjs

#

I just checked the dashboard and I see that there is customer.subscription.created in my webhooks which has endpoint type Connect

#

But I don't know why it can listen to charge.succeeded event only. I did not specify only listen to this event in my stripe cli command

lavish frost
#

stripe cli will listen to all the events and is not related to the configuration you would do on a specific endpoint

#

could you please share the logs of your server when you run npm start on your nestjs server locally

peak axle
#

okay, let me get it

#

I'm sorry

#

It is my fault.

#

Because there are many events sending to my local host

#

so it can not hold all the logs

#

after I just comment all events and open just customer.subscription.created, I got the data I need

lavish frost
#

no worries, great to hear it's working now

peak axle
#

what a tough time

#

Thank you guys so much