Skip to content

Commit 1236c85

Browse files
committed
Project commit
0 parents  commit 1236c85

File tree

437 files changed

+102669
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

437 files changed

+102669
-0
lines changed

.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2

.env.example

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
APP_NAME=SonicPayments
2+
APP_ENV=local
3+
APP_KEY=base64:Yomi6Ozdkw+olcqoKJ02BDeGdnIJWNesWOqRfuRKZvE=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost
6+
7+
LOG_CHANNEL=stack
8+
LOG_LEVEL=debug
9+
10+
DB_CONNECTION=mysql
11+
DB_HOST=127.0.0.1
12+
DB_PORT=3306
13+
DB_DATABASE=
14+
DB_USERNAME=root
15+
DB_PASSWORD=
16+
17+
BROADCAST_DRIVER=log
18+
CACHE_DRIVER=file
19+
QUEUE_CONNECTION=sync
20+
SESSION_DRIVER=file
21+
SESSION_LIFETIME=120
22+
23+
REDIS_HOST=127.0.0.1
24+
REDIS_PASSWORD=null
25+
REDIS_PORT=6379
26+
27+
MAIL_MAILER=smtp
28+
MAIL_HOST=smtp.mailtrap.io
29+
MAIL_PORT=2525
30+
MAIL_USERNAME=null
31+
MAIL_PASSWORD=null
32+
MAIL_ENCRYPTION=null
33+
MAIL_FROM_ADDRESS=null
34+
MAIL_FROM_NAME="${APP_NAME}"
35+
36+
AWS_ACCESS_KEY_ID=
37+
AWS_SECRET_ACCESS_KEY=
38+
AWS_DEFAULT_REGION=us-east-1
39+
AWS_BUCKET=
40+
41+
PUSHER_APP_ID=
42+
PUSHER_APP_KEY=
43+
PUSHER_APP_SECRET=
44+
PUSHER_APP_CLUSTER=mt1
45+
46+
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
47+
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.gitattributes

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* text=auto
2+
*.css linguist-vendored
3+
*.scss linguist-vendored
4+
*.js linguist-vendored
5+
CHANGELOG.md export-ignore

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/node_modules
2+
/public/hot
3+
/public/storage
4+
/storage/*.key
5+
/vendor
6+
.env
7+
.env.backup
8+
.phpunit.result.cache
9+
Homestead.json
10+
Homestead.yaml
11+
npm-debug.log
12+
yarn-error.log

.htaccess

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<IfModule mod_rewrite.c>
2+
<IfModule mod_negotiation.c>
3+
Options -MultiViews
4+
</IfModule>
5+
6+
RewriteEngine On
7+
8+
RewriteCond %{REQUEST_FILENAME} -d [OR]
9+
RewriteCond %{REQUEST_FILENAME} -f
10+
RewriteRule ^ ^$1 [N]
11+
12+
RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
13+
RewriteRule ^(.*)$ public/$1
14+
15+
RewriteCond %{REQUEST_FILENAME} !-d
16+
RewriteCond %{REQUEST_FILENAME} !-f
17+
RewriteRule ^ server.php
18+
</IfModule>
19+
20+
<Files .env>
21+
order allow,deny
22+
Deny from all
23+
</Files>

.styleci.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
php:
2+
preset: laravel
3+
disabled:
4+
- no_unused_imports
5+
finder:
6+
not-name:
7+
- index.php
8+
- server.php
9+
js:
10+
finder:
11+
not-name:
12+
- webpack.mix.js
13+
css: true

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Starter package for the Laravel Payment Integration online course.
2+
3+
Laravel
4+
5+
## License
6+
7+
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
8+
# laravelpaymentstarter

app/Console/Kernel.php

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace App\Console;
4+
5+
use Illuminate\Console\Scheduling\Schedule;
6+
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
7+
8+
class Kernel extends ConsoleKernel
9+
{
10+
/**
11+
* The Artisan commands provided by your application.
12+
*
13+
* @var array
14+
*/
15+
protected $commands = [
16+
//
17+
];
18+
19+
/**
20+
* Define the application's command schedule.
21+
*
22+
* @param \Illuminate\Console\Scheduling\Schedule $schedule
23+
* @return void
24+
*/
25+
protected function schedule(Schedule $schedule)
26+
{
27+
// $schedule->command('inspire')->hourly();
28+
}
29+
30+
/**
31+
* Register the commands for the application.
32+
*
33+
* @return void
34+
*/
35+
protected function commands()
36+
{
37+
$this->load(__DIR__.'/Commands');
38+
39+
require base_path('routes/console.php');
40+
}
41+
}

