#udzhin_dev

1 messages · Page 1 of 1 (latest)

nova ravenBOT
unreal kelp
#

Hello! Can you share what line of code is giving you that error?

raven galleon
#

paymentRequest.on('paymentmethod', async(e) => {

    // Создайте объект данных для отправки на сервер, включая значение price.
    const data = {
        price: price * 100, // Включаем price в данные.
    };
    const {clientSecret} = await fetch('/db/create-payment-intent.php', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        },
        body: JSON.stringify({
            paymentMethodType: 'card',
            currency: 'chf'
        }),
    }).then(r => r.json());
    console.log('Client secret returned');
unreal kelp
#

Have you confirmed that your request to your own server '/db/create-payment-intent.php' is actually going through and giviong you a successful response?

raven galleon
#

That's all I get in return

unreal kelp
#

Yeah so your request to your server is failling and you need to figure out why

nova ravenBOT
raven galleon
#

How do I pass the price from JS to PHP?

fiery remnant
#

Above it looks like you're passing it in the request body as amount

#

So in your php code, look at the request body and extract the amount param

raven galleon
#

like this?

fiery remnant
#

Try it

#

I'm not a php dev

#

You can google how to access the request body if you don't know

raven galleon
#

<br />
<b>Warning</b>: Undefined array key "amount" in <b>/home/p120872/public_html/pridewood.ch/db/create-payment-intent.php</b> on line <b>30</b><br />
{"error":"Missing required param: amount."}

fiery remnant
#

Have you tried logging the inbound request body?

#

You need to debug this yourself

raven galleon
#

Thanks, I solved the price issue, now the question is different, in Stripe Dashboard I disabled payment with Link, I have the gPay button, but when I try to pay it says "This payment method is invalid. Choose another and try again."

#

I have the Google Pay payment method enabled in my Dashboard

fiery remnant
#

Where do you see "This payment method is invalid. Choose another and try again."? It's not in the screenshot

raven galleon
fiery remnant
#

That's an error within google's modal

#

Have you tried another card

raven galleon
#

Do I need to customize anything in the GPay & Wallets panel?

#

Maybe I need to set up a panel in googlePay?

fiery remnant
#

You shouldn't, no

raven galleon
#

Then I don't know how to be, if this method is included in Stripe Payment Methods, then why is it not working?

fiery remnant
#

That's an error within google's modal
Have you tried another card

raven galleon
#

I've tried it, but that's still not the point

fiery remnant
#

Well since the error is coming from the google modal, it could be an issue with the card that's added to your google wallet

#

That's why I ask

#

That happens sometimes

#

So you tried a totally different card, and that also gave the same exact error?

raven galleon
#

Yes

fiery remnant
#

Can you share the payment intent then?

#

And your code?

#

Both front-end and backend

raven galleon
#

I don't understand about the intentions

fiery remnant
#

You just exposed your live api key

#

Never send your live keys in any public place

#

Someone can control your stripe account with them

#

I just need the code (with keys redacted) and a payment intent id for where you're getting this error (pi_123)

raven galleon
#

pi_3NoAQaH8cb5myhu41zE0muF5_secret_DnbX3maCnnLPsQmTmLsJhiC44

fiery remnant
#

A couple issues. You shouldn't be testing in live mode. It's against our TOS. You should always use our test api keys for testing. Secondly, for the PI you shared, looks like the error is insufficient funds. You can see the confirmation request in your logs here: https://dashboard.stripe.com/logs/req_xPzWReLOs0JHYP

raven galleon
#

This is already a test environment

fiery remnant
#

It's not

#

The payment intent you shared was created with live keys

#

The same ones you exposed in your code snippet earlier

#

The one I told you to roll

nova ravenBOT
raven galleon
#

This is a test environment

#

100%

limpid lion
#

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

#

Can you give me the request ID showing that error?

#

Or can you share the line of code that's throwing that error?

raven galleon
#

req_1MAs3IPiiRBCIe

limpid lion
#

That request ID does not show that error. That request succeeded.

#

Can you share the code?

raven galleon
limpid lion
#

No, not all of the code, the specific code that's throwing this error.

#

You should be able to tell me which of these hundreds of lines of code threw the specific error you're asking about.

raven galleon
#

The error is in the payment itself and not in my code, that is, I'm trying to pay, not only I have only link instead of gPay, but also it simply does not want to work.

#

Now 'Link' in test mode has stopped working as well

limpid lion
#

That error is being thrown by your code though. The error in the screenshot shows a stack trace that would normally be useful, but your code is minified and unreadable. Can you run the code without minifying it so the stack trace is useful and points to an actual line of code?

#

The other thing you can do is look at what the error is telling you. It says You specified: and then tells you exactly what your code specified, which is Success: pi_3NoBg3H8cb5myhu40tfuWhDN. Which part of your code is specifying that?

raven galleon
#

else {
console.log('Payment success');
e.complete(Success: ${paymentIntent.id});
successSend();
}

limpid lion
#

Ah, there you go.

#

So yeah, that's not going to work.

#

The error tells you what the valid values are you can pass in there.

raven galleon
#

Where do I put it in my code? I can't figure it out.

limpid lion
#

Not sure I understand? Do you understand what the error message is saying and how it relates to the code above?

limpid lion
#

@raven galleon You still here?

raven galleon
#

Yeah, i’m here, but i don’t understand what the error message is saying

limpid lion
#

Okay, which specific part don't you understand?

#

I'm happy to help you understand the error, but I need you to explain what part(s) you don't understand first.

#

@raven galleon You there?

raven galleon
#

why does this error occur?

limpid lion
#

Because you're passing an invalid value to the completion method.

raven galleon
#

How can i fix it?

limpid lion
#

You can pass a valid value to the completion method.

#

Let me ask you this: why did you write this line of code?

e.complete(`Success: ${paymentIntent.id}`);
#

@raven galleon Still here? We help people in realtime on this server. If you need async support working with Stripe support would be a better fit.

limpid lion
#

Can you give me a timestamp for when that appears?

#

Like I'm seeing this:

#

Which is very different from what you wrote in your code.

raven galleon
#

Thanks for your help, but let me post in the morning.

limpid lion
#

Are you talking about this at the end?

#

Because that's not what your code is doing.