From 41875b7bf131b9720cacce9ca8ec4ad7d679cae4 Mon Sep 17 00:00:00 2001 From: arzynik Date: Wed, 18 Jun 2014 16:17:17 -0700 Subject: [PATCH 1/2] partial #3350 --- .../default/cockpit2/api/order/index.php | 13 ---- .../views/default/cockpit2/bundle/js.phtml | 1 + .../frontend/restaurant-order-new.phtml | 2 +- www/assets/cockpit/js/controllers.drivers.js | 1 + .../cockpit/js/controllers.restaurants.js | 61 ++++++++++++++----- 5 files changed, 50 insertions(+), 28 deletions(-) diff --git a/include/controllers/default/cockpit2/api/order/index.php b/include/controllers/default/cockpit2/api/order/index.php index a821080df..39c1879b7 100644 --- a/include/controllers/default/cockpit2/api/order/index.php +++ b/include/controllers/default/cockpit2/api/order/index.php @@ -11,19 +11,6 @@ class Controller_api_order extends Crunchbutton_Controller_RestAccount { } - $_POST = [ - 'card' => [ - 'id' => 'CC1yW7tINe5OHE77eplt5hPs', - 'uri' => '/cards/CC1yW7tINe5OHE77eplt5hPs', - 'lastfour' => '4242', - 'card_type' => 'visa', - 'month' => '2', - 'year' => '2016' - ], - 'pay_type' => 'card', - 'delivery_type' => 'delivery', - ]; - // @todo check to see if the restaurant has the permissions for that restaurant id // $_POST['restaurant'] diff --git a/include/views/default/cockpit2/bundle/js.phtml b/include/views/default/cockpit2/bundle/js.phtml index a1b3b3c59..21d3010e2 100644 --- a/include/views/default/cockpit2/bundle/js.phtml +++ b/include/views/default/cockpit2/bundle/js.phtml @@ -25,6 +25,7 @@ + diff --git a/include/views/default/cockpit2/frontend/restaurant-order-new.phtml b/include/views/default/cockpit2/frontend/restaurant-order-new.phtml index e203aaada..a4cc5aa75 100644 --- a/include/views/default/cockpit2/frontend/restaurant-order-new.phtml +++ b/include/views/default/cockpit2/frontend/restaurant-order-new.phtml @@ -74,7 +74,7 @@
- +
  • diff --git a/www/assets/cockpit/js/controllers.drivers.js b/www/assets/cockpit/js/controllers.drivers.js index c99450e22..f2c6bfcb1 100644 --- a/www/assets/cockpit/js/controllers.drivers.js +++ b/www/assets/cockpit/js/controllers.drivers.js @@ -1,3 +1,4 @@ + NGApp.controller('DriversOrderCtrl', function ( $scope, DriverOrdersService ) { $scope.ready = false; diff --git a/www/assets/cockpit/js/controllers.restaurants.js b/www/assets/cockpit/js/controllers.restaurants.js index 7034f6f0d..07a84c904 100644 --- a/www/assets/cockpit/js/controllers.restaurants.js +++ b/www/assets/cockpit/js/controllers.restaurants.js @@ -7,28 +7,61 @@ NGApp.controller('RestaurantOrderView', function ($scope, $http, $routeParams) { NGApp.controller('RestaurantOrderNew', function ($scope, $http, MainNavigationService, AccountService) { $scope.isSubmitting = false; - $scope.order = {}; + $scope.order = { + name: 'MR TEST', + pay_type: 'card', + delivery_type: 'delivery' + }; + $scope.card = { + number: '4111111111111111', + month: '1', + year: '2015' + }; + + App.config.processor = { + type: 'balanced' + }; $scope.submit = function() { $scope.isSubmitting = true; $scope.order.restaurant = AccountService.restaurant; + + App.tokenizeCard({ + name: $scope.order.name, + number: $scope.card.number, + expiration_month: $scope.card.month, + expiration_year: $scope.card.year, + security_code: null - $http({ - method: 'POST', - url: '/api/order', - data: $scope.order, - headers: {'Content-Type': 'application/x-www-form-urlencoded'} - }).success(function(data) { - console.debug(data); - - $scope.isSubmitting = false; - if (data.id_order) { - MainNavigationService.link('/restaurant/order/' + data.id_order); - } else { - alert(data.errors); + }, function(status) { + if (!status.status) { + alert(status.error); } + $scope.isSubmitting = false; + console.debug(status); + + $scope.order.card = status; + + $http({ + method: 'POST', + url: '/api/order', + data: $scope.order, + headers: {'Content-Type': 'application/x-www-form-urlencoded'} + }).success(function(data) { + console.debug(data); + + $scope.isSubmitting = false; + if (data.id_order) { + MainNavigationService.link('/restaurant/order/' + data.id_order); + } else { + alert(data.errors); + } + }); + }); + + } $scope.card = {}; From a0cadadc882c72bc8f035357b22fb8a47a13e644 Mon Sep 17 00:00:00 2001 From: arzynik Date: Wed, 18 Jun 2014 16:42:20 -0700 Subject: [PATCH 2/2] updates --- .../cockpit2/frontend/restaurant-order-new.phtml | 15 +++++++++++++-- www/assets/cockpit/js/controllers.restaurants.js | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/views/default/cockpit2/frontend/restaurant-order-new.phtml b/include/views/default/cockpit2/frontend/restaurant-order-new.phtml index a4cc5aa75..de19c3e0e 100644 --- a/include/views/default/cockpit2/frontend/restaurant-order-new.phtml +++ b/include/views/default/cockpit2/frontend/restaurant-order-new.phtml @@ -59,8 +59,19 @@ -
  • +
    Payment Type
    +
    + + +
    +
  • + + +
  • Card Number
    @@ -69,7 +80,7 @@ -
  • +
  • Card Expiration
    diff --git a/www/assets/cockpit/js/controllers.restaurants.js b/www/assets/cockpit/js/controllers.restaurants.js index 07a84c904..e63d71f46 100644 --- a/www/assets/cockpit/js/controllers.restaurants.js +++ b/www/assets/cockpit/js/controllers.restaurants.js @@ -17,7 +17,7 @@ NGApp.controller('RestaurantOrderNew', function ($scope, $http, MainNavigationSe month: '1', year: '2015' }; - + App.config.processor = { type: 'balanced' };