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 499e0c41b..c0ed02424 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..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,12 +80,12 @@ -
  • +
  • Card Expiration
    - +
  • diff --git a/www/assets/cockpit/js/controllers.drivers.js b/www/assets/cockpit/js/controllers.drivers.js index 2991fc155..9b4d908ff 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..e63d71f46 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 = {};