Create Publication

We are looking for publications that demonstrate building dApps or smart contracts!
See the full list of Gitcoin bounties that are eligible for rewards.

Solution Thumbnail

ALGO Payment Plugin for Shopware 6 eCommerce

Overview

Shopware is a European e-commerce platform which powers over 100,000 webshops across the world. Since the launch of it’s newest version, Shopware 6, the popularity has boomed. Currently, only traditional payment methods are available. With this Algorand plugin Proof Of Concept, I want to open the eyes of Shopware developers everywhere, and welcome them into the world of cryptocurrency. Using Algorand, we’re able to receive payments fast, secure, and with small transaction fees.

Info

This Shopware 6 plugin is a proof of concept, and should probably not be used as-is on a live environment.

Why another payment plugin?

At the moment, there is no other PHP implementation of any Algorand payment solution; only solutions written in other languages, or of bad quality are available. With this POC, I try to show that a quality integration of a webshop in PHP is also possible. I hope this POC can be an example for many developers, writing Algorand applications, Shopware plugins, or both.

How does it work?

While Algorand (and most cryptocurrencies) are decentralized in nature, this POC makes use of the AlgoExplorer APIs to search and validate transactions, and thus makes use of a centralized component. The API can however be switched out easily for another (for example self hosted) node.

For the fiat to crypto-conversion, the API offers an integration with the APIs of Binance. At the moment of writing, only USD (ALGO/USDT) is implemented, but it should be straightforward to calculate other currencies, or even implement another API altogether.

Testing

For testing purposes, the plugin can be configured to use the TestNet network. Use the official Algorand wallet app to give yourself some ALGO, so you can test out the integration.

Setup and configuration

Shopware install

Clone the plugin to its folder under /custom/plugins/AlgorandPayments in your Shopware installation. Run the following commands in the CLI, or follow the needed steps in the Shopware admin.

bin/console plugin:refresh
bin/console plugin:install --activate AlgorandPayments
bin/console cache:clear

Configuration

It’s very simple to get this plugin up and running, as there are only 3 configuration fields.

  1. Node settings: You can choose to use the MainNet or TestNet.
  2. Rate Conversion API: You can choose between different APIs for the rate conversion. Currently, for the sake of this proof of concept, only the Binance API is available
  3. Algorand wallet address: The address where the funds should be transferred to.

What’s the flow?

After a customer chooses to pay with Algorand, the AlgorandPayments plugin starts working on generating the needed information to receive the payment using the Algorand network. First of all, we use the conversion APIs to calculate how many ALGOs we have to ask from the customer. Then we show the customer the needed details: The Algorand address from the configuration, the amount he needs to pay, and a note (the order number) he has to provide with the payment.

Screenshot frontend

Tip

We also generate a QR code so the customer can scan it directly from his official Algorand app!

After the customer pays, they can click the ‘Proceed’ button. Because this is only a proof of concept, this is not an automated process. In a `production’ plugin, it should poll every x seconds in the background, so the customer can be redirected automatically. As soon as the customer clicks the button, we reload the page and ask the AlgoExplorer API to list all transactions that are for the correct wallet address, have the correct note, and have actually paid enough. As soon as such a transaction exists, we mark the order as paid, and redirect the customer to the success page.

Improvements

As repeated some times in this article, this plugin is a POC and could use some improvements before it’s actually usable. This is a small ‘roadmap’ for anyone who would like to contribute to further development:

  • Implement more currencies, currently only USD is supported.
  • Add support for stablecoins such as USDC and USDT.
  • Implement a better security between the payment page, and the Shopware return URL. Currently the payment status is passed through a GET parameter.
  • Improve the payment screen in the frontend
  • Add live reloading in the payment screen by polling the API. (I would rewrite this to call the API asynchronously, so the payment also gets processed in the background if the customer closes his browser)
  • Rewrite usage of AlgoExplorer API to still only call it at the most once every few seconds, even if a hundred orders happen at once. (This can be done by loading the transactions, caching, and filtering them server-side instead of using the filters of the API)

Contribute

PRs are welcome to the repo!
https://github.com/runelaenen/sw6-algorand-payments

Conclusion

I think the takeaway from this Proof of Concept, should be that Algorand can be a revolutionary system to allow payments on webshops and other e-commerce websites due to the extremely low fee, and fast transaction speed.