summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--StoneIsland/www/index.html17
-rw-r--r--StoneIsland/www/js/lib/_router.js1
-rw-r--r--StoneIsland/www/js/lib/cart/CartConfirm.js38
-rw-r--r--StoneIsland/www/js/lib/cart/CartError.js28
-rw-r--r--StoneIsland/www/js/lib/cart/CartPayment.js18
-rw-r--r--StoneIsland/www/js/lib/cart/CartShipping.js4
-rw-r--r--StoneIsland/www/js/lib/cart/CartSummary.js2
-rw-r--r--StoneIsland/www/js/lib/cart/CartThanks.js3
-rw-r--r--StoneIsland/www/js/lib/cart/CartView.js1
-rw-r--r--StoneIsland/www/js/lib/view/Serializable.js1
-rw-r--r--test/test/04-cart.js10
-rw-r--r--test/test/05-cart-flows.js145
12 files changed, 217 insertions, 51 deletions
diff --git a/StoneIsland/www/index.html b/StoneIsland/www/index.html
index 2c6031c7..f3f5b3ae 100644
--- a/StoneIsland/www/index.html
+++ b/StoneIsland/www/index.html
@@ -669,8 +669,7 @@
</div>
<label class="checkbox-caption" for="address-checkbox-{{id}}">
{{name}}<br>
- {{address}}<br>
- {{city}}, {{state}} {{zip}}
+ {{address}}, {{city}}, {{state}} {{zip}}
</label>
</div>
</script>
@@ -745,7 +744,7 @@
</div>
</div>
<div class="address_list checkbox-container">
- <script type="text/html" class="address_template">
+ <script type="text/html" class="address_row_template">
<div class="checkbox-row">
<div class="checkbox-toggle">
<input id="address-checkbox-{{id}}" type="radio" name="AddressId" value="{{id}}" {{checked}}>
@@ -753,8 +752,7 @@
</div>
<label class="checkbox-caption" for="address-checkbox-{{id}}">
{{name}}<br>
- {{address}}<br>
- {{city}}, {{state}} {{zip}}
+ {{address}}, {{city}}, {{state}} {{zip}}
</label>
</div>
</script>
@@ -779,7 +777,7 @@
<label for="cc-checkbox-{{id}}"></label>
</div>
<label class="checkbox-caption" for="cc-checkbox-{{id}}">
- XXXX XXXX XXXX {{last4}}<br>
+ {{number}}<br>
{{type}} {{exp}}
</label>
</div>
@@ -877,6 +875,12 @@
</p>
</div>
+ <div id="cart_error">
+ <b>WE'RE SORRY</b>
+ <p class="errrrrrrrrrrrrrrr">
+ </p>
+ </div>
+
</div>
<div id="curtain">
@@ -1081,6 +1085,7 @@
<script src="js/lib/cart/CartSummary.js"></script>
<script src="js/lib/cart/CartConfirm.js"></script>
<script src="js/lib/cart/CartThanks.js"></script>
+<script src="js/lib/cart/CartError.js"></script>
<script src="js/lib/nav/IntroView.js"></script>
<script src="js/lib/nav/CurtainView.js"></script>
diff --git a/StoneIsland/www/js/lib/_router.js b/StoneIsland/www/js/lib/_router.js
index 23daf4c7..b1fa1c97 100644
--- a/StoneIsland/www/js/lib/_router.js
+++ b/StoneIsland/www/js/lib/_router.js
@@ -36,6 +36,7 @@ var SiteRouter = Router.extend({
'/cart/shipping': 'cart.shipping',
'/cart/confirm': 'cart.confirm',
'/cart/thanks': 'cart.thanks',
+ '/cart/error': 'cart.error',
},
initialize: function(){
diff --git a/StoneIsland/www/js/lib/cart/CartConfirm.js b/StoneIsland/www/js/lib/cart/CartConfirm.js
index 171f41a1..8e841138 100644
--- a/StoneIsland/www/js/lib/cart/CartConfirm.js
+++ b/StoneIsland/www/js/lib/cart/CartConfirm.js
@@ -127,9 +127,47 @@ var CartConfirm = FormView.extend({
},
save: function(){
+ promise(sdk.cart.finalize, {}).then(function(){
+ app.router.go('cart/thanks')
+ }.bind(this)).error(function(data){
+ // {"Header":{"StatusCode":403,"Description":"403 Forbidden"},"Error":{"Description":"GenericApiError:CartAlreadyClosed"}}
+ // {"Header":{"StatusCode":409,"Description":"304 NotModified"},"Error":{"Description":"FinalizationError:\\"Item has been removed from cart because it is no longer available.\\"\\n235"}}'
+ // {"Header":{"StatusCode":409,"Description":"304 NotModified"},"Error":{"Description":"FinalizationError:\"The cart cannot be empty.\"\n233"}}
+ // {"Header":{"StatusCode":409,"Description":"304 NotModified"},"Error":{"Description":"FinalizationError:\"The reciever validation fails."}}
+ // {"Header":{"StatusCode":440,"Description":"304 NotModified"},"Error":{"Description":"GenericApiError:CartFinalizationNotYetCompleted"}}
+ // {"Header":{"StatusCode":441,"Description":"304 NotModified"},"Error":{"Description":"GenericApiError:EmptyCreditCard"}}
+ switch (data.StatusCode) {
+ case 403: // cart already closed
+ // reset cart
+ break
+ case 409: // finalization error
+ this.finalization_error(data)
+ break
+ case 440: // genericapierror (credit card error!)
+ case 441: // genericapierror (credit card cleared)
+ app.router.go('cart/payment')
+ app.cart.payment.show_errors(["Number","There was a problem with your credit card."])
+ break
+ }
+ }.bind(this))
+ },
+
+ finalization_error: function(data){
+ if (data['Error']['Description'].match(/receiver validation fails/)) {
+ app.router.go('cart/shipping')
+ app.cart.payment.show_errors(["Number","There was a problem with your credit card."])
+ }
+ else if (data['Error']['Description'].match(/cart cannot be empty/)) {
+ app.router.go('cart/summary')
+ }
+ else if (data['Error']['Description'].match(/Item has been removed/)) {
+ app.router.go('cart/thanks')
+ app.cart.thanks.show_error("We're sorry, but one or more items was out of stock. Please check your cart and try again.")
+ }
},
cancel: function(){
+ app.router.go('cart/payment')
},
}) \ No newline at end of file
diff --git a/StoneIsland/www/js/lib/cart/CartError.js b/StoneIsland/www/js/lib/cart/CartError.js
new file mode 100644
index 00000000..f2edae35
--- /dev/null
+++ b/StoneIsland/www/js/lib/cart/CartError.js
@@ -0,0 +1,28 @@
+var CartError = View.extend({
+
+ el: "#cart_error",
+
+ events: {
+ },
+
+ initialize: function(opt){
+ this.parent = opt.parent
+ this.$error = this.$(".errrrrrrrrrrrrrrr")
+ },
+
+ show: function(){
+ document.body.className = "cart"
+ app.cart.el.className = "cart_error"
+ app.footer.show("&lt; BACK TO CART")
+ app.footer.hide()
+ },
+
+ show_error: function(msg){
+ this.$error.html(msg)
+ },
+
+ ok: function(){
+ app.router.go("cart/summary")
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/www/js/lib/cart/CartPayment.js b/StoneIsland/www/js/lib/cart/CartPayment.js
index 11d6cddf..8a597310 100644
--- a/StoneIsland/www/js/lib/cart/CartPayment.js
+++ b/StoneIsland/www/js/lib/cart/CartPayment.js
@@ -2,7 +2,7 @@ var CartPayment = FormView.extend({
el: "#cart_payment",
- address_template: $("#cart_payment .address_template").html(),
+ address_template: $("#cart_payment .address_row_template").html(),
cc_template: $("#cart_payment .cc_template").html(),
action: sdk.cart.set_credit_card,
@@ -89,25 +89,23 @@ var CartPayment = FormView.extend({
this.toggle_cc( !! app.account.ccs.length )
app.account.ccs.forEach(function(cc){
- console.log(cc)
-
var address_t = this.address_template.replace(/{{id}}/g, cc.Id)
.replace(/{{checked}}/g, cc.IsDefault ? "checked" : "")
- .replace(/{{name}}/g, cc.Name + " " + cc.Surname)
- .replace(/{{address}}/g, cc.Address.replace(/\n$/,"").replace("\n", "<br>"))
+ .replace(/{{name}}/g, (cc.Name + " " + cc.Surname).toUpperCase())
+ .replace(/{{address}}/g, cc.Address.replace(/\n$/,"").replace("\n", ", "))
.replace(/{{city}}/g, cc.City)
.replace(/{{state}}/g, cc.Province)
.replace(/{{zip}}/g, cc.ZipCode)
var cc_t = this.cc_template.replace(/{{id}}/g, cc.Id)
.replace(/{{checked}}/g, cc.IsDefault ? "checked" : "")
- .replace(/{{last4}}/g, cc.Last4)
- .replace(/{{type}}/g, cc.Type)
+ .replace(/{{number}}/g, cc['Number'])
+ .replace(/{{type}}/g, cc.Type.toUpperCase())
.replace(/{{exp}}/g, cc.ExpirationMonth + "/" + cc.ExpirationYear)
this.$address_list.append(address_t)
this.$cc_list.append(cc_t)
- })
+ }.bind(this))
},
finalize: function(data){
@@ -173,6 +171,10 @@ var CartPayment = FormView.extend({
app.router.go('cart/confirm')
},
+ error: function(data){
+ console.log(data)
+ },
+
cancel: function(){
app.router.go('cart/shipping')
},
diff --git a/StoneIsland/www/js/lib/cart/CartShipping.js b/StoneIsland/www/js/lib/cart/CartShipping.js
index ef906804..f17d42d2 100644
--- a/StoneIsland/www/js/lib/cart/CartShipping.js
+++ b/StoneIsland/www/js/lib/cart/CartShipping.js
@@ -45,8 +45,8 @@ var CartShipping = FormView.extend({
app.account.addresses.forEach(function(address){
var t = this.template.replace(/{{id}}/g, address.Id)
.replace(/{{checked}}/g, address.IsDefault ? "checked" : "")
- .replace(/{{name}}/g, address.Name + " " + address.Surname)
- .replace(/{{address}}/g, address.Address.replace(/\n$/,"").replace("\n", "<br>"))
+ .replace(/{{name}}/g, (address.Name + " " + address.Surname).toUpperCase())
+ .replace(/{{address}}/g, address.Address.replace(/\n$/,"").replace("\n", ", "))
.replace(/{{city}}/g, address.City)
.replace(/{{state}}/g, address.Province)
.replace(/{{zip}}/g, address.ZipCode)
diff --git a/StoneIsland/www/js/lib/cart/CartSummary.js b/StoneIsland/www/js/lib/cart/CartSummary.js
index 0ad57020..f370dc73 100644
--- a/StoneIsland/www/js/lib/cart/CartSummary.js
+++ b/StoneIsland/www/js/lib/cart/CartSummary.js
@@ -39,6 +39,7 @@ var CartSummary = ScrollableView.extend({
load: function(){
this.el.className = "loading"
app.footer.show("SHIPPING &gt;", "CANCEL")
+ app.curtain.show("loading")
sdk.cart.get_status({
success: this.populate.bind(this),
error: this.empty.bind(this),
@@ -127,6 +128,7 @@ var CartSummary = ScrollableView.extend({
this.el.className = "full"
this.refreshScroller()
+ app.curtain.hide("loading")
},
updateCounts: function(){
diff --git a/StoneIsland/www/js/lib/cart/CartThanks.js b/StoneIsland/www/js/lib/cart/CartThanks.js
index eb95197b..97b7155f 100644
--- a/StoneIsland/www/js/lib/cart/CartThanks.js
+++ b/StoneIsland/www/js/lib/cart/CartThanks.js
@@ -18,6 +18,9 @@ var CartThanks = View.extend({
app.orders.loaded = false
},
+ show_error: function(){
+ },
+
ok: function(){
app.router.go("store")
},
diff --git a/StoneIsland/www/js/lib/cart/CartView.js b/StoneIsland/www/js/lib/cart/CartView.js
index b57caadd..032b2fed 100644
--- a/StoneIsland/www/js/lib/cart/CartView.js
+++ b/StoneIsland/www/js/lib/cart/CartView.js
@@ -14,6 +14,7 @@ var CartView = View.extend({
this.shipping = new CartShipping ({ parent: this })
this.confirm = new CartConfirm ({ parent: this })
this.thanks = new CartThanks ({ parent: this })
+ this.error = new CartError ({ parent: this })
this.$full_msg = this.$(".full_msg")
this.$empty_msg = this.$(".empty_msg")
diff --git a/StoneIsland/www/js/lib/view/Serializable.js b/StoneIsland/www/js/lib/view/Serializable.js
index 6ef8eda3..3cb6e660 100644
--- a/StoneIsland/www/js/lib/view/Serializable.js
+++ b/StoneIsland/www/js/lib/view/Serializable.js
@@ -69,6 +69,7 @@ var SerializableView = View.extend({
var errors = errors || []
var presence_msgs = this.validate_presence || {}
if (! this.disabled) {
+ console.log("not dislab.ed..")
Object.keys(presence_msgs).forEach(function(k){
if (! data[k]) errors.push( [ k, presence_msgs[k] ] )
})
diff --git a/test/test/04-cart.js b/test/test/04-cart.js
index b786df3e..d92a6d3f 100644
--- a/test/test/04-cart.js
+++ b/test/test/04-cart.js
@@ -169,6 +169,16 @@ describe('payment', function(){
sdk.auth.user_id = 374663521
}
+ describe('#get_card_types()', function(){
+ it('gets card types', function(done){
+ promise(sdk.cart.get_card_types).then(function(data){
+ assert(data.Header.StatusCode == 200)
+ console.log(data.CardTypes.CardTypesList)
+ done()
+ })
+ })
+ })
+
describe('#set_payment_type()', function(){
it('sets payment type', function(done){
// this id probably needs to be hard coded. 1 = credit card.
diff --git a/test/test/05-cart-flows.js b/test/test/05-cart-flows.js
index e4e3a191..3a139ba0 100644
--- a/test/test/05-cart-flows.js
+++ b/test/test/05-cart-flows.js
@@ -10,18 +10,20 @@ var assert = require("assert")
describe('finalize_cart', function(){
var new_user_data = {
- "Email": "nick.kegeyan+" + Math.floor(Math.random() * 10000000) + "@gmail.com",
+ "Email": "blahtest+" + Math.floor(Math.random() * 10000000) + "@blahtest.com",
"Password": "TestPasswordYOOX",
"Gender": "U",
- "Name": "Candace",
- "Surname": "Roy",
+ "Name": "test",
+ "Surname": "test",
"DataProfiling": true,
}
var test_product = {
- Code10: "46413442EJ",
- Size: "6",
+ "Code10": "37725683OV",
+ "Size": 4,
}
+ this.timeout(30000)
+
describe('#signup()', function(){
it('makes a user and creates a token', function(done){
promise(sdk.account.signup, { data: new_user_data }).then(function(data){
@@ -60,27 +62,51 @@ describe('finalize_cart', function(){
})
})
- describe('#get_card_types()', function(){
- it('gets card types', function(done){
- promise(sdk.cart.get_card_types).then(function(data){
- assert(data.Header.StatusCode == 200)
- console.log(data.CardTypes.CardTypesList)
+ describe('#finalize()', function(){
+ it('fails to finalize a cart with test data', function(done){
+ promise(sdk.cart.finalize, {}).then(function(data){
+ console.log("SUCCESS", data)
+ done()
+ }).error(function(data){
+ console.log("FAILURE", data.responseText)
done()
})
})
})
-
+
+ describe('#add_item()', function(){
+ it('adds item to cart', function(done){
+
+ promise(sdk.cart.add_item, { data: test_product }).then(function(data){
+ assert(data.Header.StatusCode == 201)
+ done()
+ })
+ })
+ })
+
+ describe('#finalize()', function(){
+ it('fails to finalize a cart with test data', function(done){
+ promise(sdk.cart.finalize, {}).then(function(data){
+ console.log("SUCCESS", data)
+ done()
+ }).error(function(data){
+ console.log("FAILURE", data.responseText)
+ done()
+ })
+ })
+ })
+
describe('#set_shipping_address()', function(){
it('sets shipping address', function(done){
var shipping_info = {
- "Name":"Candace",
- "Surname":"Roy",
- "Email":"nick.kegeyan@gmail.com",
- "Phone":"917-846-3263",
- "Mobile":"917-846-3263",
- "StreetWithNumber":"5 Crosby\n",
+ "Name":"test",
+ "Surname":"test",
+ "Email":"test@test.com",
+ "Phone":"2345790612",
+ "Mobile":"test",
+ "StreetWithNumber":"test\n",
"PostalCode":"10013",
- "City":"New York City",
+ "City":"test",
"Region":"NY",
"CountryCode":"US",
}
@@ -91,24 +117,36 @@ describe('finalize_cart', function(){
})
})
+ describe('#finalize()', function(){
+ it('fails to finalize a cart with test data', function(done){
+ promise(sdk.cart.finalize, {}).then(function(data){
+ console.log("SUCCESS", data)
+ done()
+ }).error(function(data){
+ console.log("FAILURE", data.responseText)
+ done()
+ })
+ })
+ })
+
describe('#set_credit_card()', function(){
it('sets credit card', function(done){
var credit_info = {
"Guid": null,
- "HolderName": "Candace",
- "HolderSurname": "Roy",
- "HolderAddress": "5 Crosby",
+ "HolderName": "test",
+ "HolderSurname": "test",
+ "HolderAddress": "test",
"HolderCity": "New York City",
"HolderProvince": "NY",
"HolderZip": "10013",
"HolderISOCountry": "US",
- "HolderEmail": "nick.kegeyan@gmail.com",
- "CardNumber": "",
+ "HolderEmail": "test@test.com",
+ "CardNumber": "378282246310005",
"Type": "AmericanExpress",
- "ExpirationMonth": "",
- "ExpirationYear": "",
- "Cvv": "",
+ "ExpirationMonth": "12",
+ "ExpirationYear": "20",
+ "Cvv": "1234",
}
promise(sdk.cart.set_credit_card, { data: credit_info }).then(function(data){
@@ -118,6 +156,44 @@ describe('finalize_cart', function(){
})
})
+ describe('#finalize()', function(){
+ it('fails to finalize a cart with test data', function(done){
+ promise(sdk.cart.finalize, {}).then(function(data){
+ console.log("SUCCESS", data)
+ done()
+ }).error(function(data){
+ console.log("FAILURE", data.responseText)
+ done()
+ })
+ })
+ })
+
+ describe('#delete_item()', function(){
+ it('removes item from cart', function(done){
+ var product_item = {
+ "Code10": "37725683OV",
+ "Size": 4,
+ }
+ promise(sdk.cart.delete_item, { data: test_product }).then(function(data){
+ // console.log(data)
+ assert(data.Header.StatusCode == 200)
+ done()
+ })
+ })
+ })
+
+ describe('#finalize()', function(){
+ it('fails to finalize a cart with test data', function(done){
+ promise(sdk.cart.finalize, {}).then(function(data){
+ console.log("SUCCESS", data)
+ done()
+ }).error(function(data){
+ console.log("FAILURE", data.responseText)
+ done()
+ })
+ })
+ })
+
describe('#add_item()', function(){
it('adds item to cart', function(done){
@@ -127,12 +203,14 @@ describe('finalize_cart', function(){
})
})
})
- describe('#get_status()', function(){
- it('get contents of cart', function(done){
- promise(sdk.cart.get_status, {}).then(function(data){
- assert(data.Header.StatusCode == 200)
- console.log(data)
- console.log(data.Cart.Payment)
+
+ describe('#finalize()', function(){
+ it('fails to finalize a cart with test data', function(done){
+ promise(sdk.cart.finalize, {}).then(function(data){
+ console.log("SUCCESS", data)
+ done()
+ }).error(function(data){
+ console.log("FAILURE", data.responseText)
done()
})
})
@@ -140,7 +218,6 @@ describe('finalize_cart', function(){
describe('#finalize()', function(){
it('fails to finalize a cart with test data', function(done){
- this.timeout(10000)
promise(sdk.cart.finalize, {}).then(function(data){
console.log("SUCCESS", data)
done()
@@ -164,7 +241,6 @@ describe('finalize_cart', function(){
describe('#finalize()', function(){
it('again fails to finalize a cart with test data', function(done){
- this.timeout(10000)
promise(sdk.cart.finalize, {}).then(function(data){
console.log("SUCCESS", data)
done()
@@ -177,7 +253,6 @@ describe('finalize_cart', function(){
describe('#finalize()', function(){
it('a third time fails to finalize a cart with test data', function(done){
- this.timeout(10000)
promise(sdk.cart.finalize, {}).then(function(data){
console.log("SUCCESS", data)
done()