-
Notifications
You must be signed in to change notification settings - Fork 3
/
server.js
67 lines (59 loc) · 2.2 KB
/
server.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
57
58
59
60
61
62
63
64
65
66
67
var auth = require('./auth');
var api = require('./order-api');
var info = require('./info-api');
module.exports = {
info:info,
api:api,
auth:auth
};
/*
var item = {
"size": {"reduced_price": 1.5, "price": 1.5, "offer_id": "", "name": "normal"},
"flavors": {"items": [], "id": "0"},
"main_item": true,
"name": "Naan ",
"tags": [],
"sub_item": false,
"quantity": 2,
"id": "1101721",
"comments": "",
"description": "gebackenes Fladenbrot"
};
info.createUser()
.then(function (data) {
auth.setToken(data.token);
api.createOrder(data.user.id, 6450)
.then(function (order) {
api.addToCart(order, item)
.then(function (order) {
console.log(order.payment.method.fast_lane);
var address = {
city: "Berlin",
email: "test@example",
lastname: "lastname",
latitude: 52.520645,
longitude: 13.409779,
name: "name",
phone: "+49 1234512345",
street_name: "street_name",
street_number: "1",
zipcode: "12345"
};
for (var key in address) {
order.delivery_address.address[key] = address[key];
}
order.payment.method.name = "paypal";
order.payment.method.id = "1";
order.payment.gateway_opts.cancel_url = "https://www.lieferheld.de/customer/checkout/" + order.id + "/";
order.payment.gateway_opts.return_url = "https://www.lieferheld.de/customer/order/" + order.id + "/?ft=";
api.checkout(order)
.then(function (order) {
console.log(order.payment.gateway);
})
.catch(function (err) {
console.log(err);
})
});
});
});
*/