#kawuss

1 messages · Page 1 of 1 (latest)

topaz elkBOT
raven lance
#

have you confirmed that the api key you're passing in when initializing stripe is correct?

#

that would be the first step

vernal solstice
#

How I can do it ?

#

I added I have only this in webpage

#

@raven lance

raven lance
#

You'd log it in your client-side code to make sure it's correct

vernal solstice
#

When I try to log my publishableKey is nothing nothing happens

#

it's udefined

#

undefined

raven lance
#

Then that's your issue - you need to make sure it's being set correctly

vernal solstice
#

so how I can do it ?

#

I create a payment on the first time and I don't know how to fix it

raven lance
#

What does your code look like that set's it? Where is it getting the publishable key from?

vernal solstice
#

On the js: document.addEventListener("DOMContentLoaded", async () => {
//Fetch the publishable key from the server
const {publishableKey} = await fetch("/config").then(r => r.json);
console.log(publishableKey)
const stripe = Stripe(publishableKey);

//Fetch the client secret property for the payment intent
const {clientSecret} = await fetch("/create-payment-intent", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
}).then(r => r.json);
//Mount elements
const elements = stripe.elements({clientSecret});
const paymentElement = elements.create('payment');

});
On the java: post("/create-payment-intent", (request, response) -> {
response.type("application/json");
PaymentIntentCreateParams params = PaymentIntentCreateParams.builder()
.setAmount(1099L)
.setCurrency("pln")
.setAutomaticPaymentMethods(
PaymentIntentCreateParams.AutomaticPaymentMethods.builder()
.setEnabled(true)
.build()
)
.build();

  PaymentIntent intent = PaymentIntent.create(params);
  HashMap<String, String> clientSecretResp = new HashMap<>();
  clientSecretResp.put("clientSecret", intent.getClientSecret());
  return gson.toJson(clientSecretResp);
});
raven lance
#

So it looks like you're calilng to your server (the /config endpoint) to get the publishable key?

#

Your next step then is to debug your server and see why it's not giving you back the response you expect

vernal solstice
#

but my server giving back me my secret client after this command

raven lance
#

That's not your issue though - your issue is in line 4 with your publishable key

#

the payment intent client secret is differnet and unrelated to your current issue

vernal solstice
#

so How I can fix it ?

raven lance
#

As I said - you need to debug your own server and integration and see what the specific issue is

#

I don't know what your server's /config endpoint is doing - so it's up to you to see what the current behavior is and narrow down what the error could be

vernal solstice
#

Ok thank's for help

#

I have one more question why when I create Stripe Sample I haven't got any CreatePaymentRequest metod ?

raven lance
#

Which sample are you looking at?

vernal solstice
#

When I create Sample with stripe vs code extentions

#

and I haven't got get method on the server which would explain my problem

raven lance
#

there's a lot of different samples - I'd expect that some would have CreatePaymentRequest, but probably not all of them need it

vernal solstice
#

so How I can correctly

raven lance
#

Are you 100% sure that's the issue? Did you do when I mentioned about debugging your /config endpoint?

vernal solstice
#

How I can debugging my /config endpoint ?

#

in vscode

raven lance
#

Are you a developer? Generally, you should be systematically adding logs or breakpoints to confirm that each step ofyour code is behaving as you expect

vernal solstice
#

No I'm studing develop

#

I said it is my first time in add every payment method in my project

raven lance
#

Is this an integration you intend to put into production? Or is this just you trying things out? If it's something you need to be production ready I'd strongly recommend you look into some of the no-code/low code solutions or hire a developer to help you get it production ready

vernal solstice
#

I extends my skills and I trying things out

raven lance
#

Gotcha

#

Then yeah, you need to do what I mentioned - add logs, breakpoints, look at your server requests (make sure your server is actually being hit), etc

vernal solstice
#

Okey, thank you for help me

#

and sorry for my English

raven lance
#

no worries! happy to help

topaz elkBOT
vernal solstice
#

Did you know how catch in Java information about payments with generate payments link ?

#

in stripe generate payments link

gray chasm
#

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

#

Are you asking about listening for payment-related webhooks from Payment Links using Java?

vernal solstice
#

yes

#

How I can do it ?