diff options
Diffstat (limited to 'StoneIsland/www/js/lib/account')
| -rw-r--r-- | StoneIsland/www/js/lib/account/AccountView.js | 5 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/account/PaymentView.js | 46 |
2 files changed, 43 insertions, 8 deletions
diff --git a/StoneIsland/www/js/lib/account/AccountView.js b/StoneIsland/www/js/lib/account/AccountView.js index 4a213e16..a100ded0 100644 --- a/StoneIsland/www/js/lib/account/AccountView.js +++ b/StoneIsland/www/js/lib/account/AccountView.js @@ -54,7 +54,10 @@ var AccountView = View.extend({ populateCreditCards: function(data, cb){ console.log(data) - if (! data.CreditCards) { + if (! data.CreditCards || ! data.CreditCards.length) { + } + else { + app.payment.populate( data.CreditCards[0] ) } cb && cb() }, diff --git a/StoneIsland/www/js/lib/account/PaymentView.js b/StoneIsland/www/js/lib/account/PaymentView.js index dcf509c8..9410fa42 100644 --- a/StoneIsland/www/js/lib/account/PaymentView.js +++ b/StoneIsland/www/js/lib/account/PaymentView.js @@ -1,6 +1,8 @@ var PaymentView = FormView.extend({ el: "#payment", + + action: sdk.payment.add_credit_card, events: { }, @@ -13,19 +15,19 @@ var PaymentView = FormView.extend({ "City":"Ferrara", "Province":"NY", "HolderIsoCountry":"IT", + "CreditCardCountry": "US", "ZipCode":"40200", - "Phone":"12343340200", - "Type":"Amex", - "Number":"378282246310005", + "Type":"Visa", + "Number":"4111111111111111", "ExpirationMonth":"09", "ExpirationYear":"2017", - "Cvv":"123", + "Cvv":"1233", }, initialize: function(){ this.$form = this.$("form") this.$msg = this.$(".msg") - this.address = new AddressView ({ parent: this }) + this.address = new AddressView ({ parent: this, checkPhone: false }) this.cc = new CreditCardView ({ parent: this }) this.scroller = new IScroll('#payment', app.iscroll_options) }, @@ -34,7 +36,7 @@ var PaymentView = FormView.extend({ if (! auth.logged_in()) { return app.router.go("intro") } app.footer.show("SAVE", "CANCEL") document.body.className = "payment" - this.preload() + // this.preload() }, populate: function(data){ @@ -44,7 +46,37 @@ var PaymentView = FormView.extend({ }, finalize: function(data){ - return null + if (this.cc.data && this.cc.data.Guid) { + sdk.payment.delete_credit_card({ + guid: this.cc.data.Guid, + success: function(){}, + error: function(){}, + }) + } + + data.IsDefault = "true" // this.$isDefault.prop("checked") ? "true" : "false" + data.UserId = sdk.auth.user_id + data.HolderIsoCountry = "US" + data.CreditCardNumber = data.Number + data.IsPreferred = "true" + + console.log(data) + return data + }, + + success: function(data){ + app.curtain.show("loading") + app.account.listAddresses(function(){ + app.curtain.hide("loading") + }) + }, + + error: function(data){ + console.log(data) + }, + + cancel: function(){ + app.router.go("intro") }, }) |
