I have PHP website, looking forward to integrate cardano in that site, do i need to convert my site in node?

Dear Experts,

I have php store, and looking forward to integrate cardano in that site. We also have expertise in node js and can convert our website to node js if required… My main purpose is that users check out using cardano in our store.

a) i understand that cardano is in node, so do we need to change our entire site in Node?

b) as suggested to use https://blockfrost.io/, is it compulsory to use third party API service to integrate cardano in our application? I thought cardano itself is an application that i can integrate directly in our website.

c) If i understand correct, cant i just use cardano documentation to integrate it in our website? If yes, please do pass some advise…

Just for additional information, one of the generous member of this group assisted us to install cardano on our server. Thanks for that!

You can develop your own solution or use some existing payment gateway like Ada Pay or similar where they will take a fee (like Paypal, Stripe,…).

Using 3rd party gateway will provide easy integration and will allow faster time to market but you will need to pay for it.

Using your own solution will require custom development and maintenance.

You can use cardano-wallet or cardano-cli for that matter, which are CLI applications. So for the interaction with it, it does not matter whether you use PHP, Javascript, C#, Python, etc…

The idea is that for each payment you generate a new wallet address, let the customer scan the QR code or copy that receiving address. Then you listen for incoming ADA on that address, and once it goes in you consider the payment as successful.

See article here:
https://developers.cardano.org/docs/integrate-cardano/listening-for-payments-wallet/
https://developers.cardano.org/docs/integrate-cardano/listening-for-payments-cli

6 Likes

Actual link to ADA Pay

Know that they use COTI wallet and SaaS under the covers which might work. Can’t vouch as I have never used either and don’t consider crypto more convenient, secure, or functional compared to credit cards or even PayPal as a payment gateway yet. Maybe in 5 years or so there will be something …

2 Likes

thank you all for assisting with your information…its very helpful and slowly are are moving forward in getting this dream done…

a) We have implemented this link

We have received payments using Cardano CLI. Now we want to know, how should we bring this entire process in our shopping cart in PHP? Like when customer checkout in our PHP store, how should they be redirected to this cardano CLI so the payment goes through?

Can you please tell this process or step as this is most important…

a) Also, how is the cardano CLI will be called in front end?

b) Is it possible to implement it in node? Can we also use the curl to process this entire function?

d) And this ADA https://adapay.finance/ you have sent, is this ADA to be used anywhere in integration of cardano with our shop? inspite of we using this link ( cardano CLI )
Listening for ada payments using cardano-cli | Cardano Developer Portal

What do you mean by “We have implemented”, then?

It is all laid down in that article:

  • You control cardano-cli from your PHP code. The examples in the article are in Javascript, Typescript, Python and C#, but in principle, it’s the same for PHP. You use exec (https://www.php.net/manual/en/function.exec.php) to run cardano-cli and then process it’s output with PHP.
  • The user never gets to run anything on your cardano-node or cardano-cli. In fact, it would be much more secure if the cardano-cli interaction is done in a separate process, not by the webserver and it communicates with your web PHP script only through values in the database or something like that.
  • The customer has to do the transaction manually in their wallet app. You just provide them with an address before that and then monitor that address for arrival of the ADA.

As said, with exec: https://www.php.net/manual/en/function.exec.php

Javascript example is in the article. There are also APIs available that do not need to do command-line calls, but provide that a little bit better integrated in Javascript.

What do you want to do with curl? It is for sending requests to web servers.

As far as I understand it, they have already built all the things sketched above and in the article. You can use (and pay) their service instead of this. But then you still have to learn how to integrate their service with your web shop.

3 Likes

We created a file “cardano-cli-check.php” to check if cardano-cli will run from php using given docs in previous reply…
But when we run url to check, it just downloaded the file rather than showing cardan-cli output
attached is the contents of the file…

That has not much to do with Cardano, but with the configuration of your web server. The documentation of Cardano-specific things assumes that you already know, how to build a website with the chosen technology.

Honestly, learning server configuration, web programming, and Cardano all at the same time is a very ambitious plan.

3 Likes

The questions are more related to Php and website building than they are to cardano-cli. To me it seems as you need invest more time into researching the e-commerce system you are using and how to integrate custom payments. Regarding cardano-cli, it should be straight forward. You generate a wallet address, assign it to a particular order and then periodically check if that payment came through. As said you would present the receiving address to the user. The user would manually do the transaction.
To skip implementing all that complexity you can look at existing solutions like Ada Pay but you still need to research how to implement it with your e-commerce system.

4 Likes

Sir, based on your feedbacks, we have to decided to integrate cardano wallet and are in process of doing it…

Sir, may i ask you to give us any sample file for following message, i mean anything on how should we process this task? Any code or reference please?
(Rest we have cardino node installed, walett is being installed)

"
The front-end application would then request for a wallet address from the backend service and render a QR code to the customer to be scanned via a Cardano wallet . The backend service would then know that it has to query the cardano-wallet with a certain time interval to confirm and alert the front-end application that the payment has completed succesfully."
"

Sir, so you mean to say if we run following code on our server, it will return output?

<?php 
//echo shell_exec("cardano-cli --version");
$output=null;
$retval=null;
exec('cardano-cli --version', $output, $retval);
echo "Returned with status $retval and output:\n";
print_r($output);
?>

If you are programing a plain PHP website, then there is no specific frontend application as you can handle everything through PHP and render the content on page load.

Steps:

  • User submits an order
  • PHP script then:
    a) Executes cardano cli or wallet and generates a new receiving address.
    b) Assigns that address to the order
    c) Display the user the receiving address with instructions that the user need to send XYZ amount of ADA to that address, or displays a QR code for wallets that support that
  • Another long running process monitors orders that have not been payed yet. Once the payment comes through you trigger some other process that sends the confirmation email etc…

