Commit 6fbb5a24 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Merge branch '1103-keys-for-donors' into 'development'

Resolve "Keys for donors"

Closes #1103

See merge request !1819
parents f606f5df 0101688d
......@@ -137,8 +137,22 @@ class MailController extends Controller
public function donation(Request $request)
{
$firstname = "";
$lastname = "";
$company = "";
$private = $request->input('person', '') === 'private' ? true : false;
if($request->input('person', '') === 'private') {
$firstname = $request->input('firstname');
$lastname = $request->input('lastname');
} elseif($request->input('person', '') === 'company') {
$company = $request->input('companyname');
}
$data = [
'name' => $request->input('Name', ''),
'person' => $request->input('person', ''),
'firstname' => $request->input('firstname', ''),
'lastname' => $request->input('lastname', ''),
'company' => $company,
'iban' => $request->input('iban', ''),
'bic' => $request->input('bic', ''),
'email' => $request->input('email', ''),
......@@ -146,7 +160,7 @@ class MailController extends Controller
'frequency' => $request->input('frequency', ''),
'nachricht' => $request->input('Nachricht', ''),
];
$name = $request->input('Name', '');
$iban = $request->input('iban', '');
$bic = $request->input('bic', '');
$email = $request->input('email', '');
......@@ -175,7 +189,6 @@ class MailController extends Controller
# Check the IBAN
$iban = new IBAN($iban);
$bic = $request->input('Bankleitzahl', '');
$country = new IBANCountry($iban->Country());
$isSEPA = filter_var($country->IsSEPA(), FILTER_VALIDATE_BOOLEAN);
......@@ -186,8 +199,10 @@ class MailController extends Controller
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$email = "anonymous@suma-ev.de";
}
if (!$iban->Verify()) {
if(($private && (empty($firstname) || empty($lastname))) || (!$private && empty($company))){
$messageToUser = trans('spende.error.name');
$messageType = "error";
} elseif (!$iban->Verify()) {
$messageToUser = trans('spende.error.iban');
$messageType = "error";
} elseif (!$isSEPA && $bic === '') {
......@@ -204,59 +219,44 @@ class MailController extends Controller
# The value has to have a maximum of 2 decimal digits
$betrag = round($betrag, 2, PHP_ROUND_HALF_DOWN);
# Folgende Felder werden vom Spendenformular als Input übergeben:
# Name
# Telefon
# email
# Kontonummer ( IBAN )
# Bankleitzahl ( BIC )
# Nachricht
$message = "\r\nName: " . $name;
$message .= "\r\nIBAN: " . $iban->HumanFormat();
if ($bic !== "") {
$message .= "\r\nBIC: " . $bic;
}
$message .= "\r\nBetrag: " . $betrag;
$message .= "\r\nHäufigkeit: " . trans('spende.frequency.' . $frequency);
$message .= "\r\nNachricht: " . $nachricht;
# Generating personalised key for donor
$key = app('App\Models\Key')->generateKey($betrag);
try {
$postdata = [
"alert" => true,
"autorespond" => true,
"source" => "API",
"name" => $name,
"entity" => "Contribution",
"action" => "mgcreate",
"api_key" => env("CIVICRM_API_KEY", ''),
"key" => env("CIVICRM_SITE_KEY", ''),
"json" => 1,
"iban" => $iban->MachineFormat(),
"bic" => $bic,
"amount" => $betrag,
"frequency" => $frequency,
"email" => $email,
"subject" => "MetaGer - Spende",
"ip" => $request->ip(),
"deptId" => 4,
"message" => "data:text/plain;charset=utf-8, $message",
"mgkey" => $key,
"message" => $nachricht
];
if (LaravelLocalization::getCurrentLocale() === "de") {
$postdata["deptId"] = 4;
if($request->input('person') === 'private') {
$postdata['first_name'] = $firstname;
$postdata['last_name'] = $lastname;
} elseif($request->input('person') === 'company') {
$postdata['business_name'] = $company;
}
if($email === "anonymous@suma-ev.de"){
$postdata["autorespond"] = false;
}
$postdata = http_build_query($postdata);
$postdata = json_encode($postdata);
$resulthash = md5($message);
$resulthash = md5(json_encode($postdata));
$mission = [
"resulthash" => $resulthash,
"url" => env("TICKET_URL", "https://metager.de"),
"url" => env("CIVICRM_URL", "https://metager.de"),
"useragent" => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0",
"username" => null,
"password" => null,
"headers" => [
"X-API-Key" => env("TICKET_APIKEY", ""),
"Content-Type" => "application/json",
"Content-Length" => strlen($postdata)
"Content-Type" => "application/x-www-form-urlencoded",
],
"cacheDuration" => 0,
"name" => "Ticket",
......@@ -296,6 +296,7 @@ class MailController extends Controller
->with('data', $data);
} else {
$data['iban'] = $iban->HumanFormat();
$data['key'] = $key;
$data = base64_encode(serialize($data));
return redirect(LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route("danke", ['data' => $data])));
}
......
......@@ -56,7 +56,6 @@ class Key
}
}
public function updateStatus()
{
$authKey = base64_encode(env("KEY_USER", "test") . ':' . env("KEY_PASSWORD", "test"));
......@@ -119,4 +118,35 @@ class Key
return false;
}
}
public function generateKey($payment)
{
$authKey = base64_encode(env("KEY_USER", "test") . ':' . env("KEY_PASSWORD", "test"));
$postdata = http_build_query(array(
'payment' => $payment,
'apiAccess' => 'normal',
'notes' => 'Fuer ' . $payment . '€ aufgeladen am '. date("d.m.Y"),
'expiresAfterDays' => 365
));
$opts = array(
'http' => array(
'method' => 'POST',
'header' => [
'Content-type: application/x-www-form-urlencoded',
'Authorization: Basic ' . $authKey
],
'content' => $postdata,
'timeout' => 5
),
);
$context = stream_context_create($opts);
try {
$link = $this->keyserver . "v2/key/";
$result = json_decode(file_get_contents($link, false, $context));
return $result->{'mgKey'};
} catch (\ErrorException $e) {
return false;
}
}
}
......@@ -30,12 +30,16 @@ return [
'bankinfo.2.2' => 'BIC: GENODEM1GLS',
'bankinfo.2.3' => 'Bank: GLS Gemeinschaftsbank, Bochum',
'bankinfo.2.4' => '(Konto-Nr.: 4075 0332 01, BLZ: 43060967)',
'bankinfo.3' => 'Falls Sie eine Spendenbescheinigung wünschen, teilen Sie uns bitte Ihre vollständige Adresse mit. Bei Spenden bis 200,-€ genügt der Kontoauszug für die Absetzbarkeit beim Finanzamt.',
'bankinfo.3' => 'Falls Sie eine Spendenbescheinigung wünschen, teilen Sie uns bitte Ihre vollständige Adresse mit. Bei Spenden bis 300,-€ genügt der Kontoauszug für die Absetzbarkeit beim Finanzamt.',
'lastschrift.1' => 'Spenden mittels elektronischem Lastschriftverfahren:',
'lastschrift.2' => 'Tragen Sie hier Ihre Kontodaten ein. Wir buchen dann entsprechend von Ihrem Konto ab. Notwendige Felder sind mit einem "*" gekennzeichnet.',
'lastschrift.3' => 'Bitte geben Sie den Namen des Kontoinhabers ein:',
'lastschrift.3.placeholder' => 'Name',
'lastschrift.3f' => 'Bitte geben Sie den Vornamen des Kontoinhabers ein:',
'lastschrift.3f.placeholder' => 'Vorname',
'lastschrift.3l' => 'Bitte geben Sie den Nachnamen des Kontoinhabers ein:',
'lastschrift.3l.placeholder' => 'Nachname',
'lastschrift.3c' => 'Bitte geben Sie den Firmenkontonamen ein:',
'lastschrift.3c.placeholder' => 'Firma',
'lastschrift.4' => 'Ihre E-Mail Adresse:',
'lastschrift.5' => 'Ihre Telefonnummer, um Ihre Spende ggf. durch einen Rückruf zu verifizieren:',
'lastschrift.6' => 'Ihre IBAN:',
......@@ -43,6 +47,9 @@ return [
'lastschrift.8.message' => 'Hier können Sie uns ggf. noch eine Mitteilung dazu senden:',
'lastschrift.8.message.placeholder' => 'Weitere Angaben',
'lastschrift.10' => 'Ihre Daten werden über eine verschlüsselte Verbindung zu uns übertragen und können von Dritten nicht mitgelesen werden. SUMA-EV verwendet Ihre Daten ausschließlich für die Spendenabrechnung; Ihre Daten werden nicht weitergegeben. Spenden an den SUMA-EV sind steuerlich absetzbar, da der Verein vom Finanzamt Hannover Nord als gemeinnützig anerkannt ist, eingetragen in das Vereinsregister beim Amtsgericht Hannover unter VR200033.',
'lastschrift.private' => '*Privatperson:',
'lastschrift.company' => '*Firma:',
'paypal.1' => 'Mit einem Klick auf Spenden werden Sie zu Paypal weitergeleitet.',
......@@ -60,16 +67,19 @@ return [
'drucken' => 'Drucken',
'danke.title' => 'Herzlichen Dank!! Wir haben Ihre Spendenbenachrichtigung für MetaGer an SUMA-EV erhalten.',
'danke.title' => 'Herzlichen Dank! Wir haben Ihre Spendenbenachrichtigung erhalten.',
'danke.nachricht' => 'Falls Sie Kontaktdaten angegeben haben, erhalten Sie demnächst auch eine persönliche Nachricht.',
'danke.kontrolle' => 'Folgende Nachricht hat uns erreicht:',
'danke.schluessel' => 'Als kleines Dankeschön bieten wir unseren Spendern einen Schlüssel für werbefreie Suchen. <br> Dieser lässt sich eingeben indem man auf das Schlüsselsymbol neben der Suchleiste klickt. <br> Ihr Schlüssel lautet: ',
'telefonnummer' => 'Telefonnummer',
'iban' => 'IBAN/Kontonummer',
'bic' => 'BIC/Bankleitzahl',
'iban' => 'IBAN',
'bic' => 'BIC',
'betrag' => 'Betrag',
'danke.message' => 'Ihre Nachricht',
'error.name' => 'Es scheint, als hätten sie keinen Namen angegeben. Bitte versuchen Sie es erneut.',
'error.iban' => 'Die eingegebene IBAN scheint nicht Korrekt zu sein. Nachricht wurde nicht gesendet.',
'error.bic' => 'Die eingegebene IBAN gehört nicht zu einem Land aus dem SEPA Raum. Für einen Bankeinzug benötigen wir eine BIC von Ihnen.',
'error.amount' => 'Der eingegebene Spendenbetrag ist ungültig. Bitte korrigieren Sie Ihre Eingabe und versuchen es erneut.',
......
......@@ -35,17 +35,20 @@ return [
"lastschrift.1" => "Donate by Sepa direct debit",
"lastschrift.2" => "Enter your account data. We will debit your bank account accordingly. This method is only available for SEPA area. Required fields are marked with \"*\"",
"lastschrift.3" => "Please enter your name:",
"lastschrift.3.placeholder" => "Name",
"lastschrift.4" => "Your E-Mail adress:",
"lastschrift.3f.placeholder" => "First Name",
"lastschrift.3l.placeholder" => "Last Name",
"lastschrift.3c.placeholder" => "Business Name",
"lastschrift.4" => "Your E-Mail Adress:",
"lastschrift.5" => "Your phone number to verify your donation by callback:",
"lastschrift.6" => "Your IBAN:",
"lastschrift.7" => "Your BIC:",
"lastschrift.8.value" => "Here you can tell us, what amount you want to donate:",
"lastschrift.8.message" => "Here you can informally add a message to your donation:",
"lastschrift.8.message.placeholder" => "message",
"lastschrift.8.message.placeholder" => "Message",
"lastschrift.9" => "Donate",
"lastschrift.10" => "Your information is transmitted encrypted and is not read by a third party. SUMA-EV only uses your information for accounting; Your information is not passed on. Donations to the SUMA-EV are tax-deductible, because the association is recognized as charitable by the Finanzamt Hannover Nord (revenue board), listed in the register of associations, Amtsgericht Hannover under VR200033. A certificate for single donations above 200,-EUR is sent automatically (post address is required!). For donations below 200,-EUR an account current is enough for tax-deduction.",
"lastschrift.10" => "Your information is transmitted encrypted and is not read by a third party. SUMA-EV only uses your information for accounting; Your information is not passed on. Donations to the SUMA-EV are tax-deductible, because the association is recognized as charitable by the Finanzamt Hannover Nord (revenue board), listed in the register of associations, Amtsgericht Hannover under VR200033. A certificate for single donations above 300,-EUR is sent automatically (post address is required!). For donations below 300,-EUR an account current is enough for tax-deduction.",
"lastschrift.private" => "*As a Person:",
"lastschrift.company" => "*As a Business:",
'paypal.1' => 'You will be redirected where you can finalize your donation.',
......
......@@ -61,6 +61,12 @@ label {
// address browser inconsistencies.
// Override content-box in Normalize (* isn't specific enough)
input[type="text"] {
background-color: @input-background;
color: @input-text;
padding: 4px 8px;
}
input[type="search"] {
.box-sizing(border-box);
}
......
......@@ -68,6 +68,7 @@
}
input:checked + .frequency-label {
border: 2px solid #f47216;
font-weight: bold;
}
}
#payment-methods {
......@@ -162,5 +163,16 @@
grid-area: form;
}
}
#input-picker{
label {
min-width: 8em;
}
.show-on-input-checked {
display: none;
}
input:checked + label + .show-on-input-checked {
display: inline-block;
}
}
}
\ No newline at end of file
.data-element {
&> label {
min-width: 100px;
}
&> input, textarea {
padding: 4px 8px;
min-width: 250px;
}
}
\ No newline at end of file
......@@ -5,52 +5,64 @@
@section('navbarFocus.donate', 'class="dropdown active"')
@section('content')
<h1>{{ trans('spende.danke.title') }}</h1>
<div class="col">
<div id="left" class="col-lg-6 col-md-12 col-sm-12 others">
<div id="donation-data" class="card-heavy">
<h2>{{ trans('spende.danke.title') }}</h2>
<p style="width:100%;" class="text-muted">{{ trans('spende.danke.nachricht') }}</p>
<h2>{{ trans('spende.danke.kontrolle') }}</h2>
<h3>{{ trans('spende.danke.kontrolle') }}</h3>
<div>
<table class="table table-condensed">
<tr>
<td>{{ trans('spende.lastschrift.3.placeholder')}}</td>
<td>{{ $data['name'] }}</td>
</tr>
<tr>
<td>Email</td>
<td>{{ $data['email'] }}</td>
</tr>
<tr>
<td>{{ trans('spende.iban') }}</td>
<td>{{ $data['iban'] }}</td>
</tr>
<tr>
<td>{{ trans('spende.bic') }}</td>
<td>{{ $data['bic'] }}</td>
</tr>
<tr>
<td>{{ trans('spende.betrag') }}</td>
<td>{{ $data['betrag'] }} </td>
</tr>
<tr>
<td>{{ trans('spende.frequency') }}</td>
<td>{{ trans('spende.frequency.' . $data['frequency']) }} </td>
</tr>
<tr>
<td>{{ trans('spende.danke.message') }}</td>
<td>{{ $data['nachricht'] }}</td>
</tr>
</table>
</div>
<button type="button" class="btn btn-primary noprint" onclick="window.print();">{{ trans('spende.drucken') }}</button>
</div>
<div class="col-lg-6 col-md-12 col-sm-12 others noprint" id="right">
<h2>{{ trans('about.about.1') }}</h2>
<p>{!! trans('about.about.2') !!}</p>
<p>{!! trans('about.about.3') !!}</p>
<p>{!! trans('about.about.4') !!}</p>
<p>{!! trans('about.about.5') !!}</p>
</div>
<div class="clearfix"></div>
@if($data["person"] === "private")
<div class="data-element">
<label for="firstname" style="margin-right: 16px;">{{ trans('spende.lastschrift.3f.placeholder')}}</label>
<input type="text" name="firstname" id="firstname" value="{{ $data['firstname'] }}" readonly>
</div>
<div class="data-element">
<label for="lastname" style="margin-right: 16px;">{{ trans('spende.lastschrift.3l.placeholder')}}</label>
<input type="text" name="lastname" id="lastname" value="{{ $data['lastname'] }}" readonly>
</div>
@else
<div class="data-element">
<label for="company" style="margin-right: 16px;">{{ trans('spende.lastschrift.3c.placeholder')}}</label>
<input type="text" name="company" id="company" value="{{ $data['company'] }}" readonly>
</div>
@endif
@if(!empty($data['email']))
<div class="data-element">
<label for="email" style="margin-right: 16px;">Email</label>
<input type="text" name="email" id="email" value="{{ $data['email'] }}" readonly>
</div>
@endif
<div class="data-element">
<label for="iban" style="margin-right: 16px;">{{ trans('spende.iban') }}</label>
<input type="text" name="iban" id="iban" value="{{ $data['iban'] }}" readonly>
</div>
@if(!empty($data["bic"]))
<div class="data-element">
<label for="bic" style="margin-right: 16px;">{{ trans('spende.bic') }}</label>
<input type="text" name="bic" id="bic" value="{{ $data['bic'] }}" readonly>
</div>
@endif
<div class="data-element">
<label for="betrag" style="margin-right: 16px;">{{ trans('spende.betrag') }}</label>
<input type="text" name="betrag" id="betrag" value="{{ $data['betrag'] }} €" readonly>
</div>
<div class="data-element">
<label for="frequency" style="margin-right: 16px;">{{ trans('spende.frequency') }}</label>
<input type="text" name="frequency" id="frequency" value="{{ trans('spende.frequency.' . $data['frequency']) }}" readonly>
</div>
<div class="data-element">
<label for="nachricht" style="margin-right: 16px;">{{ trans('spende.danke.message') }}</label>
<textarea name="nachricht" id="nachricht" readonly>{{ $data['nachricht'] }}</textarea>
</div>
</div>
<button type="button" style="margin-top: 16px; margin-bottom: 16px;" class="btn btn-primary noprint js-only" onclick="window.print();">{{ trans('spende.drucken') }}</button>
@if($data['key'] !== false)
<div class="card-light">
<p style="text-align: center; width:100%;">{!! trans('spende.danke.schluessel') !!}</p>
<div class="copyLink">
<input id="key" class="loadSettings" type="text" style="text-align: center;" value="{{ $data['key'] }}">
<button class="btn btn-default js-only" onclick="var copyText = document.getElementById('key');copyText.select();copyText.setSelectionRange(0, 99999);document.execCommand('copy');">Kopieren</button>
</div>
</div>
@endif
</div>
@endsection
......@@ -95,9 +95,17 @@
<h3>{!! trans('spende.headline.6') !!}</h3>
<p>{!! trans('spende.lastschrift.2') !!}</p>
<input type="hidden" name="dt" value="{{ md5(date('Y') . date('m') . date('d')) }}">
<div class="form-group donation-form-group">
<label for="Name">*{!! trans('spende.lastschrift.3') !!}</label>
<input type="text" required="required" class="form-control" id="Name" name="Name" placeholder="{!! trans('spende.lastschrift.3.placeholder') !!}" @if(isset($data['name'])) value="{{$data['name']}}" @endif />
<div id="input-picker" class="form-group donation-form-group">
<input type="radio" required="required" id="private" name="person" value="private" @if(empty($data) || $data["person"] === "private")checked="checked"@endif><label for="private">{{trans('spende.lastschrift.private')}}</label>
<div id="input-private" class="show-on-input-checked form-inline">
<input type="text" class="form-control" id="firstname" name="firstname" placeholder="{!! trans('spende.lastschrift.3f.placeholder') !!}" @if(isset($data['firstname'])) value="{{$data['firstname']}}" @endif />
<input type="text" class="form-control" id="lastname" name="lastname" placeholder="{!! trans('spende.lastschrift.3l.placeholder') !!}" @if(isset($data['lastname'])) value="{{$data['lastname']}}" @endif />
</div>
<br>
<input type="radio" id="company" name="person" value="company" @if(!empty($data) && $data["person"] === "company")checked="checked"@endif><label for="company">{{trans('spende.lastschrift.company')}}</label>
<div id="input-company" class="show-on-input-checked form-inline">
<input type="text" class="form-control" id="companyname" name="companyname" placeholder="{!! trans('spende.lastschrift.3c.placeholder') !!}" @if(isset($data['company'])) value="{{$data['company']}}" @endif />
</div>
</div>
<div class="form-group donation-form-group">
<label for="email">{!! trans('spende.lastschrift.4') !!}</label>
......
......@@ -91,6 +91,7 @@ Route::group(
return view('spende.danke')
->with('title', trans('titles.spende'))
->with('navbarFocus', 'foerdern')
->with('css', [mix('/css/spende/danke.css')])
->with('data', unserialize(base64_decode($data)));
}]);
Route::get('partnershops', function () {
......
......@@ -55,6 +55,9 @@ mix
.less("resources/less/metager/pages/count/style.less", "public/css/count/style.css", {
strictMath: true
})
.less("resources/less/metager/pages/spende/danke.less", "public/css/spende/danke.css", {
strictMath: true
})
// js
.babel(
[
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment