Skip to content
This repository was archived by the owner on Sep 28, 2019. It is now read-only.

Commit 669a723

Browse files
authored
Merge pull request #14 from avored/dev
merging dev to master
2 parents 66e5a2c + aac2e02 commit 669a723

File tree

8 files changed

+132
-15
lines changed

8 files changed

+132
-15
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"barryvdh/laravel-dompdf": "0.8.*",
2727
"laravel/passport": "5.0.*",
2828
"stripe/stripe-php": "^6.3",
29-
"avored/framework": "~1.9"
29+
"avored/framework": "~1.8"
3030
},
3131
"autoload": {
3232
"classmap": [

resources/lang/en/module.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
return [
4+
'module-list' => 'Module List',
5+
'module-upload' => 'Upload Module',
6+
'module-upload-file' => 'Upload Module File',
7+
8+
'activate' => 'Activate',
9+
'deactivate' => 'Deactivate',
10+
];
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
@extends('avored-ecommerce::layouts.app')
2+
3+
@section('content')
4+
<div class="row mt-3">
5+
6+
<div class="col-12">
7+
<div class="h1 float-left">
8+
{{ __('avored-ecommerce::module.module-list') }}
9+
</div>
10+
11+
<div class="float-right">
12+
<a href="{{ route('admin.module.create') }}"
13+
class="btn btn-primary">
14+
{{ __('avored-ecommerce::module.module-upload') }}
15+
</a>
16+
</div>
17+
</div>
18+
</div>
19+
<div class="row">
20+
@if(count($modules) <= 0)
21+
<p>Sorry No Modules Found</p>
22+
@else
23+
@foreach($modules as $module)
24+
<div class="col-3 mt-3">
25+
<div class="card">
26+
<img class="card-img-top" src="http://placehold.it/250x250" alt="Card image cap">
27+
28+
<div class="card-body">
29+
<div class="h5">{{ $module->name() }}</div>
30+
<p>{{ $module->description() }}</p>
31+
<button
32+
class="btn btn-primary" disabled>
33+
34+
@if("enabled" == strtolower($module->status()))
35+
Enabled
36+
@else
37+
Disabled
38+
@endif
39+
</button>
40+
</div>
41+
42+
</div>
43+
</div>
44+
@endforeach
45+
46+
@endif
47+
48+
</div>
49+
50+
@endsection
51+

resources/views/payment/stripe/index.blade.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
card.mount('#card-element');
7575
7676
77-
jQuery('.avored-payment-option').change(function (e) {
77+
jQuery('#stripe').bind('paymentOptionChange', function (e) {
7878
7979
if (jQuery(this).prop('id') != "stripe") {
8080
@@ -90,7 +90,7 @@
9090
});
9191
9292
jQuery('#stripe').bind('paymentProcessStart', function (e) {
93-
93+
9494
stripe.createToken(card).then(function (result) {
9595
if (result.error) {
9696
// Inform the customer that there was an error.
@@ -103,6 +103,7 @@
103103
// Send the token to your server.
104104
stripeTokenHandler(result.token);
105105
jQuery("#place-order-button").trigger('paymentProcessEnd');
106+
106107
}
107108
108109
@@ -113,11 +114,19 @@
113114
function stripeTokenHandler(token) {
114115
// Insert the token ID into the form so it gets submitted to the server
115116
var formWrapper = document.getElementById('stripe-card-form-wrapper');
117+
116118
var hiddenInput = document.createElement('input');
117119
hiddenInput.setAttribute('type', 'hidden');
118120
hiddenInput.setAttribute('name', 'stripeToken');
119121
hiddenInput.setAttribute('value', token.id);
120122
formWrapper.appendChild(hiddenInput);
123+
124+
var hiddenInput = document.createElement('input');
125+
hiddenInput.setAttribute('type', 'hidden');
126+
hiddenInput.setAttribute('name', 'payment_option');
127+
hiddenInput.setAttribute('value', 'stripe');
128+
formWrapper.appendChild(hiddenInput);
129+
121130
}
122131
123132
</script>

routes/web.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@
6666
Route::get('configuration', 'ConfigurationController@index')->name('configuration');
6767
Route::post('configuration', 'ConfigurationController@store')->name('configuration.store');
6868

69+
/** -------- Modules ROUTES -------- **/
70+
Route::get('module', 'ModuleController@index')->name('module.index');
71+
Route::get('module/create', 'ModuleController@create')->name('module.create');
72+
Route::get('module/{module}', 'ModuleController@show')->name('module.show');
73+
6974
Route::get('themes', 'ThemeController@index')->name('theme.index');
7075
Route::get('themes/create', 'ThemeController@create')->name('theme.create');
7176
Route::post('themes', 'ThemeController@store')->name('theme.store');
@@ -74,7 +79,7 @@
7479
Route::delete('themes/{name}', 'ThemeController@destroy')->name('theme.destroy');
7580

7681
//Route::resource('order-status', 'OrderStatusController');
77-
82+
7883
Route::get('order', 'OrderController@index')->name('order.index');
7984

8085
Route::post('get-property-element', 'PropertyController@getElementHtml')->name('property.element');
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace AvoRed\Ecommerce\Http\Controllers;
4+
5+
use AvoRed\Framework\Modules\Facade as Module;
6+
7+
class ModuleController extends Controller
8+
{
9+
/**
10+
* Display a listing of the modules.
11+
*
12+
* @return \Illuminate\Http\Response
13+
*/
14+
public function index()
15+
{
16+
$modules = Module::all();
17+
18+
return view('avored-ecommerce::module.index')
19+
->with('modules', $modules);
20+
}
21+
}

src/Payment/Stripe/Payment.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
use AvoRed\Framework\Models\Database\Configuration;
88
use AvoRed\Framework\Payment\Payment as PaymentEcommerce;
99
use AvoRed\Framework\Payment\Contracts\Payment as PaymentContracts;
10+
use AvoRed\Ecommerce\Models\Database\User;
1011

1112
class Payment extends PaymentEcommerce implements PaymentContracts
1213
{
13-
const CONFIG_KEY = 'payment_stripe_enabled';
14+
const CONFIG_KEY = 'payment_stripe_enabled';
1415

15-
const CONFIG_PUBLISHABLE_KEY = 'payment_stripe_publishable_key';
16+
const CONFIG_PUBLISHABLE_KEY = 'payment_stripe_publishable_key';
1617

17-
const CONFIG_SECRET_KEY = 'payment_stripe_secret_key';
18+
const CONFIG_SECRET_KEY = 'avored_stripe_secret_key';
1819
/**
1920
* Payment Option Identifier.
2021
*
@@ -80,8 +81,8 @@ public function process($orderData, $cartProducts, $request)
8081
$taxTotal = 0;
8182

8283
foreach ($cartProducts as $product) {
83-
$subTotal += $product['price'] * $product['qty'];
84-
$taxTotal += $product['tax_amount'] * $product['qty'];
84+
$subTotal += $product->price() * $product->qty();
85+
$taxTotal += $product->tax() * $product->qty();
8586
}
8687

8788
$total = (round($subTotal, 2) + round($taxTotal, 2)) * 100;
@@ -90,12 +91,22 @@ public function process($orderData, $cartProducts, $request)
9091
$apiKey = Configuration::getConfiguration(self::CONFIG_SECRET_KEY);
9192

9293
Stripe::setApiKey($apiKey);
94+
//dd($orderData);
95+
//$user = User::find($orderData['user_id']);
96+
//$customer = \Stripe\Customer::create([
97+
// 'email' => $user->email,
98+
// 'description' => 'Customer for One of Charge ' . $user->id,
99+
// 'source' => $request->get('stripeToken')
100+
// ]);
101+
102+
//dd($request->all());
103+
//dd($request->get('stripeToken'));
93104

94105
$response = Charge::create([
95106
'amount' => $totalCents,
96107
'currency' => 'nzd',
97108
'source' => $request->get('stripeToken'), // obtained with Stripe.js
98-
'description' => 'AvoRed E commerce',
109+
'description' => 'AvoRed E commerce Payment',
99110
]);
100111

101112
return $response;

src/Provider.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function registerPassportResources()
171171
*/
172172
protected function registerAdminMenu()
173173
{
174-
AdminMenuFacade::add('shop', function(AdminMenu $shopMenu) {
174+
AdminMenuFacade::add('shop', function (AdminMenu $shopMenu) {
175175
$shopMenu->label('Shop')
176176
->route('#')
177177
->icon('fas fa-cart-plus');
@@ -214,10 +214,10 @@ protected function registerAdminMenu()
214214
->icon('fas fa-dollar-sign');
215215
$shopMenu->subMenu('order', $orderMenu);
216216

217-
AdminMenuFacade::add('cms',function(AdminMenu $cmsMenu) {
217+
AdminMenuFacade::add('cms', function (AdminMenu $cmsMenu) {
218218
$cmsMenu->label('CMS')
219219
->route('#')
220-
->icon('fas fa-building');
220+
->icon('fas fa-building');
221221
});
222222

223223
$cmsMenu = AdminMenuFacade::get('cms');
@@ -235,12 +235,12 @@ protected function registerAdminMenu()
235235
->icon('fas fa-leaf');
236236
$cmsMenu->subMenu('menu', $frontMenu);
237237

238-
AdminMenuFacade::add('system', function(AdminMenu $systemMenu) {
238+
AdminMenuFacade::add('system', function (AdminMenu $systemMenu) {
239239
$systemMenu->label('System')
240240
->route('#')
241241
->icon('fas fa-cogs');
242242
});
243-
243+
244244
$systemMenu = AdminMenuFacade::get('system');
245245

246246
$configurationMenu = new AdminMenu();
@@ -277,6 +277,16 @@ protected function registerAdminMenu()
277277
->route('admin.theme.index')
278278
->icon('fas fa-adjust');
279279
$systemMenu->subMenu('themes', $themeMenu);
280+
281+
//$moduleMenu = new AdminMenu();
282+
283+
$systemMenu->subMenu('module', function (AdminMenu $moduleMenu) {
284+
//dd($moduleMenu);
285+
$moduleMenu->key('module')
286+
->label('Module')
287+
->route('admin.module.index')
288+
->icon('fas fa-adjust');
289+
});
280290
}
281291

282292
/**

0 commit comments

Comments
 (0)