Skip to content

Commit

Permalink
cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
gheorghelupu17 committed Jun 22, 2023
1 parent f9566a6 commit 55611d4
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 28 deletions.
5 changes: 2 additions & 3 deletions app/Http/Controllers/Auth/RegisteredUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@
use App\Models\User;
use App\Notifications\Admin\OrganizationCreated as OrganizationCreatedAdmin;
use App\Notifications\Ngo\OrganizationCreated;
use App\Providers\RouteServiceProvider;
use Illuminate\Auth\Events\Registered;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Redirect;
use Inertia\Inertia;
use Inertia\Response;
use Illuminate\Support\Facades\Redirect;

class RegisteredUserController extends Controller
{
Expand Down Expand Up @@ -75,11 +74,11 @@ public function store(RegistrationRequest $request): RedirectResponse
$user->organization_id = $organization->id;
$user->save();
}

return Redirect::route('register');
}

public function update(RegistrationRequest $request): RedirectResponse
{

}
}
1 change: 1 addition & 0 deletions app/Http/Controllers/DonationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function makeDonation(Donation $donation)
{
$service = new EuPlatescService($donation->organization_id);
$data = $service->getPaymentData($donation);

return Inertia::render('Public/Donor/Donor', [
'data' => $data,
]);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/OrganizationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function index(Request $request)
/* Apply the active scope. */
$query->status(OrganizationStatus::active);

/** Extract existing organizations cities with county. */
/* Extract existing organizations cities with county. */
/* Return inertia page. */
return Inertia::render('Public/Organizations/Organizations', [
'activity_domains' => ActivityDomain::all(),
Expand Down
5 changes: 3 additions & 2 deletions app/Http/Controllers/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function item(Project $project)
'project' => $project,
]);
}

public function donation(Project $project, Request $request)
{
$request->validate([
Expand All @@ -40,8 +41,8 @@ public function donation(Project $project, Request $request)
]);
try {
[$lastName, $firstName] = explode(' ', $request->name);
}catch (\Exception $e){
throw ValidationException::withMessages(['name' => __('invalid_name')]);
} catch (\Exception $e) {
throw ValidationException::withMessages(['name' => __('invalid_name')]);
}

$donation = $project->donations()->create([
Expand Down
1 change: 1 addition & 0 deletions app/Models/Donation.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Donation extends Model
'updated_without_correct_e_pid',
];
use HasFactory;

public function project(): BelongsTo
{
return $this->belongsTo(Project::class);
Expand Down
1 change: 0 additions & 1 deletion app/Models/Organization.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Collection;

class Organization extends Model
{
Expand Down
2 changes: 0 additions & 2 deletions app/Models/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ public function getIsPeriodActiveAttribute(): bool
return $this->start <= now() && $this->end >= now();
}



public function counties(): BelongsToMany
{
return $this->belongsToMany(County::class);
Expand Down
1 change: 1 addition & 0 deletions app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class RouteServiceProvider extends ServiceProvider
* @var string
*/
public const HOME = '/dashboard';

public const ONG = '/ong/organizatie';

/**
Expand Down
27 changes: 15 additions & 12 deletions app/Services/EuPlatescService.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Services;

use App\Models\Donation;
Expand All @@ -8,13 +10,15 @@
class EuPlatescService
{
private string $merchantId;

private string $privateKey;

private bool $testMode;

private string $url;

public function __construct($organizationId)
{

$organization = Organization::findOrFail($organizationId);
$this->merchantId = $organization->eu_platesc_merchant_id;
$this->privateKey = $organization->eu_platesc_private_key;
Expand All @@ -39,26 +43,25 @@ public function getPaymentData(Donation $donation): array
$data['fp_hash'] = $this->euPlatescHash($data);
$data['fname'] = $donation->first_name;
$data['lname'] = $donation->last_name;
$data['ExtraData[silenturl]']= route('donation.callback',$donation->uuid);
$data['ExtraData[successurl]']= route('donation.thanks',$donation->uuid);
$data['ExtraData[backtosite]']= route('project',$donation->project->slug);
$data['ExtraData[silenturl]'] = route('donation.callback', $donation->uuid);
$data['ExtraData[successurl]'] = route('donation.thanks', $donation->uuid);
$data['ExtraData[backtosite]'] = route('project', $donation->project->slug);
$data['payment_url'] = $this->url;

return $data;
}

private function euPlatescHash($data): string
{
$str = NULL;
foreach($data as $d){
if($d === NULL || strlen($d) == 0){
$str = null;
foreach ($data as $d) {
if ($d === null || \strlen($d) == 0) {
$str .= '-';
}else{
$str .= strlen($d) . $d;
} else {
$str .= \strlen($d) . $d;
}
}
return hash_hmac('MD5',$str, pack('H*', $this->privateKey));
}


return hash_hmac('MD5', $str, pack('H*', $this->privateKey));
}
}
5 changes: 2 additions & 3 deletions config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
'eu_platesc' =>
[
'eu_platesc' => [
'test_mode' => env('EU_PLATESC_TEST_MODE', true),
'url' => env('EU_PLATESC_URL', 'https://secure.euplatesc.ro/tdsprocess/tranzactd.php'),
'merchant_id' => env('EU_PLATESC_MERCHANT_ID', ''),
'private_key' => env('EU_PLATESC_PRIVATE_KEY', ''),
]
],

];
2 changes: 1 addition & 1 deletion database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function run(): void
}

for ($i = 0; $i < self::USER_NGO_ADMIN_NUMBER; $i++) {
$organization = Organization::factory(['eu_platesc_merchant_id'=>config('services.eu_platesc.merchant_id'),'eu_platesc_private_key'=>config('services.eu_platesc.private_key')])->create();
$organization = Organization::factory(['eu_platesc_merchant_id'=>config('services.eu_platesc.merchant_id'), 'eu_platesc_private_key'=>config('services.eu_platesc.private_key')])->create();
if ($i === 0) {
User::factory(['email' => '[email protected]'])->ngoAdmin()->for($organization)->create();
} else {
Expand Down
6 changes: 3 additions & 3 deletions routes/donations.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
use Inertia\Inertia;

/* Public routes. */
Route::get('/doneaza/{donation:uuid}', [\App\Http\Controllers\DonationController::class,'makeDonation'])->name('donation.make');
Route::get('/doneaza/callbacks/{uuid}', [\App\Http\Controllers\DonationController::class,'makeDonation'])->name('donation.callback');
Route::post('/doneaza/thanks/{uuid}', [\App\Http\Controllers\DonationController::class,'thankYou'])->name('donation.thanks');
Route::get('/doneaza/{donation:uuid}', [\App\Http\Controllers\DonationController::class, 'makeDonation'])->name('donation.make');
Route::get('/doneaza/callbacks/{uuid}', [\App\Http\Controllers\DonationController::class, 'makeDonation'])->name('donation.callback');
Route::post('/doneaza/thanks/{uuid}', [\App\Http\Controllers\DonationController::class, 'thankYou'])->name('donation.thanks');
/* Tichets routes. */
Route::prefix('ong')->middleware('auth')->group(function () {
Route::get('/donatii', function () {
Expand Down

0 comments on commit 55611d4

Please sign in to comment.