#gb34-Webhook

1 messages · Page 1 of 1 (latest)

muted rover
#

what webhook events are you currently listening to?

snow surge
#

charge.succeeded

#

On my server I only want to run my code for a given product

muted rover
snow surge
#

I'm not sure where to go edit that

#

is that something I have to do on the webhooks UI on stripe

#

dashboard

muted rover
snow surge
#

I'm actually doing my integration with Google App Script

#

this is what I am trying to get at

#
// current product ID
    var productID = '---productID------';

    // only want to listen to events concerning specified product.
    if (event["data"].object.id !== productID) {
      return;
    }
muted rover
snow surge
#

I actually didn't create any charges

#

may be I'm doing this wrong

muted rover
#

Or are you using payment Intent API?

snow surge
#

I am not using an API

#

I create an endpoint on my app script that only listens to the charge.succeeded event

#

and from there I run some code

#

I deployed a link then used it as my endpoint in stripe webhook section

#

I created the product using the stripe UI

#

do you recommend me using the payment_intent event instead?

#

will that give me the user name, email, and the productID?

#

Sorry if this was too much

#

btw I am a college senior working on a sponsored capstone project

muted rover
#

Are you using a 3rd-party plugin?

snow surge
#

No

muted rover
#

OK, then you need to check your code and see how did you make the charge (i.e., via either PaymentIntent / Charge / Checkout Session API), and then set the price/product info on the charge or payment_intent's metadata.

#

In this way, when the charge.succeeded or payment_intent.succeeded happens, you can retrieve the price/product info from the metadata of the received charge or payment_intent object

snow surge
#

I am not creating the charge programtically

#

all I'm doing is that I am listening to the charge.succeeded event

#

I wish I could just show you this on a video call

muted rover
#

I'm afraid that I can't join a call. Did you create the charge from Stripe Dashboard?

snow surge
#

yeah I did

muted rover
#

Got it, you can type in the product info in the description when creating a payment in Dashboard

snow surge
#

I am not sure how that will help

#

Am I making sense? Like do you get what I am trying to do?

muted rover
#

The idea here is to add in the product info when the payment is created, whether it's via Dashboard or API.

Based on your description, my understanding is that you are creating payments from Dashboard, and that's why I suggest you to type in the product info in the description field.

snow surge
#

Yes I'm creating the product payment link from Dashbaord

#

would the description field be part of my charge JSON object I receive on my backend from stripe

muted rover
#

Ah I see, I though you are creating payments, they are different things.

snow surge
#

So my thought was that I can listen for event only for a specific product

#

you know

#

why doesn't stripe add that productID in its JSON object

#

idk

#

I been try to figure this out for a long time now

light cave
#

Hi! I'm taking over Jack Tan.

snow surge
#

Hi

light cave
#

Could you summarise your question while I catchup?

snow surge
#

yeah

#

So I built an endpoint server on google app script, that listens to stripe charge.succeeded event. It runs some code using the data from the charge object

#

The idea in this project is that a user makes a payment using the stripe payment link that we created on the dashboard. after they submit that payment we get a notification (charge.succeeded) on our backend. Our backend will use the name and email that was entered on the payment link. we will email the user a link to take an assessment. This assessment is what we're pretty much selling (product)

#

The assessment is the product we created on the stripe dashboard

#

So at the moment we only have one product on our dashboard which is this assessment. If we add more products it will become a problem for our backend, because it will run everytime a charge.succeeded is made.

muted rover
light cave
#

Yes if you are using Payment Links, you should listen to the checkout_session.completed to get access to all the information about the Payment Link. The charge.succeeded event is a lot more limited.

snow surge
#
{
  "id": "cs_test_a16AGPuv0UVNuqOGpvHnAbYVNmbPLj1S7e6jPLbSf2bc6iMVUApBlq4vkN",
  "object": "checkout.session",
  "after_expiration": null,
  "allow_promotion_codes": null,
  "amount_subtotal": null,
  "amount_total": null,
  "automatic_tax": {
    "enabled": false,
    "status": null
  },
  "billing_address_collection": null,
  "cancel_url": "https://example.com/cancel",
  "client_reference_id": null,
  "consent": null,
  "consent_collection": null,
  "currency": null,
  "customer": null,
  "customer_creation": null,
  "customer_details": null,
  "customer_email": null,
  "expires_at": 1650962665,
  "livemode": false,
  "locale": null,
  "metadata": {},
  "mode": "payment",
  "payment_intent": "pi_1Dr1S92eZvKYlo2CrWdcRnWr",
  "payment_link": null,
  "payment_method_options": {},
  "payment_method_types": [
    "card"
  ],
  "payment_status": "unpaid",
  "phone_number_collection": {
    "enabled": false
  },
  "recovered_from": null,
  "setup_intent": null,
  "shipping": null,
  "shipping_address_collection": null,
  "shipping_options": [],
  "shipping_rate": null,
  "status": "expired",
  "submit_type": null,
  "subscription": null,
  "success_url": "https://example.com/success",
  "total_details": null,
  "url": null
}

```
#

is that what you're talking about?

light cave
snow surge
#

can this be done using the UI on stripe or this is something I have to do on my backend

#

Just to clarify

#

checkout_session.completed

light cave
#

Expanding the repsonse has to be done with code in your backend.

snow surge
#

checkout_session.completed will give me the name and email of the customer right

#

Okay I will try this then see how it goes

#

thanks again for your time and help

light cave
#

checkout_session.completed will give me the name and email of the customer right
Yes, in the customer_details object or by looking at the customer ID.