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

Commit

Permalink
Merge pull request #14 from avored/dev
Browse files Browse the repository at this point in the history
merging dev to master
  • Loading branch information
indpurvesh authored Jul 7, 2018
2 parents 66e5a2c + aac2e02 commit 669a723
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 15 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"barryvdh/laravel-dompdf": "0.8.*",
"laravel/passport": "5.0.*",
"stripe/stripe-php": "^6.3",
"avored/framework": "~1.9"
"avored/framework": "~1.8"
},
"autoload": {
"classmap": [
Expand Down
10 changes: 10 additions & 0 deletions resources/lang/en/module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

return [
'module-list' => 'Module List',
'module-upload' => 'Upload Module',
'module-upload-file' => 'Upload Module File',

'activate' => 'Activate',
'deactivate' => 'Deactivate',
];
51 changes: 51 additions & 0 deletions resources/views/module/index.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
@extends('avored-ecommerce::layouts.app')

@section('content')
<div class="row mt-3">

<div class="col-12">
<div class="h1 float-left">
{{ __('avored-ecommerce::module.module-list') }}
</div>

<div class="float-right">
<a href="{{ route('admin.module.create') }}"
class="btn btn-primary">
{{ __('avored-ecommerce::module.module-upload') }}
</a>
</div>
</div>
</div>
<div class="row">
@if(count($modules) <= 0)
<p>Sorry No Modules Found</p>
@else
@foreach($modules as $module)
<div class="col-3 mt-3">
<div class="card">
<img class="card-img-top" src="http://placehold.it/250x250" alt="Card image cap">

<div class="card-body">
<div class="h5">{{ $module->name() }}</div>
<p>{{ $module->description() }}</p>
<button
class="btn btn-primary" disabled>

@if("enabled" == strtolower($module->status()))
Enabled
@else
Disabled
@endif
</button>
</div>

</div>
</div>
@endforeach

@endif

</div>

@endsection

13 changes: 11 additions & 2 deletions resources/views/payment/stripe/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
card.mount('#card-element');
jQuery('.avored-payment-option').change(function (e) {
jQuery('#stripe').bind('paymentOptionChange', function (e) {
if (jQuery(this).prop('id') != "stripe") {
Expand All @@ -90,7 +90,7 @@
});
jQuery('#stripe').bind('paymentProcessStart', function (e) {
stripe.createToken(card).then(function (result) {
if (result.error) {
// Inform the customer that there was an error.
Expand All @@ -103,6 +103,7 @@
// Send the token to your server.
stripeTokenHandler(result.token);
jQuery("#place-order-button").trigger('paymentProcessEnd');
}
Expand All @@ -113,11 +114,19 @@
function stripeTokenHandler(token) {
// Insert the token ID into the form so it gets submitted to the server
var formWrapper = document.getElementById('stripe-card-form-wrapper');
var hiddenInput = document.createElement('input');
hiddenInput.setAttribute('type', 'hidden');
hiddenInput.setAttribute('name', 'stripeToken');
hiddenInput.setAttribute('value', token.id);
formWrapper.appendChild(hiddenInput);
var hiddenInput = document.createElement('input');
hiddenInput.setAttribute('type', 'hidden');
hiddenInput.setAttribute('name', 'payment_option');
hiddenInput.setAttribute('value', 'stripe');
formWrapper.appendChild(hiddenInput);
}
</script>
Expand Down
7 changes: 6 additions & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
Route::get('configuration', 'ConfigurationController@index')->name('configuration');
Route::post('configuration', 'ConfigurationController@store')->name('configuration.store');

/** -------- Modules ROUTES -------- **/
Route::get('module', 'ModuleController@index')->name('module.index');
Route::get('module/create', 'ModuleController@create')->name('module.create');
Route::get('module/{module}', 'ModuleController@show')->name('module.show');

Route::get('themes', 'ThemeController@index')->name('theme.index');
Route::get('themes/create', 'ThemeController@create')->name('theme.create');
Route::post('themes', 'ThemeController@store')->name('theme.store');
Expand All @@ -74,7 +79,7 @@
Route::delete('themes/{name}', 'ThemeController@destroy')->name('theme.destroy');

//Route::resource('order-status', 'OrderStatusController');

Route::get('order', 'OrderController@index')->name('order.index');

Route::post('get-property-element', 'PropertyController@getElementHtml')->name('property.element');
Expand Down
21 changes: 21 additions & 0 deletions src/Http/Controllers/ModuleController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace AvoRed\Ecommerce\Http\Controllers;

use AvoRed\Framework\Modules\Facade as Module;

class ModuleController extends Controller
{
/**
* Display a listing of the modules.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$modules = Module::all();

return view('avored-ecommerce::module.index')
->with('modules', $modules);
}
}
23 changes: 17 additions & 6 deletions src/Payment/Stripe/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
use AvoRed\Framework\Models\Database\Configuration;
use AvoRed\Framework\Payment\Payment as PaymentEcommerce;
use AvoRed\Framework\Payment\Contracts\Payment as PaymentContracts;
use AvoRed\Ecommerce\Models\Database\User;

class Payment extends PaymentEcommerce implements PaymentContracts
{
const CONFIG_KEY = 'payment_stripe_enabled';
const CONFIG_KEY = 'payment_stripe_enabled';

const CONFIG_PUBLISHABLE_KEY = 'payment_stripe_publishable_key';
const CONFIG_PUBLISHABLE_KEY = 'payment_stripe_publishable_key';

const CONFIG_SECRET_KEY = 'payment_stripe_secret_key';
const CONFIG_SECRET_KEY = 'avored_stripe_secret_key';
/**
* Payment Option Identifier.
*
Expand Down Expand Up @@ -80,8 +81,8 @@ public function process($orderData, $cartProducts, $request)
$taxTotal = 0;

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

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

Stripe::setApiKey($apiKey);
//dd($orderData);
//$user = User::find($orderData['user_id']);
//$customer = \Stripe\Customer::create([
// 'email' => $user->email,
// 'description' => 'Customer for One of Charge ' . $user->id,
// 'source' => $request->get('stripeToken')
// ]);

//dd($request->all());
//dd($request->get('stripeToken'));

$response = Charge::create([
'amount' => $totalCents,
'currency' => 'nzd',
'source' => $request->get('stripeToken'), // obtained with Stripe.js
'description' => 'AvoRed E commerce',
'description' => 'AvoRed E commerce Payment',
]);

return $response;
Expand Down
20 changes: 15 additions & 5 deletions src/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function registerPassportResources()
*/
protected function registerAdminMenu()
{
AdminMenuFacade::add('shop', function(AdminMenu $shopMenu) {
AdminMenuFacade::add('shop', function (AdminMenu $shopMenu) {
$shopMenu->label('Shop')
->route('#')
->icon('fas fa-cart-plus');
Expand Down Expand Up @@ -214,10 +214,10 @@ protected function registerAdminMenu()
->icon('fas fa-dollar-sign');
$shopMenu->subMenu('order', $orderMenu);

AdminMenuFacade::add('cms',function(AdminMenu $cmsMenu) {
AdminMenuFacade::add('cms', function (AdminMenu $cmsMenu) {
$cmsMenu->label('CMS')
->route('#')
->icon('fas fa-building');
->icon('fas fa-building');
});

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

AdminMenuFacade::add('system', function(AdminMenu $systemMenu) {
AdminMenuFacade::add('system', function (AdminMenu $systemMenu) {
$systemMenu->label('System')
->route('#')
->icon('fas fa-cogs');
});

$systemMenu = AdminMenuFacade::get('system');

$configurationMenu = new AdminMenu();
Expand Down Expand Up @@ -277,6 +277,16 @@ protected function registerAdminMenu()
->route('admin.theme.index')
->icon('fas fa-adjust');
$systemMenu->subMenu('themes', $themeMenu);

//$moduleMenu = new AdminMenu();

$systemMenu->subMenu('module', function (AdminMenu $moduleMenu) {
//dd($moduleMenu);
$moduleMenu->key('module')
->label('Module')
->route('admin.module.index')
->icon('fas fa-adjust');
});
}

/**
Expand Down

0 comments on commit 669a723

Please sign in to comment.