markjen / square-connect-node-sdk Goto Github PK
View Code? Open in Web Editor NEWnode.js SDK for Square Connect API
License: Apache License 2.0
node.js SDK for Square Connect API
License: Apache License 2.0
I have to preface this issue by saying that my company (mid-size, >100 employees and >5 stores) had an event involving irreversible infrastructure failure almost 24 hours ago, and I am implementing a very quick and dirty replacement POS/online store for the time being. I say this because I have been going for nearly 18 hours replacing everything I can and am not entirely sure if I could spot bugs in my own code or library code at this point.
i tried to make things a bit easy for you with a jsfiddle, but it doesn't really have a lot of similarity to my code, it just shows the structure of my object that is submitted to your wrapper. http://jsfiddle.net/efjytg6r/4/
When creating an item, I noticed that the price I set is not persisted through to my square account. Here is my form (note: it is HEAVILY modified to take out all styles etc, save the base bootstrap classes for readability and brevity)
here is AngularJS (modified for brevity):
controller:
var itemObj = {};
//set these to be the norm for now
itemObj.pricing_type = 'FIXED_PRICING';
itemObj.price_money = {
currency_code: 'USD'
};
//set up the model
$scope.itemObj = {};
$scope.itemObj.variations = itemObj;
function verify_and_return(str){
var reg = /^\d*\.{0,1}\d{0,2}$/;
var test = reg.test(str);
if (test == false){
//didnt work
} else {
return parseFloat(str);
}
}
$scope.create = function(item){
item.variations.price_money.amount = verify_and_return(item.variations.price_money.amount);
ItemService.create(item)
.then(handleRes, handleRes);
}
service:
this.create = function(item){
return $http.post('/square/item', {
item: item
});
}
and here is my route handler on my express server (again, heavily modified for brevity):
squareRouter.post('/item', function(req, res){
var item = req.body.item;
square.api('/me/items', 'POST', item, function(err, resp){
data_handler(err, resp, res);
});
});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.