app/Exceptions/Handler.php

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace App\Exceptions;
4+
5+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
6+
use Throwable;
7+
8+
class Handler extends ExceptionHandler
9+
{
10+
/**
11+
* A list of the exception types that are not reported.
12+
*
13+
* @var array
14+
*/
15+
protected $dontReport = [
16+
//
17+
];
18+
19+
/**
20+
* A list of the inputs that are never flashed for validation exceptions.
21+
*
22+
* @var array
23+
*/
24+
protected $dontFlash = [
25+
'password',
26+
'password_confirmation',
27+
];
28+
29+
/**
30+
* Register the exception handling callbacks for the application.
31+
*
32+
* @return void
33+
*/
34+
public function register()
35+
{
36+
$this->reportable(function (Throwable $e) {
37+
//
38+
});
39+
}
40+
}

app/Helpers/AmountConverterHelper.php

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace App\Helpers;
4+
5+
use DB;
6+
7+
class AmountConverterHelper
8+
{
9+
public static function getStripeAmountBasedOnCurrency($currency, $amount)
10+
{
11+
// https://stripe.com/docs/currencies#:~:text=Stripe%20supports%20processing%20payments%20in,native%20currency%20can%20increase%20sales.
12+
$zeroDecimalCurrencies = array('BIF' => 1, 'CLP' => 1, 'DJF' => 1, 'GNF' => 1, 'JPY' => 1,
13+
'KMF' => 1, 'KRW' => 1, 'MGA' => 1, 'PYG' => 1, 'RWF' => 1,
14+
'VND' => 1, 'VUV' => 1, 'XAF' => 1, 'XOF' => 1, 'XPF' => 1);
15+
16+
if( array_key_exists($currency, $zeroDecimalCurrencies) )
17+
{
18+
return intval($amount);
19+
}
20+
else
21+
{
22+
return ($amount * 100);
23+
}
24+
}
25+
26+
public static function getBraintreeAmountBasedOnCurrency($amount)
27+
{
28+
$settings = DB::table('settings')->first();
29+
30+
$currency = $settings->currency;
31+
// https://developers.braintreepayments.com/reference/general/currencies
32+
$zeroDecimalCurrencies = array('BIF' => 1, 'CLP' => 1, 'DJF' => 1, 'GNF' => 1, 'JPY' => 1,
33+
'KMF' => 1, 'KRW' => 1, 'LAO' => 1, 'PYG' => 1, 'RWF' => 1,
34+
'UGX' => 1, 'VND' => 1, 'VUV' => 1, 'XAF' => 1, 'XOF' => 1,
35+
'XPF' => 1);
36+
37+
if( array_key_exists($currency, $zeroDecimalCurrencies) )
38+
{
39+
return intval($amount);
40+
}
41+
else
42+
{
43+
return $amount;
44+
}
45+
}
46+
}

