#Salman

1 messages · Page 1 of 1 (latest)

elfin charmBOT
fresh cedar
#

hello! it can request for the connected account user to fill up their bank account. But what type of Connected account type are you using?

candid meadow
#

basically we want to ensure user has linked external account to his connect account during onboarding.... does it depend upon capabilities we request during account creation?? if so then which capability do i need to provide to ensure stripe collects user external account information too?

fresh cedar
#

which country is your platform account in?

candid meadow
fresh cedar
candid meadow
#

so it doen't depends upon capabilities we just need to turn on the settings from dashboard to ask for external_account information during connect onboarding...am i right?

grave vortex
#

I believe so, yep. Try it out

candid meadow
#

I'm testing a webhook with stripe cli but i am unable to receive events on backend
Here is my post api listening to webhooks:

const router = require("express").Router();
let stripeSecretKey = require("../config").stripeSecretKey;
let stripe = require("stripe")(stripeSecretKey);

const endpointSecret = "whsec_ec64d962.......13c7b651110e49115432fd45e4be340";

router.post("/webhook", express.raw({ type: "application/json" }), (request, response) => {
const sig = request.headers["stripe-signature"];

let event;
try {
    event = stripe.webhooks.constructEvent(request.body, sig, endpointSecret);
} catch (err) {
    return response.status(400).send(`Webhook Error: ${err.message}`);
}

console.log(event);

// if (event.type === "account.updated") {
if (event.type === "charge.succeeded") {
    const account = event.data.object;
    handleAccountUpdate(account);
}

response.json({ received: true });

});

const handleAccountUpdate = (account) => {
console.log(JSON.stringify(account));
};

module.exports = router;

grave vortex
#

Is there a specific error being thrown by your webhook handler?

candid meadow
#

no

#

although webhook is triggering events

grave vortex
#

Are you using stripe listen to listen for and forward the events to your endpoint?

candid meadow
#

login --> listen --forward-to ---> then trigger

grave vortex
#

Ok, and is your handler receiving the events?

candid meadow
#

route is working fine but can't receive/listen any event

grave vortex
#

Can you share the logs from your stripe listen command?

candid meadow
#

yeah sure

grave vortex
#

Can you paste an evt_xxx ID that the CLI has generated?

candid meadow
#

i can't see any id like that

grave vortex
#

You'd need to check the Dashboard

#

And there's no logs from your localhost:8080 application?

candid meadow
grave vortex
#

What's the acct_xxx ID?

#

I think you're signed in to a different account on the CLI

candid meadow
candid meadow
grave vortex
candid meadow
#

can you check my code?

grave vortex
#

I don't think your code is the issue here – clearly there's no events even being forwarded to your endpoint

candid meadow
#

then what the reason will be of events not being forwarded?

grave vortex
#

Wait. You need to listen before you trigger

#

Your listen command should always be running, in a separate tab or something

candid meadow
grave vortex
#

In your screenshot you're doing trigger then listen

grave vortex
#

That won't work

#

Did that help?

candid meadow
dense stirrup
#

Hi! I'm taking over this thread.

#

Getting a SignatureVerificationError is quite common. It usually comes from two potential errors:

  • You are using the wrong webhook secret. So please double check you are using the correct one. It should look like whsec_xxx and match the one displayed in your dashboard
  • The payload you pass in the constructEvent function is not the raw payload. So you need to ensure that you get the raw body of the HTTP request that Stripe sent you, without any interference by your code or framework in the middle.
    To debug this you'll need to add logging to log every value you pass to constructEvent (the payload, the secret, and the signature header) and then we can try to have a look at what part is wrong
candid meadow
#

let me see

#

I'm receiving this payload:

{
id: 'evt_3Mh9rfEMf7jvpGkr1fz2uHFm',
object: 'event',
api_version: '2022-11-15',
created: 1677754800,
data: {
object: {
id: 'ch_3Mh9rfEMf7jvpGkr1upQiQrs',
object: 'charge',
amount: 100,
amount_captured: 100,
amount_refunded: 0,
application: null,
application_fee: null,
application_fee_amount: null,
balance_transaction: 'txn_3Mh9rfEMf7jvpGkr1x55cuoH',
billing_details: [Object],
calculated_statement_descriptor: 'Stripe',
captured: true,
created: 1677754799,
currency: 'usd',
customer: null,
description: '(created by Stripe CLI)',
destination: null,
dispute: null,
disputed: false,
failure_balance_transaction: null,
failure_code: null,
failure_message: null,
fraud_details: {},
invoice: null,
livemode: false,
metadata: {},
on_behalf_of: null,
order: null,
outcome: [Object],
paid: true,
payment_intent: null,
payment_method: 'card_1Mh9rfEMf7jvpGkrL9qUewuD',
payment_method_details: [Object],
receipt_email: null,
receipt_number: null,
receipt_url: 'https://pay.stripe.com/receipts/payment/CAcaFwoVYWNjdF8xTWg3cHNFTWY3anZwR2tyKLCDgqAGMgYQPKTZEJ46LBb7xkl-rbLR7XNsc6lCNIO4dOBMejirmy1mK9XRHb4lvY-hBzNEBiHnhuRw',
refunded: false,
review: null,
shipping: null,
source: [Object],
source_transfer: null,
statement_descriptor: null,
statement_descriptor_suffix: null,
status: 'succeeded',
transfer_data: null,
transfer_group: null
}
},
livemode: false,
pending_webhooks: 2,
request: {
id: 'req_cwMaW0ozgvFXv2',
idempotency_key: 'd1c61eda-51df-4090-9e34-9e18a6ba765b'
},
type: 'charge.succeeded'
}

#

secret key is correct

dense stirrup
#

The payload should be a raw string, not a JSON object.

candid meadow
candid meadow
#

now it's working

dense stirrup
#

Awesome!