Merge branch 'Settlement' of https://github.com/crunchbutton/crunchbutton into Settlement
This commit is contained in:
commit
9fb16683cd
@ -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']
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
|
||||
<script src="/assets/js/base.js?v=<?=Cana_Util::gitVersion()?>"></script>
|
||||
<script src="/assets/js/util.js?v=<?=Cana_Util::gitVersion()?>"></script>
|
||||
<script src="/assets/js/tokenizeCard.js?v=<?=Cana_Util::gitVersion()?>"></script>
|
||||
|
||||
<!-- AngularJS Controllers -->
|
||||
<script src="/assets/cockpit/js/controllers.js?v=<?=Cana_Util::gitVersion()?>"></script>
|
||||
|
||||
@ -59,8 +59,19 @@
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li class="li-input" ng-class="{'error':form.driverName.$invalid}">
|
||||
<div class="label">Payment Type</div>
|
||||
<div class="input">
|
||||
|
||||
<select ng-model="order.pay_type">
|
||||
<option value="card">Card</option>
|
||||
<option value="cash">Cash</option>
|
||||
</select>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
<li class="li-input" ng-class="{'error':form.driverName.$invalid}" ng-show="order.pay_type=='card'">
|
||||
<div class="label">Card Number</div>
|
||||
<div class="input">
|
||||
<input type="text" name="name" ng-model="card.number" required="" placeholder="0000-0000-0000-0000" ng-minlength="5" ng-maxlength="80" class="ng-pristine ng-valid-maxlength ng-valid-minlength ng-valid ng-valid-required">
|
||||
@ -69,12 +80,12 @@
|
||||
|
||||
|
||||
|
||||
<li class="li-input" ng-class="{'error':form.driverName.$invalid}">
|
||||
<li class="li-input" ng-class="{'error':form.driverName.$invalid}" ng-show="order.pay_type=='card'">
|
||||
<div class="label">Card Expiration</div>
|
||||
<div class="input">
|
||||
|
||||
<select ng-model="card.month" ng-options="month.value as month.label for month in card._months()" class=""></select>
|
||||
<select ng-model="order.year" ng-options="year.value as year.label for year in card._years()" class=""></select>
|
||||
<select ng-model="card.year" ng-options="year.value as year.label for year in card._years()" class=""></select>
|
||||
</div>
|
||||
</li>
|
||||
<li class="li-input" ng-show="!isSubmitting"><button class="button orange" ng-click="submit();">Submit New Order</button></li>
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
NGApp.controller('DriversOrderCtrl', function ( $scope, DriverOrdersService ) {
|
||||
|
||||
$scope.ready = false;
|
||||
|
||||
@ -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 = {};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user