summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/ios/www/js/lib/cart/CartConfirm.js
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/platforms/ios/www/js/lib/cart/CartConfirm.js')
-rwxr-xr-xStoneIsland/platforms/ios/www/js/lib/cart/CartConfirm.js48
1 files changed, 32 insertions, 16 deletions
diff --git a/StoneIsland/platforms/ios/www/js/lib/cart/CartConfirm.js b/StoneIsland/platforms/ios/www/js/lib/cart/CartConfirm.js
index a82509af..031e3359 100755
--- a/StoneIsland/platforms/ios/www/js/lib/cart/CartConfirm.js
+++ b/StoneIsland/platforms/ios/www/js/lib/cart/CartConfirm.js
@@ -110,20 +110,31 @@ var CartConfirm = FormView.extend({
this.$tax.html( as_cash(tax) )
this.$total.html( as_cash(total) )
- var street = data.Receiver.StreetWithNumber.replace(/\n$/,"").replace("\n", ", ")
- var address = data.Receiver.Name.toUpperCase() + " " + data.Receiver.Surname.toUpperCase() + "<br>" + street + ", "
- address += data.Receiver.City + ", " + data.Receiver.Region + " " + data.Receiver.PostalCode
+ if (data.Receiver) {
+ var street = data.Receiver.StreetWithNumber.replace(/\n$/,"").replace("\n", ", ")
+ var address = data.Receiver.Name.toUpperCase() + " " + data.Receiver.Surname.toUpperCase() + "<br>" + street + ", "
+ address += data.Receiver.City + ", " + data.Receiver.Region + " " + data.Receiver.PostalCode
- this.$shipping_address.html(address)
- this.$shipping_method.html(data.DeliveryMethod.Selected.Type == 1 ? "* STANDARD SHIPPING" : "* EXPRESS SHIPPING")
+ this.$shipping_address.html(address)
+ this.$shipping_method.html(data.DeliveryMethod.Selected.Type == 1 ? "* STANDARD SHIPPING" : "* EXPRESS SHIPPING")
+ } else {
+ this.$shipping_address.html( "Please enter your shipping information." )
+ this.$shipping_method.html( "" )
+ }
var cc = data.Payment.CreditCard
- var cc_street = cc.HolderAddress.replace(/\n$/,"").replace("\n", ", ")
- var cc_type = cc.Type == "AmericanExpress" ? "American Express" : cc.Type
+ if (cc) {
+ var cc_street = cc.HolderAddress.replace(/\n$/,"").replace("\n", ", ")
+ var cc_type = cc.Type == "AmericanExpress" ? "American Express" : cc.Type
+ var cc_name = cc.HolderName.toUpperCase() + " " + cc.HolderSurname.toUpperCase()
+ var cc_eNcrYpTed = cc_type.toUpperCase() + " XXXX-XXXX-XXXX-" + cc.Last4
+ this.$payment_name.html( cc_name )
+ this.$payment_method.html( cc_eNcrYpTed )
+ } else {
+ this.$payment_name.html( "Please enter your credit card information." )
+ this.$payment_method.html( "" )
+ }
- this.$payment_name.html( cc.HolderName.toUpperCase() + " " + cc.HolderSurname.toUpperCase() )
- this.$payment_method.html( cc_type.toUpperCase() + " XXXX-XXXX-XXXX-" + cc.Last4 )
-
app.curtain.hide("loading")
},
@@ -132,7 +143,9 @@ var CartConfirm = FormView.extend({
promise(sdk.cart.finalize, {}).then(function(){
app.curtain.hide("loading")
app.router.go('cart/thanks')
- }.bind(this)).error(function(data){
+ }.bind(this)).error(function(res){
+ const data = res.responseJSON
+ console.log(data)
app.curtain.hide("loading")
// {"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"}}'
@@ -140,7 +153,7 @@ var CartConfirm = FormView.extend({
// {"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) {
+ switch (data.StatusCode || data.Header.StatusCode) {
case 403: // cart already closed
auth.clear_cart(auth.create_cart)
app.router.go('thanks')
@@ -158,14 +171,17 @@ var CartConfirm = FormView.extend({
},
finalization_error: function(data){
- if (data['Error']['Description'].match(/receiver validation fails/)) {
- app.router.go('cart/shipping')
+ if (data['Error']['Description'].match(/receiver validation fails/i)) {
+ console.log('cc error')
+ app.router.go('cart/billing')
app.cart.payment.show_errors([["Number","There was a problem with your credit card."]])
}
- else if (data['Error']['Description'].match(/cart cannot be empty/)) {
+ else if (data['Error']['Description'].match(/cart cannot be empty/i)) {
+ console.log('cart empty')
app.router.go('cart/summary')
}
- else if (data['Error']['Description'].match(/Item has been removed/)) {
+ else if (data['Error']['Description'].match(/Item has been removed/i)) {
+ console.log('item does not exist')
app.router.go('cart/error')
app.cart.error.show_error("We're sorry, but one or more items was out of stock. Please check your cart and try again.")
}