Commit 0f53c151 authored by Stefan Busemann's avatar Stefan Busemann

Merge branch 'task/integrate-donation' into 'develop'

Task/integrate donation

Closes #2, #1, #5, and #4

See merge request !249
parents 3ce8d8fb 868bf0b8
Pipeline #5767 passed with stages
in 6 minutes and 59 seconds
......@@ -28,10 +28,6 @@
"type": "vcs",
"url": "https://git-t3o.typo3.org/t3o/t3o_membership.git"
},
{
"type": "vcs",
"url": "https://git-t3o.typo3.org/t3o/t3o_donation.git"
},
{
"type": "vcs",
"url": "https://git-t3o.typo3.org/t3o/randombanners.git"
......@@ -55,7 +51,6 @@
"t3o/typo3_roadmap": "^2.0",
"t3o/t3o_membership": "^2.0",
"t3o/randombanners": "^1.0",
"t3o/t3o_donation": "^0.9",
"clickstorm/cs_seo": "^2.3",
"gordalina/cachetool": "^3.2",
"cweagans/composer-patches": "^1.6",
......@@ -76,7 +71,8 @@
},
"autoload": {
"psr-4": {
"T3o\\T3orgLayout\\": "html/typo3conf/ext/t3org_layout/Classes"
"T3o\\T3orgLayout\\": "html/typo3conf/ext/t3org_layout/Classes",
"T3o\\T3oDonation\\": "html/typo3conf/ext/t3o_donation/Classes"
}
}
}
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "20712bef42d2294b356ca3cf4601728b",
"content-hash": "1d9c9f344abba78bf36d2c7d1d06b8fe",
"packages": [
{
"name": "adoy/fastcgi-client",
......@@ -1943,16 +1943,16 @@
},
{
"name": "symfony/console",
"version": "v3.4.18",
"version": "v3.4.19",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "1d228fb4602047d7b26a0554e0d3efd567da5803"
"reference": "8f80fc39bbc3b7c47ee54ba7aa2653521ace94bb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/1d228fb4602047d7b26a0554e0d3efd567da5803",
"reference": "1d228fb4602047d7b26a0554e0d3efd567da5803",
"url": "https://api.github.com/repos/symfony/console/zipball/8f80fc39bbc3b7c47ee54ba7aa2653521ace94bb",
"reference": "8f80fc39bbc3b7c47ee54ba7aa2653521ace94bb",
"shasum": ""
},
"require": {
......@@ -2008,20 +2008,20 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2018-10-30T16:50:50+00:00"
"time": "2018-11-26T12:48:07+00:00"
},
{
"name": "symfony/debug",
"version": "v3.4.18",
"version": "v3.4.19",
"source": {
"type": "git",
"url": "https://github.com/symfony/debug.git",
"reference": "fe9793af008b651c5441bdeab21ede8172dab097"
"reference": "2016b3eec2e49c127dd02d0ef44a35c53181560d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/fe9793af008b651c5441bdeab21ede8172dab097",
"reference": "fe9793af008b651c5441bdeab21ede8172dab097",
"url": "https://api.github.com/repos/symfony/debug/zipball/2016b3eec2e49c127dd02d0ef44a35c53181560d",
"reference": "2016b3eec2e49c127dd02d0ef44a35c53181560d",
"shasum": ""
},
"require": {
......@@ -2064,7 +2064,7 @@
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
"time": "2018-10-31T09:06:03+00:00"
"time": "2018-11-11T19:48:54+00:00"
},
{
"name": "symfony/dependency-injection",
......@@ -2139,16 +2139,16 @@
},
{
"name": "symfony/finder",
"version": "v3.4.18",
"version": "v3.4.19",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "54ba444dddc5bd5708a34bd095ea67c6eb54644d"
"reference": "6cf2be5cbd0e87aa35c01f80ae0bf40b6798e442"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/54ba444dddc5bd5708a34bd095ea67c6eb54644d",
"reference": "54ba444dddc5bd5708a34bd095ea67c6eb54644d",
"url": "https://api.github.com/repos/symfony/finder/zipball/6cf2be5cbd0e87aa35c01f80ae0bf40b6798e442",
"reference": "6cf2be5cbd0e87aa35c01f80ae0bf40b6798e442",
"shasum": ""
},
"require": {
......@@ -2184,7 +2184,7 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2018-10-03T08:46:40+00:00"
"time": "2018-11-11T19:48:54+00:00"
},
{
"name": "symfony/polyfill-ctype",
......@@ -2354,16 +2354,16 @@
},
{
"name": "symfony/yaml",
"version": "v3.4.18",
"version": "v3.4.19",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "640b6c27fed4066d64b64d5903a86043f4a4de7f"
"reference": "291e13d808bec481eab83f301f7bff3e699ef603"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/640b6c27fed4066d64b64d5903a86043f4a4de7f",
"reference": "640b6c27fed4066d64b64d5903a86043f4a4de7f",
"url": "https://api.github.com/repos/symfony/yaml/zipball/291e13d808bec481eab83f301f7bff3e699ef603",
"reference": "291e13d808bec481eab83f301f7bff3e699ef603",
"shasum": ""
},
"require": {
......@@ -2409,7 +2409,7 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2018-10-02T16:33:53+00:00"
"time": "2018-11-11T19:48:54+00:00"
},
{
"name": "t3o/certifications",
......@@ -2482,37 +2482,6 @@
],
"time": "2018-08-14T11:08:54+00:00"
},
{
"name": "t3o/t3o_donation",
"version": "0.9.1",
"source": {
"type": "git",
"url": "https://git-t3o.typo3.org/t3o/t3o_donation.git",
"reference": "416f9e06a9a5205d8ae1dd86ff34c95517c768a7"
},
"require": {
"typo3/cms-core": "8.5.0 - 8.9.99"
},
"replace": {
"t3o_donation": "self.version",
"typo3-ter/t3o_donation": "self.version"
},
"type": "typo3-cms-extension",
"autoload": {
"psr-4": {
"T3o\\T3oDonation\\": "Classes/"
}
},
"license": [
"GPL-3.0+"
],
"description": "An extension to make donations. Used on typo3.org",
"keywords": [
"Donation",
"TYPO3 CMS"
],
"time": "2018-10-14T11:38:39+00:00"
},
{
"name": "t3o/t3o_membership",
"version": "2.0.0",
......
<?php
namespace T3o\T3oDonation\Controller;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
/**
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Class \T3o\T3oDonation\Controller\DonationController
* @author Sebastian Diez
*/
class DonationController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
/**
* configurationUtility
*
* @var \TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility
* @inject
* @lazy
*/
protected $configurationUtility = null;
/**
* accountRepository
*
* @var \T3o\T3oDonation\Domain\Repository\AccountRepository
* @inject
* @lazy
*/
protected $accountRepository = null;
/**
* donationRepository
*
* @var \T3o\T3oDonation\Domain\Repository\DonationRepository
* @inject
* @lazy
*/
protected $donationRepository;
/**
* ipnService
*
* @var \T3o\T3oDonation\Service\PayPalIpn
* @inject
* @lazy
*/
protected $ipnService;
/**
* mailService
*
* @var \T3o\T3oDonation\Service\Mail
* @inject
* @lazy
*/
protected $mailService;
/**
* Adds custom JS to page.
*/
public function initializeAction()
{
/* @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->addJsFooterFile(
ExtensionManagementUtility::siteRelPath($this->request->getControllerExtensionKey())
. 'Resources/Public/JavaScript/donation.js'
);
parent::initializeAction();
}
/**
* @param string $optionName
* @return string
*/
protected function getConfigurationOption($optionName)
{
$config = $this->configurationUtility->getCurrentConfiguration('t3o_donation');
if (!isset($config[$optionName])) {
return '';
}
if (!isset($config[$optionName]['value'])) {
return '';
}
return $config[$optionName]['value'];
}
/**
* action list
*/
public function listAction()
{
$donations = $this->donationRepository->findAll();
$this->view->assign('donations', $donations);
}
/**
* action form
*/
public function formAction()
{
$account = $this->accountRepository->findByUid($this->settings['payPalAccount']);
$this->view->assign('account', $account);
$this->view->assign('actionUrl', $this->settings['paypal']['action']);
if ($GLOBALS['TSFE']->fe_user && $GLOBALS['TSFE']->fe_user->user['uid']) {
$userId = $GLOBALS['TSFE']->fe_user->user['uid'];
} else {
$userId = 0;
}
$this->view->assign('userId', $userId);
}
/**
* action thankyou
*/
public function thankyouAction()
{
$this->addFlashMessage(
LocalizationUtility::translate(
'thankyou_message_body',
't3o_donation'
),
LocalizationUtility::translate(
'thankyou_message_title',
't3o_donation'
),
FlashMessage::OK,
true
);
$this->forward('form');
}
/**
* action ipn log
*/
public function ipnLogAction()
{
$parameters = GeneralUtility::_POST();
$verified = $this->ipnService->verify($parameters, $this->getConfigurationOption('paypal.action'));
if (!$verified) {
$this->addFlashMessage('Payment verification failed', 'Paypal transaction', \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR);
return;
}
if (!$this->ipnService->isNewCompletedTransaction($parameters, $this->donationRepository)) {
$this->addFlashMessage('isNewCompletedTransaction == false', 'Paypal transaction', \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR);
return;
}
$donation = $this->ipnService->createDonation($parameters);
$this->donationRepository->add($donation);
$this->sendNotificationMail($donation);
$this->sendThankyouMail($donation);
//@TODO recuddderring, test address data
}
/**
* @param \T3o\T3oDonation\Domain\Model\Donation $donation
* @return bool
*/
protected function sendNotificationMail($donation)
{
if (isset($this->settings['fromName']) && $this->settings['fromName'] !== '') {
$from = [$this->settings['fromAddress'] => $this->settings['fromName']];
} else {
$from = [$this->settings['fromAddress']];
}
if (isset($this->settings['replyToName']) && $this->settings['replyToName'] !== '') {
$replyTo = [$this->settings['replyToAddress'] => $this->settings['replyToName']];
} elseif (isset($this->settings['replyToAddress']) && $this->settings['replyToAddress'] !== '') {
$replyTo = [$this->settings['replyToAddress']];
} else {
$replyTo = [];
}
return $this->mailService->sendDonationNotification(
$donation,
$from,
$replyTo
);
}
/**
* @param \T3o\T3oDonation\Domain\Model\Donation $donation
* @return bool
*/
protected function sendThankyouMail($donation)
{
if (isset($this->settings['fromName']) && $this->settings['fromName'] !== '') {
$from = [$this->settings['fromAddress'] => $this->settings['fromName']];
} else {
$from = [$this->settings['fromAddress']];
}
if (isset($this->settings['replyToName']) && $this->settings['replyToName'] !== '') {
$replyTo = [$this->settings['replyToAddress'] => $this->settings['replyToName']];
} elseif (isset($this->settings['replyToAddress']) && $this->settings['replyToAddress'] !== '') {
$replyTo = [$this->settings['replyToAddress']];
} else {
$replyTo = [];
}
return $this->mailService->sendDonationThankyou(
$donation,
$this->settings['thankyouSubject'],
$this->settings['thankyouText'],
$from,
$replyTo
);
}
}
<?php
namespace T3o\T3oDonation\Domain\Model;
/**
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Class \T3o\T3oDonation\Domain\Model\Account
* @author Sebastian Diez
*/
class Account extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* @validate NotEmpty
* @var string
*/
protected $name;
/**
* @validate NotEmpty
* @validate EmailAddress
* @var string
*/
protected $emailNotification;
/**
* @validate NotEmpty
* @validate EmailAddress
* @var string
*/
protected $emailPaypal;
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param $name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* @return string
*/
public function getEmailNotification()
{
return $this->emailNotification;
}
/**
* @param string $email
*/
public function setEmailNotification($email)
{
$this->emailNotification = $email;
}
/**
* @return string
*/
public function getEmailPaypal()
{
return $this->emailPaypal;
}
/**
* @param string $email
*/
public function setEmailPaypal($email)
{
$this->emailPaypal = $email;
}
}
<?php
namespace T3o\T3oDonation\Domain\Model;
/**
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Class \T3o\T3oDonation\Domain\Model\Donation
* @author Sebastian Diez
*/
class Donation extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* @var bool
*/
protected $hidden;
/**
* @var string
*/
protected $name;
/**
* @var string
*/
protected $company;
/**
* @var string
*/
protected $addressStreet;
/**
* @var string
*/
protected $addressZip;
/**
* @var string
*/
protected $addressCity;
/**
* @var string
*/
protected $addressState;
/**
* @var string
*/
protected $addressCountry;
/**
* @var string
*/
protected $addressCountryCode;
/**
* @validate NotEmpty
* @validate EmailAddress
* @var string
*/
protected $email;
/**
* @var string
*/
protected $url;
/**
* @var float
*/
protected $amount;
/**
* @var float
*/
protected $fee;
/**
* @var string
*/
protected $currency;
/**
* @var \TYPO3\CMS\Extbase\Domain\Model\FrontendUser
*/
protected $feUser;
/**
* @var string
*/
protected $comment;
/**
* @var \T3o\T3oDonation\Domain\Model\Account
*/
protected $account;
/**
* @var string
*/
protected $paypalTransactionId;
/**
* @var \DateTime
*/
protected $date;
/**
* @var \DateTime
*/
protected $crdate;
/**
* @return bool
*/
public function getHidden()
{
return $this->hidden;
}
/**
* @param bool $hidden
*/
public function setHidden($hidden)
{
$this->hidden = $hidden;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string $name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* @return float
*/
public function getAmount()
{
return $this->amount;
}
/**
* @param float $amount
*/
public function setAmount($amount)
{
$this->amount = (float)$amount;
}
/**
* @return float
*/
public function getFee()
{
return $this->fee;
}
/**
* @param float $fee
*/
public function setFee($fee)
{
$this->fee = (float)$fee;
}
/**
* @return string
*/
public function getCurrency()
{
return $this->currency;
}
/**
* @param string $currency
*/
public function setCurrency($currency)
{
$this->currency = $currency;
}
/**
* @param string $email