-
Notifications
You must be signed in to change notification settings - Fork 24
Onlineweb payme nibble
Payment system for the Online office.
User beeps their card. A tablet displays a webpage with user info and saldo and allows the user to perform an operation(Select product, Add money, subtract money, undo previous operation)
Integration in Onlineweb for adding money using Stripe.
- Adding and subtracting money
- Undo / revert transaction
- Keep stock
- Buying products
- Possibility for users to add money using Stripe
- Adding/Setting RFID (Might have to be done in Onlineweb as it should be authenticated)
- Notify trikom when supply is running low
- Name
- Name
- Price
- Description
- Amount
- Available (If the product should be displayed to the user)
- Product Category
- User
- Money diff (minus for subtraction, plus for addition) (Optional)
- Product (Optional)
- Timestamp
- Add saldo field
- Add/remove/edit products in the admin panel/dashboard
- Tab in my profile where the user can see transaction history, saldo and add money to their saldo using Stripe.
- Rest API
Use the client_id and client_secret to get an access_token that lasts for 1 hour.
var getToken = function(){
$.ajax({
type: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
url: "http://localhost:8001/sso/o/token/",
data: {
"grant_type":"client_credentials",
"client_id":"24Qy0p75pY4usMHKPQdJJYYoO9zigEU1RkCTibZU",
"client_secret":"BVarpTofBtIqiO0QJksgbueHx3tERuGCgxJRs8i2zABPDLVzrEp2tY7lv5jD0Zk8jKqR3oeKhi5N5gN2lNlITjBkizZSNgeSlqETwyhCFSnTYVLpacLFka4gyu9HdCjd",
},
dataType: "json",
success: function(data) {
console.log(data.access_token);
},
error: function(msg) {
console.log(msg);
}
});
}
This token will be used to perform actions on the other endpoints.
If a call returns 401 UNAUTHORIZED a new access_token is needed.
A users RFID can be used to retrieve the users ID, name and saldo.
var getUserSaldo = function(rfid){
$.ajax({
url: "http://localhost:8001/api/v1/usersaldo/?format=json&rfid=" + rfid,
type: 'GET',
beforeSend: function (xhr) {
xhr.setRequestHeader('Authorization', 'Bearer <access_token>');
},
data: {},
success: function (data) { console.log(data.results)},
error: function (msg) { console.log(msg)},
});
}
returns:
{"pk", "first_name", "last_name", "saldo"}
If the RFID does not exists an emtpy list is returned.
If the RFID is new it can be connected to a user using user credentials.
Note! This will replace old RFIDs connected to the user.
var setRFID = function(username, password, rfid){
$.ajax({
url: "http://localhost:8001/shop/rfid/",
type: 'POST',
beforeSend: function (xhr) {
xhr.setRequestHeader('Authorization', 'Bearer ' + access_token);
},
data: {
'username': username,
'password': password,
'rfid': rfid,
},
success: function (data) { console.log(data)},
error: function (msg) { console.log(msg)},
});
}
Returns 200_OK on success and 409_CONFLICT on invalid user credentials.
Returns a list of items that are on sale.
http://localhost:8001/api/v1/inventory/?format=json
Returns
{"pk", "name", "price", "description"}
The userId received from userinformation as PK.
Positive amount for adding currency to the saldo, negative to decrease saldo.
var transaction = function(userId, amount){
$.ajax({
url: "http://localhost:8001/api/v1/transactions/",
type: 'POST',
beforeSend: function (xhr) {
xhr.setRequestHeader('Authorization', 'Bearer ' + access_token);
},
data: {
'user': userId,
'amount': amount,
},
success: function (data) { console.log(data)},
error: function () { console.log("error")},
});
}
Values reducing the saldo to less than zero will return a 406_NOT_ACCEPTABLE
var json= '{"user": 1, "orders": [{"object_id": 2, "quantity": 1}, {"object_id": 1, "quantity": 1}]}'
var buy = function(){
$.ajax({
url: "http://localhost:8001/api/v1/orderline/",
type: 'POST',
contentType:"application/json",
beforeSend: function (xhr) {
xhr.setRequestHeader('Authorization', 'Bearer ' + access_token);
},
data: jsonString2,
success: function (data) { console.log(data)},
error: function (msg) { console.log(msg)},
});
}
If the order is more expensive than the users saldo a 406_NOT_ACCEPTABLE will be returned.
-
/api/v1/inventory/ - {"pk", "name", "price", "description"}
-
/api/v1/usersaldo/?rfid=[rfid] RETURN{"pk", "first_name", "last_name", "saldo"}
-
/api/v1/transactions/ - POST{"user": [pk], "amount": [amount]} - Adds or subtracts the users balance based on the amount.
-
/api/v1/orderline/ - POST{"user":user_id, "orders":[{"object_id": id, "quantity": 2}]} //By things. object_id= item_id
-
/payme/undo - POST{"user":[rfid] } - Undoes the previous transaction for the user.
- Front page
- Beep card message
- User beeps unknown card
- Rfid unknown - authenticate with user
- Inform the user that the rfid is connect to the onlineuser (events etc)
- Cancel button
- Users beeps known card
- Name and saldo
- items - select multiple (name, price, description)
- History (Low pri)
- Display total price
- Add cash
- Remove cash
- Buy
- Cancel
- User buys
- New saldo
- Price
- Bought items
- Undo button
- Finish button (Exit screen automatically after x seconds)
Either:
-
Ultrabook with touch screen and rotatable screen (3000-4000kr)
-
Touchscreen connected to pc (2000kr)
-
tablet-pc with removable keyboard (2800kr)
-
https://www.komplett.no/product/853960/pc-nettbrett/brbar-pc/2-i-1-pc/asus-t100ha-101-hd#
- Design
- Security
- Secure the rest end point (token, white list MAC/IP, certificate or something similar)
- Restrict the tablet to a webpage.
- Reporting system for trikom when they are running out of for instance cups or forks or something similar.