#udzhin_dev
1 messages · Page 1 of 1 (latest)
Hello! Can you share what line of code is giving you that error?
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');
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?
That's all I get in return
Yeah so your request to your server is failling and you need to figure out why
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
like this?
Try it
I'm not a php dev
You can google how to access the request body if you don't know
<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."}
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
Where do you see "This payment method is invalid. Choose another and try again."? It's not in the screenshot
Do I need to customize anything in the GPay & Wallets panel?
Maybe I need to set up a panel in googlePay?
You shouldn't, no
Then I don't know how to be, if this method is included in Stripe Payment Methods, then why is it not working?
That's an error within google's modal
Have you tried another card
I've tried it, but that's still not the point
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?
Yes
Can you share the payment intent then?
And your code?
Both front-end and backend
I don't understand about the intentions
You just exposed your live api key
Never send your live keys in any public place
You'll need to roll the keys now: https://stripe.com/docs/keys#rolling-keys
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)
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
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
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
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?
req_1MAs3IPiiRBCIe
That request ID does not show that error. That request succeeded.
Can you share the code?
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.
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
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?
else {
console.log('Payment success');
e.complete(Success: ${paymentIntent.id});
successSend();
}
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.
The docs also explain the valid values: https://stripe.com/docs/js/appendix/payment_response#payment_response_object-complete
Where do I put it in my code? I can't figure it out.
Not sure I understand? Do you understand what the error message is saying and how it relates to the code above?
@raven galleon You still here?
Yeah, i’m here, but i don’t understand what the error message is saying
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?
Because you're passing an invalid value to the completion method.
How can i fix it?
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.
Because that's what was shown in the video
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.
Thanks for your help, but let me post in the morning.