summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/www/js')
-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
9 files changed, 86 insertions, 10 deletions
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("< 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] ] )
})