-
Notifications
You must be signed in to change notification settings - Fork 235
/
Copy pathngCart.fulfilment.js
56 lines (35 loc) · 1.28 KB
/
ngCart.fulfilment.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
angular.module('ngCart.fulfilment', [])
.service('fulfilmentProvider', ['$injector', function($injector){
this._obj = {
service : undefined,
settings : undefined
};
this.setService = function(service){
this._obj.service = service;
};
this.setSettings = function(settings){
this._obj.settings = settings;
};
this.checkout = function(){
var provider = $injector.get('ngCart.fulfilment.' + this._obj.service);
return provider.checkout(this._obj.settings);
}
}])
.service('ngCart.fulfilment.log', ['$q', '$log', 'ngCart', function($q, $log, ngCart){
this.checkout = function(){
var deferred = $q.defer();
$log.info(ngCart.toObject());
deferred.resolve({
cart:ngCart.toObject()
});
return deferred.promise;
}
}])
.service('ngCart.fulfilment.http', ['$http', 'ngCart', function($http, ngCart){
this.checkout = function(settings){
return $http.post(settings.url,
{ data: ngCart.toObject(), options: settings.options});
}
}])
.service('ngCart.fulfilment.paypal', ['$http', 'ngCart', function($http, ngCart){
}]);