app/Helpers/CurrencyHelper.php

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?php
2+
3+
namespace App\Helpers;
4+
5+
use App\Models\Setting\Setting;
6+
use App\Models\Checkout\Currency;
7+
8+
class CurrencyHelper
9+
{
10+
public static function getSetPriceFormat($priceWithTwoDecimals)
11+
{
12+
$settings = Setting::first();
13+
$isCommaTheDecimalSeparator = $settings->comma_is_decimal_separator;
14+
$isIntegerPriceUsed = $settings->use_integer_prices;
15+
16+
$priceStringToReturn = $priceWithTwoDecimals;
17+
if( ($isIntegerPriceUsed) && ($priceWithTwoDecimals < 1000) )
18+
{
19+
return intval($priceStringToReturn);
20+
}
21+
22+
if( (!$isIntegerPriceUsed) && ($priceWithTwoDecimals < 1000) )
23+
{
24+
$priceString = strval($priceWithTwoDecimals);
25+
if($isCommaTheDecimalSeparator)
26+
{
27+
return str_replace('.', ',', $priceString);
28+
}
29+
else
30+
{
31+
return $priceStringToReturn;
32+
}
33+
}
34+
35+
if( ($isIntegerPriceUsed) && ($priceWithTwoDecimals >= 1000) )
36+
{
37+
$priceString = strval(intval($priceStringToReturn));
38+
if($isCommaTheDecimalSeparator)
39+
{
40+
return number_format($priceString, null, null, '.');
41+
}
42+
else
43+
{
44+
return number_format($priceString, null, null, ',');
45+
}
46+
}
47+
48+
if( (!$isIntegerPriceUsed) && ($priceWithTwoDecimals >= 1000) )
49+
{
50+
$priceStringWithTwoDecimals = strval($priceWithTwoDecimals);
51+
$positionOfPeriod = strpos($priceStringWithTwoDecimals, '.');
52+
$priceStringInt = substr($priceStringWithTwoDecimals, 0, $positionOfPeriod);
53+
$decimalsString = substr($priceStringWithTwoDecimals, $positionOfPeriod + 1);
54+
55+
if($isCommaTheDecimalSeparator)
56+
{
57+
$separatedPriceInt = number_format($priceStringInt, null, null, '.');
58+
return $separatedPriceInt . ',' . $decimalsString;
59+
}
60+
else
61+
{
62+
$separatedPriceInt = number_format($priceStringInt, null, null, ',');
63+
return $separatedPriceInt . '.' . $decimalsString;
64+
}
65+
}
66+
67+
return $priceStringToReturn;
68+
}
69+
70+
public static function getCurrencyString()
71+
{
72+
$settings = Setting::first();
73+
$currencyText = $settings->currency;
74+
$adjustedCurrencyText = $currencyText . ' ';
75+
if( $settings->use_currency_symbol == 1 )
76+
{
77+
if( $currencyText == 'USD' || $currencyText == 'EUR' || $currencyText == 'GBP' )
78+
{
79+
$currencyData = Currency::where('name', $currencyText)->first();
80+
if( !is_null($currencyData) )
81+
{
82+
$adjustedCurrencyText = $currencyData->symbol;
83+
}
84+
}
85+
}
86+
87+
return $adjustedCurrencyText;
88+
}
89+
}

app/Helpers/OrderDataHelper.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace App\Helpers;
4+
5+
class OrderDataHelper
6+
{
7+
public static function getOrderData(&$dataArray, &$requestObj, &$authUser, $courseTitle, $transactionId)
8+
{
9+
$dataArray["user_id"] = $authUser->id;
10+
$dataArray["customer_name"] = $requestObj->first_name . " " . $requestObj->last_name;
11+
$dataArray["user_email"] = $authUser->email;
12+
$dataArray["price"] = $requestObj->total;
13+
$dataArray["purchased_course_id"] = $requestObj->course;
14+
$dataArray["purchased_course_title"] = $courseTitle;
15+
$dataArray["transaction_id"] = $transactionId;
16+
$dataArray["customer_street"] = $requestObj->street;
17+
$dataArray["customer_city"] = $requestObj->city;
18+
$dataArray["customer_zip"] = $requestObj->zip;
19+
$dataArray["customer_country"] = $requestObj->country;
20+
$dataArray["customer_apartment"] = $requestObj->apartment;
21+
$dataArray["customer_state"] = $requestObj->state;
22+
$dataArray["customer_phone"] = $requestObj->phone;
23+
}
24+
}

0 commit comments

Comments
 (0)