diff options
author | Tim Leibacher <tim.leibacher@gmail.com> | 2023-05-31 10:53:34 +0200 |
---|---|---|
committer | Tim Leibacher <tim.leibacher@gmail.com> | 2023-05-31 10:53:34 +0200 |
commit | 7e4014b73f3f631fd9f1f3ca74a2ace0d4f04dbe (patch) | |
tree | e1d9971b299c44724c6f346672afb8f3666209f6 | |
download | joomla-payage-taler-plugin-7e4014b73f3f631fd9f1f3ca74a2ace0d4f04dbe.tar.gz joomla-payage-taler-plugin-7e4014b73f3f631fd9f1f3ca74a2ace0d4f04dbe.tar.bz2 joomla-payage-taler-plugin-7e4014b73f3f631fd9f1f3ca74a2ace0d4f04dbe.zip |
Init Push
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | COPYING | 339 | ||||
-rw-r--r-- | Makefile | 10 | ||||
-rw-r--r-- | README.md | 103 | ||||
-rw-r--r-- | com_payage_taler/currencies.csv | 2 | ||||
-rw-r--r-- | com_payage_taler/install.php | 62 | ||||
-rw-r--r-- | com_payage_taler/language/en-GB/en-GB.com_payage_taler_leibacher.ini | 11 | ||||
-rw-r--r-- | com_payage_taler/pay_buttons/taler_button_grey_128.png | bin | 0 -> 5179 bytes | |||
-rw-r--r-- | com_payage_taler/pay_buttons/taler_button_grey_200.png | bin | 0 -> 6528 bytes | |||
-rw-r--r-- | com_payage_taler/pay_buttons/taler_button_grey_232.png | bin | 0 -> 6450 bytes | |||
-rw-r--r-- | com_payage_taler/pay_buttons/taler_button_orange_128.png | bin | 0 -> 5181 bytes | |||
-rw-r--r-- | com_payage_taler/pay_buttons/taler_button_orange_200.png | bin | 0 -> 6336 bytes | |||
-rw-r--r-- | com_payage_taler/pay_buttons/taler_button_orange_232.png | bin | 0 -> 6247 bytes | |||
-rw-r--r-- | com_payage_taler/payage_taler_leibacher.xml | 55 | ||||
-rw-r--r-- | com_payage_taler/taler_leibacher.php | 622 | ||||
-rw-r--r-- | com_payage_taler/taler_leibacher.xml | 27 | ||||
-rw-r--r-- | dis/Setup/README.md | 8 | ||||
-rw-r--r-- | dis/Setup/setup.sh | 91 |
18 files changed, 1331 insertions, 0 deletions
@@ -0,0 +1 @@ +Tim Jeremy Leibacher <timjeremy.leibacher@students.bfh.ch> @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..39ca866 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +# This file is in the public domain. +VERSION=1.0 + +all: + ln -s com_payage_taler com_payage_taler_$(VERSION) + zip -r com_payage_taler_$(VERSION).zip com_payage_taler_$(VERSION) + rm com_payage_taler_$(VERSION) + +clean: + rm -f com_payage_taler_$(VERSION).zip diff --git a/README.md b/README.md new file mode 100644 index 0000000..0ad2f69 --- /dev/null +++ b/README.md @@ -0,0 +1,103 @@ +# Taler Gateway For Payage + +## Introduction + +Welcome to the user documentation for the Payage Gateway that +integrates Taler as a payment option for your website. This +documentation will guide you through the installation, configuration, +and usage of the plugin. It is important to note that this is not a +stand-alone plugin and requires the Payage component to be installed +and configured on your website. For more information on Payage, please +visit the [Payage +Documentation](https://www.lesarbresdesign.info/extensions/payage) + +## Table of Contents + +- [Installation](#installation) +- [Configuration](#configuration) +- [Usage](#usage) + - [Enabling Taler Payment](#enabling-taler-payment) + - [Managing Taler Settings](#managing-taler-settings) +- [Troubleshooting](#troubleshooting) +- [Frequently Asked Questions](#frequently-asked-questions) + +## Installation + +First make sure you have already a version of the Payage Plugin +installed. If not, please follow the [Payage Installation +Guide](https://www.lesarbresdesign.info/extensions/payage/installation). +If you have already installed Payage, you can install the Taler plugin +simply by donwloading the latest version from the [Taler Plugin +Releases](https://ftp.gnu.org/gnu/taler/com_payage_taler-latest.zip) +and installing it through the Joomla plugin manager. + +### Enabling Taler Payment + +To create a new instance for a Taler Gateway, navigate to the Payage +component and select the "Gateway Accounts" tab. Click on the "New" +button to create a new gateway instance. Select "Taler" as the gateway +type and fill out the required fields. If you have filled out all the +required fields you can test if the Taler Backend you configured is +valid with the "Test" button. If the test is successful you can "Save" +the gateway. Now you only need to publish it from inside the "Gateway +Accounts" tab. To see how to create a payment button inside your +E-commerce app, refer to the Payage Documentation. + +## Special Currencies + +The Taler Payage plugin supports all common currencies. However, if +you want to use a special currencies that do not have a 3 letter +ISO-4217 currency code, you have to add an explicit mapping to a 3 +letter currency code: Payage is limited to 3 letter currency codes +while Taler supports currency codes with up to 11 letters. + +To do so, clone the Git repository from [Taler Plugin +Releases](https://gitlab.ti.bfh.ch/leibt2/taler-joomla) and edit the +file "com_payage_taler/currencies.csv". There is already an example +for the Taler test currency "KUDOS". To add a new special currency, +simply add a new line following the same format of +"$NAME,$ABBREVIATION". Then submit a patch to the maintainers (see +AUTHORS) to ensure that the new currency is available in future +releases. The abbreviation should be some 3 letter code that is *not* +in ISO-4217. Note that in theory new currency codes could be added to +ISO-4217, so such unofficial currency codes may need to be removed in +the future. + +## Webhook Configuration For Refunds + +To update the Payage database automatically when a refund is made, you +have to configure a webhook in the Taler merchant backend. To do so, +log into the Taler merchant backend Web interface and select the +"Webhooks" tab. Click on the "New" button to create a new webhook with +the following values: + + Id: A unique name for the webhook (say "taler-payage-refund-hook") + Event: refund + Method: 'POST' + URL: "https://example.com/index.php?option=com_payage&task=refund" + Header: 'Content-Type: application/json' + Body: '{"refunded_amount":"{{refund_amount}}","order_id":"{{order_id}}"}' + +https://tim-leibacher.ch:8443/index.php?option=com_payage&task=refund&aid=1003&tid=0 + +- Id: `A unique name for the webhook (say "taler-payage-refund-hook")` +- Event: `'refund'` +- Method: `'POST'` +- URL: `"https://example.com/index.php?option=com_payage&task=refund&aid=1000&tid=0"` + +aid stands for the account id. In the "Gateway Accounts" tab you can see which id you should use + +- Header: `'Content-Type: application/json'` +- Body: + `'{ + "order_id": "{{order_id}}" + }'` + + +## Frequently Asked Questions +Q: How can I add my own Translations? \ +A: See [Taler Translations](https://docs.taler.net/taler-developer-manual.html#how-to-create-a-translation) + +Q: Where do I get my own Taler Merchant Backend? \ +A: See [Taler Merchant Backend](https://docs.taler.net/taler-merchant-manual.html) + diff --git a/com_payage_taler/currencies.csv b/com_payage_taler/currencies.csv new file mode 100644 index 0000000..b4cadfd --- /dev/null +++ b/com_payage_taler/currencies.csv @@ -0,0 +1,2 @@ +name,abbreviation +KUDOS,KUD
\ No newline at end of file diff --git a/com_payage_taler/install.php b/com_payage_taler/install.php new file mode 100644 index 0000000..bb2872f --- /dev/null +++ b/com_payage_taler/install.php @@ -0,0 +1,62 @@ +<?php +/******************************************************************** +Product : GNU Taler Gateway for Payage +Date : 26 Feburary 2023 +Copyright : Tim Leibacher +Contact : https://www.tim-leibacher.ch/contact +Licence : GNU General Public License +*********************************************************************/ +defined('_JEXEC') or die('Restricted Access'); + +class Payage_Taler_LeibacherInstallerScript +{ +public function preflight($type, $parent) +{ + $app = JFactory::getApplication(); + $payage_xml_file = JPATH_ADMINISTRATOR.'/components/com_payage/payage.xml'; + if (!file_exists($payage_xml_file)) + { + $app->enqueueMessage("Please install Payage before installing gateway addons", 'error'); + return false; + } + + $xml_array = JInstaller::parseXMLInstallFile($payage_xml_file); + $payage_version = $xml_array['version']; + if (version_compare($payage_version,"2.28","<")) + { + $app->enqueueMessage("This Payage addon requires at least Payage 2.28. Please install the latest version of Payage first.", 'error'); + return false; + } + +// get the previously installed version, if any + + if (file_exists(JPATH_ADMINISTRATOR.'/components/com_payage/payage_taler_leibacher.xml')) + { + $xml_array = JInstaller::parseXMLInstallFile(JPATH_ADMINISTRATOR.'/components/com_payage/payage_taler_leibacher.xml'); + $this->previous_version = $xml_array['version']; + } + + return true; +} + +//------------------------------------------------------------------------------- +// Called at uninstall time +// +public function uninstall($parent) +{ + $app = JFactory::getApplication(); + $app->enqueueMessage("Taler gateway for Payage has been uninstalled."); +} + +//------------------------------------------------------------------------------- +// The main install function +// +public function postflight($type, $parent) +{ + $this->app = JFactory::getApplication(); + $this_version = $parent->getManifest()->version; + $this->app->enqueueMessage("Payage Taler version $this_version installed.", 'message'); + return true; +} + +} diff --git a/com_payage_taler/language/en-GB/en-GB.com_payage_taler_leibacher.ini b/com_payage_taler/language/en-GB/en-GB.com_payage_taler_leibacher.ini new file mode 100644 index 0000000..cc65d63 --- /dev/null +++ b/com_payage_taler/language/en-GB/en-GB.com_payage_taler_leibacher.ini @@ -0,0 +1,11 @@ +COM_PAYAGE_TALER_BACKEND_URL="Taler Backend URL" +COM_PAYAGE_TALER_BACKEND_URL_DESC="Set the URL of the Taler merchant backend. (Example: 'https://backend.demo.taler.net/')" +COM_PAYAGE_TALER_REFUND_TIME="Taler Refund Time" +COM_PAYAGE_TALER_KEY="Taler Backend API Key" +COM_PAYAGE_TALER_KEY_DESC="Must start with 'secret-token:'" +COM_PAYAGE_TALER_CURRENCY_NOT_FOUND="You are using a custom currency that is not recognized. Please add it to the 'currencies.csv'." +COM_PAYAGE_GATEWAY_TEST_BAD_KEY="Wrong Taler merchant backend or invalid secret token" +COM_PAYAGE_GATEWAY_TEST_PASSED="Connection established successfully" +COM_PAYAGE_TALER_REFUND_TIME_DESCRIPTION="Time in seconds after order was created" +COM_PAYAGE_GATEWAY_TEST_BAD_URL="Backend URL is not reachable" +COM_PAYAGE_GATEWAY_TEST_SERVER_ERROR="Server error"
\ No newline at end of file diff --git a/com_payage_taler/pay_buttons/taler_button_grey_128.png b/com_payage_taler/pay_buttons/taler_button_grey_128.png Binary files differnew file mode 100644 index 0000000..cea1f53 --- /dev/null +++ b/com_payage_taler/pay_buttons/taler_button_grey_128.png diff --git a/com_payage_taler/pay_buttons/taler_button_grey_200.png b/com_payage_taler/pay_buttons/taler_button_grey_200.png Binary files differnew file mode 100644 index 0000000..d81f8f1 --- /dev/null +++ b/com_payage_taler/pay_buttons/taler_button_grey_200.png diff --git a/com_payage_taler/pay_buttons/taler_button_grey_232.png b/com_payage_taler/pay_buttons/taler_button_grey_232.png Binary files differnew file mode 100644 index 0000000..31036a7 --- /dev/null +++ b/com_payage_taler/pay_buttons/taler_button_grey_232.png diff --git a/com_payage_taler/pay_buttons/taler_button_orange_128.png b/com_payage_taler/pay_buttons/taler_button_orange_128.png Binary files differnew file mode 100644 index 0000000..c790d98 --- /dev/null +++ b/com_payage_taler/pay_buttons/taler_button_orange_128.png diff --git a/com_payage_taler/pay_buttons/taler_button_orange_200.png b/com_payage_taler/pay_buttons/taler_button_orange_200.png Binary files differnew file mode 100644 index 0000000..1a7924a --- /dev/null +++ b/com_payage_taler/pay_buttons/taler_button_orange_200.png diff --git a/com_payage_taler/pay_buttons/taler_button_orange_232.png b/com_payage_taler/pay_buttons/taler_button_orange_232.png Binary files differnew file mode 100644 index 0000000..fb90b6d --- /dev/null +++ b/com_payage_taler/pay_buttons/taler_button_orange_232.png diff --git a/com_payage_taler/payage_taler_leibacher.xml b/com_payage_taler/payage_taler_leibacher.xml new file mode 100644 index 0000000..aedea61 --- /dev/null +++ b/com_payage_taler/payage_taler_leibacher.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="utf-8"?> +<extension type="file" version="3.7.0" method="upgrade"> + <name>Payage_Taler</name> + <creationDate>26 February 2023</creationDate> + <author>Tim Leibacher</author> + <copyright>Tim Leibacher</copyright> + <license>GNU/GPL</license> + <authorUrl>https://Tim-Leibacher.ch</authorUrl> + <version>1.0</version> + <description>Taler Gateway for Payage</description> + + <scriptfile>install.php</scriptfile> + + <gateway_info> + <type>Taler_Leibacher</type> + <shortName>Taler</shortName> + <longName>Taler Payments</longName> + <defaultButton>images/pay_buttons/taler_button_grey_232</defaultButton> + <defaultTitle>Pay with Taler</defaultTitle> + <gatewayUrl>https://taler.net/</gatewayUrl> + <helpUrl>https://www.google.com</helpUrl> + <docUrl>https://www.tim-leibacher.ch/taler/doc</docUrl> + </gateway_info> + + <fileset> + <files target="administrator/components/com_payage"> + <filename>payage_taler_leibacher.xml</filename> + </files> + + <files target="images"> + <folder>pay_buttons</folder> + </files> + + <files target="administrator/components/com_payage/models"> + <filename>taler_leibacher.php</filename> + </files> + + <files target="administrator/components/com_payage/forms"> + <filename>taler_leibacher.xml</filename> + </files> + + <files folder="language/en-GB" target="administrator/components/com_payage/language/en-GB"> + <filename>en-GB.com_payage_taler_leibacher.ini</filename> + </files> + + <files target="administrator/components/com_payage"> + <filename>currencies.csv</filename> + </files> + </fileset> + + <updateservers> + <server type="extension" priority="2" name="Taler Component"><![CDATA[https://ftp.gnu.org/gnu/taler/com_payage_taler-latest.zip]]></server> + </updateservers> + +</extension> diff --git a/com_payage_taler/taler_leibacher.php b/com_payage_taler/taler_leibacher.php new file mode 100644 index 0000000..7d512c7 --- /dev/null +++ b/com_payage_taler/taler_leibacher.php @@ -0,0 +1,622 @@ +<?php +/** + * @version 1.0.0 + + * @date 2023-05-29 + * @copyright 2023 Tim Leibacher + * @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU/GPLv2 + */ +defined("_JEXEC") or die("Restricted Access"); + +use Joomla\CMS\Uri\Uri; + +/** + * @since 1.0.0 + */ +class PayageModelTaler_Leibacher extends PayageModelAccount +{ + /** + * Default response timeout (in seconds). + */ + public const DEFAULT_TIMEOUT = 10; + /** + * Default connect timeout (in seconds). + */ + public const DEFAULT_CONNECT_TIMEOUT = 5; + + /** + * HTTP Methods + */ + public const HTTP_GET = "GET"; + public const HTTP_POST = "POST"; + + var $app = null; + + var $common_data = null; + + var $specific_data = null; + + function __construct() + { + parent::__construct(); + $xml_array = JInstaller::parseXMLInstallFile(JPATH_ADMINISTRATOR . '/components/com_payage/payage_taler_leibacher.xml'); + $this->gw_addon_version = $xml_array['version']; + LAPG_trace::trace("Taler: v" . $this->gw_addon_version); + } + + // ------------------------------------------------------------------------------- + // Initialise data items specific to this gateway + // - the account class initialises the common data items + // + public function initData($gateway_info) + { + parent::initData($gateway_info); + $this->specific_data = new stdClass; + $this->specific_data->backend_url = ''; + $this->specific_data->backend_key = ''; + $this->specific_data->currency = ''; + $this->specific_data->refund_time = ''; + $this->specific_data->tid_optional = true; + + } + + // ------------------------------------------------------------------------------- + // Get the post data specific to this gateway + // - the account class gets the common data items + // + public function getPostData() + { + parent::getPostData(); + $this->specific_data = new stdClass; + $jinput = JFactory::getApplication()->input; + $this->specific_data->test_mode = $jinput->get('test_mode', '0', 'STRING'); + $this->specific_data->backend_url = $jinput->get('backend_url', '', 'STRING'); + $this->specific_data->backend_key = $jinput->get('backend_key', '', 'STRING'); + $this->specific_data->refund_time = $jinput->get('refund_time', '', 'STRING'); + $currency = $this->create_payment(self::HTTP_GET, $this->specific_data->backend_url . '/config', null)['currency']; + $this->specific_data->tid_optional = true; + + // To allow for custom currencies which don't use 3 Letter abbreviation + if (strlen($currency) != 3) + { + $this->specific_data->currency = $this->convertCurrency($currency, "currency2Abr"); + } + else + { + $this->specific_data->currency = $currency; + } + + $this->common_data->account_currency = $this->specific_data->currency; + + $languages = PayageHelper::get_site_languages(); + + foreach ($languages as $tag => $name) + { + $this->translations[$tag]['account_language'] = $jinput->get($tag . '_account_language', '', 'string'); + } + + return $this->specific_data; + } + + function convertCurrency($currency, $conversionType) + { + defined('JPATH_PAYMENT') or define('JPATH_PAYMENT', JPATH_SITE . '/administrator/components/com_payage'); + $file = JPATH_PAYMENT . '/currencies.csv'; + + if (JFile::exists($file)) + { + // Open the CSV file + $file = fopen($file, 'r'); + + while (($row = fgetcsv($file)) !== false) + { + if ($conversionType === 'currency2Abr' && $row[0] == $currency) + { + $value = $row[1]; + fclose($file); + LAPG_trace::trace($value); + + return $value; + } + elseif ($conversionType === 'abr2Currency' && $row[1] == $currency) + { + $value = $row[0]; + fclose($file); + + return $value; + } + } + } + + $errors[] = JText::_('COM_PAYAGE_INVALID') . ' ' . JText::_('COM_PAYAGE_TALER_CURRENCY_NOT_FOUND'); + $this->app->enqueueMessage(implode('<br />', $errors), 'error'); + + return 'ERR'; + } + + // ------------------------------------------------------------------------------- + // Validate the account details + // - the account class checks the common data items + // + public function check_post_data() + { + $errors = array(); + $ok = parent::check_post_data(); // Check the common data + + if (!str_starts_with($this->specific_data->backend_url, "http")) + { + $errors[] = JText::_('COM_PAYAGE_INVALID') . ' ' . JText::_('COM_PAYAGE_TALER_BACKEND_URL'); + } + + if (!str_starts_with($this->specific_data->backend_key, "secret-token:")) + { + $errors[] = JText::_('COM_PAYAGE_INVALID') . ' ' . JText::_('COM_PAYAGE_TALER_KEY'); + } + + if (!ctype_digit(trim($this->specific_data->refund_time))) + { + $errors[] = JText::_('COM_PAYAGE_INVALID') . ' ' . JText::_('COM_PAYAGE_TALER_REFUND_TIME'); + } + + if (!empty($errors)) + { + $this->app->enqueueMessage(implode('<br />', $errors), 'error'); + $ok = false; + } + + return $ok; + } + + // ------------------------------------------------------------------------------- + // handle an incoming request from the payment gateway + // - we assume this is a genuine request because the front end found the account and payment records + // our model instance already has $this->common_data and $this->specific_data + // + public function Gateway_handle_request($payment_model) + { + + $jinput = JFactory::getApplication()->input; + $task = $jinput->get('task', '', 'STRING'); + $this->payment_model = $payment_model; + $this->payment_data = $payment_model->data; + + switch ($task) + { + case 'create': // Someone clicked a Payage Taler payment button + $action = $this->create(); + + return $action; + + case 'return': + case 'update': + case 'refund': // Used for the webhook + return $this->handle_return($task); + + case 'cancel': + return LAPG_CALLBACK_CANCEL; + + default: + LAPG_trace::trace("Taler handle_request() unknown task $task"); + + return LAPG_CALLBACK_BAD; // Should never happen + } + + } + + // ------------------------------------------------------------------------------- + // Create a payment in Taler + // - we redirect here from Taler payment buttons + // + private function create() + { + LAPG_trace::trace('Taler create() for Payage transaction id: ' . $this->payment_data->pg_transaction_id); + + $this->payment_data->account_id = $this->common_data->id; // Save the account_id now in case of errors + $this->payment_data->gw_addon_version = $this->gw_addon_version; + $stored = $this->payment_model->store(); + + if (!function_exists('curl_version')) + { + LAPG_trace::trace("CURL not installed - cannot use Taler"); + $this->payment_data->pg_status_code = LAPG_STATUS_FAILED; + $this->payment_data->pg_status_text = JText::_('COM_PAYAGE_CURL_NOT_INSTALLED'); + $stored = $this->payment_model->store(); + + return LAPG_CALLBACK_USER; // Return to the calling application + } + + // Set up the payment in the gateway + + $redirectUrl = htmlentities(JURI::root() . 'index.php?option=com_payage&task=return&aid=' . $this->common_data->id . '&tid=' . $this->payment_data->pg_transaction_id . '&tmpl=component&format=raw'); + $customer_fee = parent::calculate_gateway_fee($this->common_data, $this->payment_data->gross_amount); + $total_amount = $this->payment_data->gross_amount + $customer_fee; + $total_amount = number_format($total_amount, 2, '.', ''); // We currently only support currencies that use two decimal places + $currency = $this->convertCurrency($this->common_data->account_currency, "abr2Currency"); + + if ($this->specific_data->refund_time < 10) + { + $refund_time = 0; + } + else + { + $refund_time = intval($this->specific_data->refund_time) * 1000; + } + + try + { + $data = array( + 'refund_delay' => array( + 'd_us' => (int) $refund_time + ), + 'order' => array( + 'amount' => $currency . ':' . $total_amount, + 'summary' => Uri::getInstance()->getHost() . ' - ' . $this->payment_data->item_name, + 'fulfillment_url' => $redirectUrl + ) + ); + + // Redirect the browser to the Taler gateway + + $response_data = $this->create_payment(self::HTTP_POST, $this->specific_data->backend_url . '/private/orders', json_encode($data)); + + $order_id = $response_data['order_id']; + $token = $response_data['token']; + + // Save the payment details so far + + $this->payment_data->gw_transaction_id = $order_id; + $stored = $this->payment_model->store(); + + $url = $this->specific_data->backend_url . '/orders/' . $order_id . '?token=' . $token; + LAPG_trace::trace("Taler redirecting to: $url"); + $app = JFactory::getApplication(); + $app->redirect($url); + + return LAPG_CALLBACK_NONE; // We are at the gateway - we will go back to the calling application later + } + catch (Exception $e) + { + $html = $e->getMessage() . '<br>' . JText::_('COM_PAYAGE_GATEWAY_TEST_RESPONSE_NOT_OK'); + $this->app->enqueueMessage($html, 'error'); + + return; + } + } + + private function create_payment($httpMethod, $url, $httpBody) + { + $curl = curl_init(); + + $headers = array( + 'Authorization: Bearer ' . $this->specific_data->backend_key, + 'Content-Type: application/json' + ); + + curl_setopt($curl, CURLOPT_URL, $url); + + curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, self::DEFAULT_CONNECT_TIMEOUT); + curl_setopt($curl, CURLOPT_TIMEOUT, self::DEFAULT_TIMEOUT); + + switch ($httpMethod) + { + case self::HTTP_POST: + curl_setopt($curl, CURLOPT_POST, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, $httpBody); + break; + case self::HTTP_GET: + break; + default: + throw new InvalidArgumentException("Invalid http method: " . $httpMethod); + } + + $response = curl_exec($curl); + $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); + + if ($response === false) + { + $curlErrorMessage = "Curl error: " . curl_error($curl); + curl_close($curl); + throw new ErrorException($curlErrorMessage); + } + + curl_close($curl); + $responseData = json_decode($response, true); + $responseData['httpCode'] = $httpCode; + + return $responseData; + } + + // ------------------------------------------------------------------------------- + // handle a return from Taler + // - this is when Taler re-directs back to the client site after a payment + // + private function handle_return($task) + { + LAPG_trace::trace("Taler handle_return($task) for Payage transaction id: " . $this->payment_data->pg_transaction_id); + + // Used for the Webhook to get the correct Order + if ($task == 'refund') + { + if ($_SERVER['REQUEST_METHOD'] === 'POST') + { + if ($_SERVER['CONTENT_TYPE'] === 'application/json') + { + $json_data = file_get_contents('php://input'); + $body = json_decode($json_data, true); + + if ($body !== null) + { + $orderId = $body['order_id']; + + LAPG_trace::trace('Order with Id: ' . $orderId . ' is being refunded'); + + $this->payment_data = $this->payment_model->getOne($orderId, 'gw_transaction_id'); + } + else + { + LAPG_trace::trace("Missing Order ID in JSON body"); + + return LAPG_STATUS_FAILED; + } + } + else + { + LAPG_trace::trace("refunds triggered but without a JSON header"); + + return LAPG_STATUS_FAILED; + } + } + else + { + LAPG_trace::trace("refund triggered but wihtout a POST request"); + + return LAPG_STATUS_FAILED; + } + } + + // Get the payment status from the gateway + $response_data = $this->create_payment(self::HTTP_GET, $this->specific_data->backend_url . '/private/orders/' . $this->payment_data->gw_transaction_id, null); + $status = $response_data['order_status']; + + switch ($status) + { + case 'paid': + $new_status_code = LAPG_STATUS_SUCCESS; + break; + case 'expired': + case 'canceled': + $new_status_code = LAPG_STATUS_CANCELLED; + break; + case 'failed': + $new_status_code = LAPG_STATUS_FAILED; + break; + case 'pending': + case 'unpaid': + $new_status_code = LAPG_STATUS_PENDING; + break; + default: + $new_status_code = LAPG_STATUS_FAILED; + } + + // Check for refunds + + $refund_description = ''; + + if ($response_data['refunded']) + { + $amount_refunded = trim(explode(':', $response_data['refund_amount'])[1]); + $amount_total = trim(explode(':', $response_data['contract_terms']['amount'])[1]); + $refund_details = $response_data['refund_details']; + $refund_description = 'Taler: ' . JText::_('COM_PAYAGE_REFUNDED') . ' ' . $amount_refunded . ' details: ' . end($response_data['refund_details'])['reason']; + LAPG_trace::trace("Taler: $refund_description"); + $amount_remaining = (float) $amount_total - (float) $amount_refunded; + + if ($amount_remaining == 0.0) + { + $new_status_code = LAPG_STATUS_REFUNDED; + $status = 'refunded'; + } + } + + // Multiple calls + + $result = $this->payment_model->ladb_lockTable('#__payage_payments'); + + if ($result === true) + { + LAPG_trace::trace('Locked the payment table ok'); + } + else + { + LAPG_trace::trace('Failed to lock the payment table: ' . $this->payment_model->ladb_error_text); + } + + $this->payment_data = $this->payment_model->getOne($this->payment_data->id); + $this->payment_data->account_id = $this->common_data->id; + $this->payment_data->gw_addon_version = $this->gw_addon_version; + $this->payment_data->pg_status_code = $new_status_code; + $this->payment_data->pg_status_text = $status; + + // Update the history + + if ($refund_description != '') + { + $this->payment_model->add_history_entry($refund_description); + } + else + { + $status_description = PayageHelper::getPaymentDescription($this->payment_data->pg_status_code); + $this->payment_model->add_history_entry("Taler: $status_description"); + } + + // Update the payment record + // we store some details in the root of gw_transaction_details so they are easily visible + // we also store each update separately in case something goes wrong and we need to see the full history + + $stored = $this->payment_model->store(); + $this->payment_model->ladb_unlock(); + + // For a 'return' task, we redirect to the calling application + + if ($task == 'return') + { + LAPG_trace::trace("Taler $task returning LAPG_CALLBACK_USER"); + + return LAPG_CALLBACK_USER; + } + + // It's an 'update' + // if this was a refund, we must update the application + + if ($new_status_code == LAPG_STATUS_REFUNDED) + { + LAPG_trace::trace("Taler $task [refund], returning LAPG_CALLBACK_UPDATE"); + + return LAPG_CALLBACK_UPDATE; + } + + LAPG_trace::trace("Taler $task, returning LAPG_CALLBACK_NONE"); + + return LAPG_CALLBACK_NONE; + } + + + // ------------------------------------------------------------------------------- + // Verify the amount, currency and recipient of a payment + // - set the payment status code and text accordingly + // + private function check_payment($customer_fee, $gross_received, $currency_received, $receiver_email) + { + $expected_gross = $this->payment_data->gross_amount; + $expected_total = $expected_gross + $customer_fee; + $str_expected_total = number_format($expected_total, 2); + $str_actual_total = number_format($gross_received, 2); + LAPG_trace::trace("check_payment() gross_amount = $expected_gross, customer_fee = $customer_fee, expected_payment_amount = $expected_total, gross_received = $gross_received"); + + if (!isset($this->specific_data->auto_tax)) + { + // New parameter may not have been saved yet + $this->specific_data->auto_tax = 0; // default to no + } + + if (($this->specific_data->auto_tax == 0) && ($str_expected_total != $str_actual_total)) + { + $this->payment_data->pg_status_code = LAPG_STATUS_FAILED; + $this->payment_data->pg_status_text = JText::sprintf("COM_PAYAGE_MISMATCH_AMOUNT", $str_expected_total, $str_actual_total); + LAPG_trace::trace($this->payment_data->pg_status_text); + } + + if (($this->specific_data->auto_tax == 1) && ($str_actual_total < $str_expected_total)) + { + $this->payment_data->pg_status_code = LAPG_STATUS_FAILED; + $this->payment_data->pg_status_text = JText::sprintf("COM_PAYAGE_MISMATCH_AMOUNT", $str_expected_total, $str_actual_total); + LAPG_trace::trace($this->payment_data->pg_status_text); + } + + if ($this->common_data->account_currency != $currency_received) + { + $this->payment_data->pg_status_code = LAPG_STATUS_FAILED; + $this->payment_data->pg_status_text = JText::sprintf("COM_PAYAGE_MISMATCH_CURRENCY", $this->common_data->account_currency, $currency_received); + LAPG_trace::trace($this->payment_data->pg_status_text); + } + + if (strcasecmp($this->common_data->account_email, $receiver_email) == 0) + { + return; + } + + if (isset($this->specific_data->account_primary_email) && strcasecmp($this->specific_data->account_primary_email, $receiver_email) == 0) + { + return; + } + + $this->payment_data->pg_status_code = LAPG_STATUS_FAILED; + + if (isset($this->specific_data->account_primary_email)) + { + $email_address = $this->common_data->account_email . ' OR ' . $this->specific_data->account_primary_email; + } + else + { + $email_address = $this->common_data->account_email; + } + + $this->payment_data->pg_status_text = JText::sprintf("COM_PAYAGE_MISMATCH_RECIPIENT", $email_address, $receiver_email); + LAPG_trace::trace($this->payment_data->pg_status_text); + } + + + // ------------------------------------------------------------------------------- + // Build a Buy Now button + // + public function Gateway_make_button($payment_data, $call_array, $app_fee) + { + + $process_url = JURI::root() . 'index.php?option=com_payage&task=create&aid=' . $this->common_data->id . '&tid=' . $payment_data->pg_transaction_id . '&tmpl=component&format=raw'; + $button_url = JURI::base(true) . '/' . $this->common_data->button_image; + $html = '<form class="pb-form pb-taler" action="' . $process_url . '" method="post" >'; + $html .= '<input type="image" src="' . $button_url . '" alt="Taler" title="' . $this->common_data->button_title . '" ' . $call_array['button_extra'] . '>'; + $html .= "</form>"; + + return $html; + } + + // ------------------------------------------------------------------------------- + // Test a Taler API call + // + public function Gateway_test() + { + LAPG_trace::trace("Taler gateway test with key " . $this->specific_data->backend_key); + $curl_info = curl_version(); + $curl_version = $curl_info['version']; + LAPG_trace::trace("PHP version: " . PHP_VERSION); + LAPG_trace::trace("CURL version: $curl_version"); + LAPG_trace::trace("Openssl version: " . OPENSSL_VERSION_TEXT); + + if (!function_exists('curl_version')) + { + $this->app->enqueueMessage("FAIL: CURL is not installed", 'error'); + + return; + } + + try // Try to connect to Taler + { + $response_data = $this->create_payment(self::HTTP_GET, $this->specific_data->backend_url . '/private', json_encode($data)); + $httpCode = $response_data['httpCode']; + + switch ($httpCode) + { + case 200: + case 201: + $msg = JText::_('COM_PAYAGE_GATEWAY_TEST_PASSED'); + $this->app->enqueueMessage($msg, 'message'); + break; + case 401: + $msg = JText::_('COM_PAYAGE_GATEWAY_TEST_BAD_KEY'); + $this->app->enqueueMessage($msg, 'error'); + break; + case 404: + $msg = JText::_('COM_PAYAGE_GATEWAY_TEST_BAD_URL'); + $this->app->enqueueMessage($msg, 'error'); + break; + case str_starts_with($httpCode, '5'): + $msg = JText::_('COM_PAYAGE_GATEWAY_TEST_SERVER_ERROR'); + $this->app->enqueueMessage($msg, 'error'); + break; + } + } + catch (Exception $e) + { + $html = $e->getMessage() . '<br>' . JText::_('COM_PAYAGE_GATEWAY_TEST_RESPONSE_NOT_OK'); + $this->app->enqueueMessage($html, 'error'); + + return; + } + + LAPG_trace::trace("Taler Gateway_test done"); + } +} + diff --git a/com_payage_taler/taler_leibacher.xml b/com_payage_taler/taler_leibacher.xml new file mode 100644 index 0000000..621605f --- /dev/null +++ b/com_payage_taler/taler_leibacher.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<form> + <fieldset name="main"> + <field name="account_name" type="text" class="input-xlarge" label="COM_PAYAGE_ACCOUNT_NAME" required="true" /> + + <field name="test_mode" type="hidden" /> + + <field name="backend_url" type="text" class ="input-xlarge" label="COM_PAYAGE_TALER_BACKEND_URL" description="COM_PAYAGE_TALER_BACKEND_URL_DESC" required="true" /> + + <field name="backend_key" type="text" class ="input-xlarge" label="COM_PAYAGE_TALER_KEY" description="COM_PAYAGE_TALER_KEY_DESC" required="true" /> + + + <field name="button_image" type="media" label="COM_PAYAGE_BUTTON" directory="pay_buttons" /> + + <field name="account_description" type="text" class="input-xxlarge" label="COM_PAYAGE_DESCRIPTION" description="COM_PAYAGE_ACCOUNT_DESCRIPTION_DESC" /> + + <field name="account_group" type="text" class="input-xlarge" label="COM_PAYAGE_GROUP" /> + + <field name="refund_time" type="text" class="input-xlarge" label="COM_PAYAGE_TALER_REFUND_TIME" description="COM_PAYAGE_TALER_REFUND_TIME_DESCRIPTION" /> + + <field name="currency_symbol" type="text" class="input-xxlarge" default="£" label="COM_PAYAGE_CURRENCY_SYMBOL" required="true" /> + + + + </fieldset> + +</form> diff --git a/dis/Setup/README.md b/dis/Setup/README.md new file mode 100644 index 0000000..47d7c7f --- /dev/null +++ b/dis/Setup/README.md @@ -0,0 +1,8 @@ +# Setup + +Webserver: apache2 +Database: mariadb +Joomla: V 4.2 + +Joobla Admin: leibt2 leibt2 +Joomla_DB: joomla_user Password123! diff --git a/dis/Setup/setup.sh b/dis/Setup/setup.sh new file mode 100644 index 0000000..4b6cbd8 --- /dev/null +++ b/dis/Setup/setup.sh @@ -0,0 +1,91 @@ +#!/bin/bash + +MYSQL_ROOT_PASSWORD="Password123!" +JOOMLADB_PASSWORD="Password123!" +WEBSITE="tim-leibacher.ch" +NAME="tim-leibacher" +#exec 2> error 1> mylog + + + +sudo apt update && sudo apt upgrade -y + +echo "Installing apache2" + +sudo apt install apache2 -y +sudo systemctl start apache2 +sudo systemctl enable apache2 + + +echo "installing php" + +sudo apt install php libapache2-mod-php php-dev php-bcmath php-intl php-soap php-zip php-curl php-mbstring php-mysql php-gd php-xml -y + +#Recommended settings from Joomla +sudo sed -i "s/memory_limit = .*/memory_limit = 512M/" /etc/php/7.2/fpm/php.ini +sudo sed -i "s/upload_max_filesize = .*/upload_max_filesize = 128M/" /etc/php/7.2/fpm/php.ini +sudo sed -i "s/post_max_size = .*/post_max_size = 128M/" /etc/php/7.2/fpm/php.ini +sudo sed -i "s/max_execution_time = .*/max_execution_time = 3000/" /etc/php/7.2/fpm/php.ini + +echo "installing mariadb" + +sudo apt install mariadb-server -y +systemctl start mariadb +systemctl enable mariadb + + +create_DB="CREATE DATABASE IF NOT EXISTS joomla;" +create_USER="CREATE USER IF NOT EXISTS 'joomla_user'@'localhost' IDENTIFIED BY '$JOOMLADB_PASSWORD';" +privilege="GRANT ALL ON joomla.* TO 'joomla_user'@'localhost';" +flushDB="FLUSH PRIVILEGES;" + +sudo mysql -e "$create_DB" +sudo mysql -e "$create_USER" +sudo mysql -e "$privilege" +sudo mysql -e "$flushDB" + + +echo "download Joomla" +cd /var/tmp + +sudo wget -N https://downloads.joomla.org/cms/joomla4/4-2-0/Joomla_4-2-0-Stable-Full_Package.tar.gz +sudo mkdir -p /var/www/html/$WEBSITE +sudo tar -vxf Joomla_4-2-0-Stable-Full_Package.tar.gz -C /var/www/html/$WEBSITE + +sudo chown -R www-data:www-data /var/www/html/$WEBSITE/ + + + +echo "<VirtualHost *:80> + +ServerAdmin webmaster@$WEBSITE + +ServerName $WEBSITE +ServerAlias www.$WEBSITE +DocumentRoot /var/www/html/$WEBSITE + +<Directory /var/www/html/$WEBSITE/> + Options FollowSymlinks + AllowOverride All + Require all granted +</Directory> + +ErrorLog ${APACHE_LOG_DIR}/${WEBSITE}_error.log +CustomLog ${APACHE_LOG_DIR}/${WEBSITE}_access.log combined + +</VirtualHost>" > /etc/apache2/sites-available/$NAME.conf + +echo "Listen 80 + +<IfModule ssl_module> + Listen 443 +</IfModule ssl_module> + +<IfModule mod_gnutls.c> + Listen 443 +</IfModule mod_gnutls.c> +" > /etc/apache2/ports.conf + + +sudo a2ensite $NAME.conf +sudo systemctl restart apache2 |