This is some basic overview. The implementation in this case is heavily PHP and web development related, and most questions will be related to that.

3 Likes

Yes, that should work. If you get the web server to execute the code instead of offering it for download.

Why did you choose PHP?

And do you have anyone in your team who already knows enough about server-side web programming? In any language – does not have to be PHP, can be Node-JS, Python, whatever?

Building a web shop from scratch is not trivial. Even just taking an existing one and integrating Cardano payments into it would probably require someone who already knows a bit about the language.

4 Likes

Wish I could +10 previous comments :smiley:

As a preface I have not used PHP, ASP, Ruby, and their like in over 10 years but the last time I did use PHP was for a WordPress based legacy e-commerce website. If that is what is driving your payment gateway needs then the typical thing was finding a plugin and modifying it to suit your needs. In which case a cursory search turned up Spoddano – Cardano For Woocommerce – WordPress plugin | WordPress.org for Woo Commerce. I recall using WooCommerce at least thrice upon a time for some small business websites back in the day before anyone cared about blockchains.

If this is for a new project and not an existing client on CSA I highly recommend researching some modern architectures and upgrading to a 21st century web experience. Ironically this can take various forms as we are in a transformative period in technology yet again!

  • Container Craze (Docker, Kubernetes, Helm, etc)
  • Framework de Jour (React, Flutter, Vue, etc) [not Angular, thank me later]
  • NEW Old School (Web Assembly, gRPC, HTML5, etc)

Notice the distinct lack of PHP, ASP, and other technologies where a server generates the content to be delivered to the browser client like we did once upon a time to make the internet less pathetic. Similar to previous periods of experimentation and consolidation by my pseudo-expert opinion we will standardize on a winner sometime in 2025 and that will set the stage for how we build with blockchain!

3 Likes

Just to add my 2c, I agree with what @DinoDude wrote.

The chosen technology highly depends on the project scope, requirements, and the experience of the team or individual working on the project. Php has come a long way in the last 20+ years and having good and experienced people I think it even can be successfully used in enterprise-grade projects with many developers and higher staff fluctuations. It is an easy and forgiving scripting language but has also its drawbacks so one needs to compare the pro vs contra for the given requirements and team setup. For newcomers, it’s very appealing due to its forgiveness (usually harder to get memory leaks, etc).

Sometimes new technologies can be very tempting to use but may be an overkill, like containers and Kubernetes for a project that does not really require that amount of flexibility while increasing complexity. Later you pay the bill heavily through maintenance of such a system while not profiting enough to justify the cost.

The is a very high chance you will still require it for the backend in order to do server-side processing and provide an API for the frontend.

I did mainly Php for ~10+ years in the early 2000s and it did the job for small to mid scale projects not involving many team members and high team change dynamics. Since DotNetCore became a thing I’m using it heavily for the backend services and am very happy with it, the language, the runtime, and the community. For the front-end very happy with the current vue3.

In the end, it highly depends on the experience of the team. You can take the best and most flexible platform out there but if there is not enough experience on how to make use of it or how to structure the application to meet all the requirements and future upgrades, preventing spaghetti code and a big ball of mud that will need to be rewritten once the core team changes then it’s not really important what tech is being transformed down to processor instructions.

3 Likes

Thanks everyone guys for your valuable comments…here is our overview to make it simple…

1-> We Installed Cardano-node (1.34.1)

2-> We installed Cardano-cli (1.34.1)

3-> We installed Cardano-wallet (v2022-01-18)

After this we received Payments via…

It is running as mentioned in above page…

It is also tested at tesnet and it is also working…

Now our questions are…

Question 1:

In Listening Payments via Cardano-wallet page,

there is no clear code that indicates How to Generate Wallet Address dynamically?

Question 2:

There is an url given “http://localhost:9998/v2/wallets” is this URL changed at Live server?

Question 3

Can I get any example code of front end that used to receive ada payments that i can test please?

Please reply Sir…

As far I can see from the example and the docs, you request an unused address from cardano-wallet. It seems it will manage the creation of new ones automatically. But you need to test that.

const resp = await fetch(`http://localhost:9998/v2/wallets/${walletId}/addresses?state=unused`);

See here more docs for cardano-wallet:
https://input-output-hk.github.io/cardano-wallet/
https://input-output-hk.github.io/cardano-wallet/api/edge/

For the other questions, you really need to consult your website developers.

2 Likes

Yeah don’t ever force it but always keep an eye out for something better and compare the options. You need to know enough to understand that trying to get JavaScript programmers to use Qt effectively simply is not going to end well even if QML is similar to what they already know.

That said I heard good things about Laravel (PHP) and there is nothing stopping you from using that or .NET (C#), Spring (Java), Django (Python), etc if you need those kind of frameworks. This is some of the stuff that built the centralized world we have been living in for awhile now. I was actually mildly impressed with Hugo (Go) recently although overall I do not see Go being the best choice for anything outside of Google just yet :smiley:

Plethora of options out there so at the end of the day just pick one your team is comfortable with based on the programming language they know best!

1 Like

thanks for the advise…

We are super experts in PHP but problem is that we have not worked on node JS ever, is that the problem that is stopping us to integrate what we have done with our website?

We have PHP store, our only aim was to let users checkout using ADA. Thats it, nothing else…

But i think we are making it so complicated, we are installing CLI, cardano wallets, cardano nodes…i dont even know if thats required all or not…

But its very frustrating, that we are not able to move forward. Kindly i request if you can give us some sample file for integration on how do we integrate ADA payments in our store ( in PHP ) , it would be helpful…

After you installed all the CLI tools it’s all PHP in your case. There is no need for NodeJS.

If you do not want to integrate with a 3rd party payment gateway, then that’s required.

1 Like