Commit b668fa1b authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

fetching payment status

parent ff8d7da0
......@@ -302,6 +302,75 @@ class MailController extends Controller
}
}
public function donationPayPalCallback(Request $request){
$url = "https://www.sandbox.paypal.com/cgi-bin/webscr";
# PayPal Transaction ID
$tx = $request->input("tx", "");
$postdata = [
"cmd" => "_notify-synch",
"tx" => $tx,
"at" => config("metager.metager.paypal.pdt_token"),
"submit" => "PDT",
];
$postdata = http_build_query($postdata);
$resulthash = md5($tx);
$mission = [
"resulthash" => $resulthash,
"url" => $url,
"useragent" => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0",
"username" => null,
"password" => null,
"headers" => [
"Content-Type" => "application/x-www-form-urlencoded",
],
"cacheDuration" => 0,
"name" => "Ticket",
"curlopts" => [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postdata,
CURLOPT_LOW_SPEED_TIME => 20,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => 20
]
];
$mission = json_encode($mission);
Redis::rpush(\App\MetaGer::FETCHQUEUE_KEY, $mission);
// Fetch the result
// Verify at PayPal that the transaction was indeed SUCCESSFULL
$answer = Redis::blpop($resulthash, 20);
if(sizeof($answer) !== 2){
return ''; # TODO Redirect on failure
}else{
$answer = $answer[1];
$answer = explode("\n", $answer);
}
if($answer[0] !== "SUCCESS"){
return ''; #TODO Redirect on failure
}
# Transaction was successfull. Let's parse the details
array_splice($answer, 0, 1);
$answertmp = $answer;
$answer = [];
foreach($answertmp as $index => $element){
if(preg_match("/^([^=]+)=(.*)$/", $element, $matches) === 1){
$key = $matches[1];
$value = urldecode($matches[2]);
$answer[$key] = $value;
}
}
dd($answer);
}
#Ueberprueft ob ein bereits vorhandener Eintrag bearbeitet worden ist
public static function isEdited($k, $v, $filename)
{
......
......@@ -55,6 +55,9 @@ return [
"user" => env("WEBDRIVER_USER", ""),
"key" => env("WEBDRIVER_KEY", ""),
],
"paypal" => [
'pdt_token' => env("PAYPAL_PDT_TOKEN", ""),
],
"maps" => [
"version" => env("maps_version"),
],
......
......@@ -15,6 +15,33 @@
</div>
<div id="content-container">
@if (app('request')->input('method') == "paypal")
<form class="form" action="https://www.sandbox.paypal.com/donate" method="post" target="_top">
<div class="section">
<h3>{!! trans('spende.headline.5') !!}</h3>
<div id="payment-methods">
<a class="payment-label" href="?method=debit">{!! trans('spende.head.lastschrift') !!}</a>
<a class="payment-label" href="?method=bank-transfer">{!! trans('spende.ueberweisung') !!}</a>
<a class="payment-label payment-label-selected" href="?method=paypal">{!! trans('spende.paypal') !!}</a>
</div>
<p><br>{!! trans('spende.paypal.1') !!}</p>
<div class="center-wrapper">
@if (LaravelLocalization::getCurrentLocale() == "de")
<input type="hidden" name="lc" value="{{ Request::getPreferredLanguage([]) }}">
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="hidden" name="hosted_button_id" value="Z3Z7SRD4U2L3N" />
<input type="image" src="{{ action('Pictureproxy@get', ['url' => 'https://www.paypalobjects.com/de_DE/DE/i/btn/btn_donateCC_LG.gif']) }}" border="0" name="submit" title="PayPal - The safer, easier way to pay online!" alt="Donate with PayPal button" />
<img alt="" border="0" src="{{ action('Pictureproxy@get', ['url' => 'https://www.paypal.com/de_DE/i/scr/pixel.gif']) }}" width="1" height="1" />
@else
<input type="hidden" name="lc" value="{{ Request::getPreferredLanguage([]) }}">
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="hidden" name="hosted_button_id" value="Z3Z7SRD4U2L3N" />
<input type="image" src="{{ action('Pictureproxy@get', ['url' => 'https://www.paypalobjects.com/en_US/DK/i/btn/btn_donateCC_LG.gif']) }}" border="0" name="submit" title="PayPal - The safer, easier way to pay online!" alt="Donate with PayPal button" />
<img alt="" border="0" src="{{ action('Pictureproxy@get', ['url' => 'https://www.paypal.com/en_DE/i/scr/pixel.gif']) }}" width="1" height="1" />
@endif
</div>
</div>
</form>
<!--
<form class="form" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<div class="section">
<h3>{!! trans('spende.headline.5') !!}</h3>
......@@ -40,7 +67,7 @@
@endif
</div>
</div>
</form>
</form>-->
@elseif ((app('request')->input('method') == "bank-transfer"))
<div class="section form">
<h3>{!! trans('spende.headline.5') !!}</h3>
......
......@@ -80,20 +80,28 @@ Route::get('tor', function () {
->with('title', 'tor hidden service - MetaGer')
->with('navbarFocus', 'dienste');
});
Route::get('spende', function () {
return view('spende.spende')
->with('title', trans('titles.spende'))
->with('js', [mix('/js/donation.js')])
->with('navbarFocus', 'foerdern');
})->name("spende");
Route::get('spende/danke/{data}', function ($data) {
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)));
})->name("danke");
Route::group(['prefix' => 'spende'], function(){
Route::get('/', function () {
return view('spende.spende')
->with('title', trans('titles.spende'))
->with('js', [mix('/js/donation.js')])
->with('navbarFocus', 'foerdern');
})->name("spende");
Route::post('/', 'MailController@donation');
Route::get('paypal', 'MailController@donationPayPalCallback')->name('paypal-callback');
Route::get('danke/{data?}', function ($data) {
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)));
})->name("danke");
});
Route::get('partnershops', function () {
return view('spende.partnershops')
->with('title', trans('titles.partnershops'))
......@@ -112,7 +120,7 @@ Route::get('bform1.htm', function () {
return redirect('beitritt');
});
Route::post('spende', 'MailController@donation');
Route::get('datenschutz', function () {
return view('datenschutz/datenschutz')
......
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