Closed rockcesar closed 3 years ago
I have a simmular error, when i exec the payment function i dont get a response and the server just gives me a timeout after 6000ms
I have a simmular error, when i exec the payment function i dont get a response and the server just gives me a timeout after 6000ms
Share the specific code where you are defining the Pi.createPayment, to see if we can help.
Can someone teach me about this app and how to pay
Your input data is wrong for creating payment Change the amount data to number
I have a simmular error, when i exec the payment function i dont get a response and the server just gives me a timeout after 6000ms
You need to post message to pi server to check the create payment. See the platform sdk to know how it post
Can someone teach me about this app and how to pay
I have a simmular error, when i exec the payment function i dont get a response and the server just gives me a timeout after 6000ms
Share the specific code where you are defining the Pi.createPayment, to see if we can help.
i got the same problem,how to fix this
Hi @rockcesar ! Thanks for the detailed issue, and thanks for providing code examples. It makes it so much easier to help you.
From the code example you provided, it looks like you're passing an empty object as the payment's metadata here. That's why you're getting a validation error. Metadata is mandatory, because it enables the developer to know what the user was paying for, even if the payment failed to register on the developer's side (this is similar to the memo, but the memo is more of a user-facing description, whereas the metadata can be processed programmatically).
Since it looks like your app is simply receiving donations, you could put something to record this fact in the metadata - e.g {paymentType: "donation"}
.
This is all up to your own internal business logic, but you just need to pass something in the payment's metadata object.
I do agree that this error was very obscure, and that it would have been much better if you had received a message like "metadata can't be empty". I've created a new issue with our internal issue tracker on the SDK side to record the fact that we should return a clearer error message.
Hello, @aurelienshz , thanks by detailed answer. I changed the code as you said, and it changed its behavior, but now I'm having the same issue than @Sten435
https://github.com/pi-apps/pi-platform-docs/issues/14#issuecomment-870958269
I updated the code in github, you can check the current code.
https://github.com/pi-apps/pi-platform-docs/issues/14#issue-933049175
I updated the code in github, you can check the current code.
https://github.com/pi-apps/pi-platform-docs/issues/14#issue-933049175
You should do the ServerApproval by using platform SDK
I updated the code in github, you can check the current code. #14 (comment)
You should do the ServerApproval by using platform SDK
@aszasz1234 Do you have an example?.
Done, it is working, I sent the ServerApproval and ServerComplete.
@SuperHax @Sten435 @aurelienshz @aszasz1234
Check an example here:
Example app (Pi Browser): https://piapp-example.web.app/ Code: https://github.com/rockcesar/PiNetworkDevelopments/blob/master/PiDevelopment_test1/public/index.html
Wait... You have merged the server side and client code? The approve and complete calls should not come from the client side as it includes the apiKey. This logic should be split. I am going to release a detailed guide later also using firebase functions but I have made it isomorphic with node, express and axios for the requests on the server side and react and axios on the client side
@rockcesar sorry I'll explain if you send the API call from the client then the API key you are sending is exposed in the client network requests that why that request must be sent from the server and not the the browser
@rockcesar that's not how it works.
@rockcesar what do you mean? Yes it will work but people will easily be able to see your API key if they know how too by inspecting the POST request. Therefore it's not viable. The server side code needs to run off a server and the client side on the client side it can't be combined
No worries
Nice š isomorphic JavaScript is completely different
I'm not even trying to argue with you. I was simply trying to help! I suppose yeah your running PHP it is all running server side I understand that.
Ohh ok, its dangerous running that code client side but whatever you won't listen
This isn't correct though my friend
I'm currently with my kids. Once they go to bed I'm going write up a guide on how to do the server side part of the payment process
Ok I'm not arguing with you. That's fine but read the documentation first properly
Lol your just being ridiculous now
šš
I would rather use the pi platform docs here thanks mate
Please guys lets stick to proper decorum here lets stay respectful, and on topic, with that said all aspects of the documentation should be adhered to for safety of the community.
I agree with @chipmoon27 there is no reason to debait on what is the best way to post an http request with an API key.
If you want to do it on the front-end and you know the risks and are fine with them then why not.
If you want to use it with a server to not expose your API key thats a bit safer but its personal prefferancess.
I and the rest here dont want a debait fight over chat.
Your both realy experianced and have your own thoughts about certain items...
Greetings Stan P
@Sten435 I appreciate people knowing the risk and not caring. That's purely their choice, however the documentation states that the API key definitely should not be used client side. I was just trying to warn him that Core Team will probably not allow that and any developers doing that will be penalised.
@Sten435 I appreciate people knowing the risk and not caring. That's purely their choice, however the documentation states that the API key definitely should not be used client side. I was just trying to warn him that Core Team will probably not allow that and any developers doing that will be penalised.
Yea, i agree with you.
I think serverside is bether for safety and becuse of the docu.
Greetings Stan P
Or just completely hide it in your server side like this server-side This example is using firebase cloud functions for the "server-side"
Ok, I did the server side.
You can watch an example of PHP here:
https://github.com/rockcesar/PiNetworkDevelopments/blob/master/server1.php
@rockcesar that is awesome, a lot safer now š. Are you able to call the /approve and /complete API endpoints? I'm currently receiving 500 errors from the pi servers.
@dannybutterfield1880 Yes, I got the same response, because I was sending this in the header. But I solved, in the header of the /approve and /complete call, only send Authorization: Key ...
In /complete, you have to send also the txid in the body.
I was sending in the header that the request was json, but it seems, it doesn't needs.
@rockcesar @rockcesar I wasn't passing txid to the body šš¤¦š¼āāļøI knew I needed to just missed it while writing the code lol sorted now. Nice one š
@dannybutterfield1880 cool!
Adakah Apk yang bisa menjadikan pi uang nyat
Adakah Apk yang bisa menjadikan pi uang nyat
Not yet. But join Pi, soon will be in phase 3.
Ok, it was solved. I guess it can be closed.
I'm having this issue. When I try to make a payment to the app, I have this messsage:
Title of the window: Error! Message: "Payment data is invalid. Please reach out to developer."
I'm using these docs: https://github.com/pi-apps/pi-platform-docs
This is the code I'm using: Example app (Pi Browser): https://piapp-example.latin-chain.com/ Code: https://github.com/rockcesar/PiNetworkDevelopments/blob/master/piapp-example/main.html
I have other code with the same issue: Pidoku app (Pi Browser): https://sudoku.latin-chain.com/ Code: https://github.com/rockcesar/PiNetworkDevelopments/blob/master/sudoku/pidoku/functions.js
Snake app (Pi Browser): https://snake.latin-chain.com/ Code: https://github.com/rockcesar/PiNetworkDevelopments/blob/master/snake/responsive-snake/example/js/functions.js
Another example for Odoo: https://apps.odoo.com/apps/modules/14.0/website_pinetwork_odoo/
Server side example in PHP: https://github.com/rockcesar/PiNetworkDevelopments/blob/master/server1.php Server side example in Odoo 13 and 14 (Python3): https://github.com/rockcesar/PiNetworkDevelopments/blob/master/website_pinetwork_odoo/controllers/main.py
Image of error: