#dandev_cli-customer

1 messages ยท Page 1 of 1 (latest)

rough solarBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1255987647890063361

๐Ÿ“ Have more to share? Add details, code, screenshots, videos, etc. below.

spark runeBOT
rough solarBOT
bronze jacinth
#

dandev_cli-customer

neon swallow
#

This is what I need changed

bronze jacinth
#

@neon swallow the CLI will set default values in a few parameters to help understand the API. Really the easiest for you is to not use the CLI for this and to either use the Dashboard or call our API with real code you write to set the exact parameter(s) you are after

neon swallow
#

How can I set the exact parameters?

bronze jacinth
#

Are you a developer? If so what language are you using?

neon swallow
#

Yes, node.js

bronze jacinth
#

Okay so you are creating a PaymentIntent and you want to control the description is that right? So you would use this API: https://docs.stripe.com/api/payment_intents/create and pass the description parameter to what you want it to be instead of the (created by Stripe CLI) string

neon swallow
#

Yes, using the webhook

bronze jacinth
#

what does that mean "using the webhook"?

#

What are you really trying to do? Why are you putting an email address on a PaymentIntent's description in the first place?

neon swallow
#

// Include necessary dependencies
const stripe = require("stripe")("sk_test...");
const express = require("express");
const bodyParser = require("body-parser");
const app = express();

// Stripe webhook secret for your endpoint
const endpointSecret = "whsec_...";

// Middleware to parse the raw body as text for webhook endpoint
app.use(bodyParser.raw({ type: "application/json" }));

// Webhook endpoint to listen for Stripe events
app.post("/webhook", async (req, res) => {
let event;
let signature = req.headers["stripe-signature"];

try {
event = stripe.webhooks.constructEvent(req.body, signature, endpointSecret);

// Handle the event
switch (event.type) {
  case "payment_intent.succeeded":
    const paymentIntent = event.data.object;
    console.log("Payment Intent succeeded:", paymentIntent.id);
    // Handle the succeeded payment intent here
    break;
  default:
    console.log(`Unhandled event type ${event.type}`);
}

// Return a 200 response to acknowledge receipt of the event
res.status(200).end();

} catch (err) {
console.error(Webhook error: ${err.message});
res.status(400).send(Webhook Error: ${err.message});
}
});

// Start the server and listen on port 4242
app.listen(4242, () => {
console.log("Running on port 4242");
}); this is what works for me

#

but this way I cannot edit the description

bronze jacinth
#

yeah I mean at that point the description is already set. What you need to change is where you create the PaymentIntent instead

neon swallow
#

So it should be without constructEvent>

bronze jacinth
#

No sorry you're misunderstanding the whole issue I think. The code you shared is for a webhook handler: this is code that gets the payment_intent.succeeded Event for example after the payment succeeds to do certain things.

You want the PaymentIntent to have a different description. Your own code, somewhere, would create the PaymentIntent, and that code would set the description you want.

neon swallow
bronze jacinth
#

yeah that description: "Custom description here", // Replace with your desired description

#

that would set that specific string as a description as expected

neon swallow
#

The problem is that this doesn't work

bronze jacinth
#

It does work totally fine. My guess is that you are never using this code and instead are using the Stripe CLI to trigger Events

neon swallow
#

Yes, I am triggering events using CLI, you are right

#

So how am I supposed to test this without CLI?

#

And will it be changed in all of the logs?

bronze jacinth
#

yeah sorry I'm trying to figure out how to explain it. If you use the Stripe CLI, all it does is create API requests to trigger the exact Event you want. It's completely unrelated to your code in that case.

So stop using the CLI for this. You have real code that creates a PaymentIntent. You can use that code, create a PaymentIntent, collect card details client-side to confirm it and that will send the payment_intent.succeeded Event for your webhook handler to process the information

neon swallow
#

How do I create payment intent without CLI?

#

I need to connect this to shopify, that is why I need a webhook

#

And I wanted to deploy the code to AWS

bronze jacinth
#

I'm sorry you seem completely lost with the whole thing right now so it's really hard to help you.
You shared real code, which I assume you wrote yourself. That code literally has a route on your server-side code that creates a PaymentIntent. So now you need to hit that route.

neon swallow
#

Wait, if I understand this correctly. When I create a webhook in Stripe, and when I connect it with the API and webhook code, when a user wants to buy something using Stripe, wouldn't that automatically trigger paymentIntent

#

when the app is deployed

bronze jacinth
#

Not really sorry, the way you framed things doesn't make sense to me. A webhook handler is used for reconciliation. All it does is receive Events about things happening in your account. It doesn't create anything.

Creating a PaymentIntent is a completely separate operation. For example something you do when I browse your website and buy a product from you for $10. Then your code creates a PaymentIntent for $10 so I can pay you

neon swallow
#

So where should I use this code?

#

Sorry for bothering you, it is really confusing me

bronze jacinth
#

What do you call "this code"? You're not bothering me, I'm just struggling to explain how this all works

#

Are you a developer writing the full payment integration? You mentioned Shopify, is it possible you misunderstood the whole thing and Shopify is the one handling payments for you entirely?

neon swallow
#

Yes I am a developer, I just phrased it that way. Shopify is handling payments, but the problem is paymen details section, in which I want to change the description

#

That is all

#

In stripe

#

I sent a screenshot before

bronze jacinth
#

yeah okay that's the whole entire confusion lol

#

You, as the developer, never create the PaymentIntent, or accept a payment. Shopify does that for you. So as the developer you have no control over the description they set. Shopify controls that for you.

#

Like our CLI sets (created by Stripe CLI) and Shopify would do something special for them, like maybe they put an order number or something. I don't really know what they do and you'd have to ask them (or test a payment in Test mode through them)

neon swallow
#

The thing is, it was working before. I saw it on a different Stipe account

#

Somehow it was changed to email as description

#

So it is definitely possible

#

Do you think it is possible?

bronze jacinth
#

The problem is the question is really too vague.
Can you control the description in the API? Absolutely, this is really easy by either passing the description when creating a PaymentIntent or later you can just call the Update PaymentIntent API and pass a new description

neon swallow
#

Update PaymentIntent worked for me, but I saw it in the logs. I want it to not be there either

#

Thank you for your help. Is it possible to listen for webhooks and not run the default creation of the payment like with the CLI?

bronze jacinth
#

The CLI is really just a developer tool for you to "simulate" real actions. The CLI is really irrelevant otherwise. So don't use the CLI at all. You use Shopify, you should be able to test payments through Shopify and those will cause Events to be generated

neon swallow
#

Okay, Thank you for your help!