diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-11-25 23:41:44 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-11-25 23:41:44 -0500 |
| commit | 818a4f598851d4fbfac5addbfd3fedc59772ac2b (patch) | |
| tree | f6c5bda4b0e3c65e4d574df804390301e48cbfe0 /StoneIsland/www/js/lib | |
| parent | 98e21c4f1b096fc117a6a0f770bb69ab7c83914d (diff) | |
populate cc test data
Diffstat (limited to 'StoneIsland/www/js/lib')
| -rw-r--r-- | StoneIsland/www/js/lib/account/AccountView.js | 19 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/account/PaymentView.js | 59 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/nav/CreditCardView.js | 15 |
3 files changed, 83 insertions, 10 deletions
diff --git a/StoneIsland/www/js/lib/account/AccountView.js b/StoneIsland/www/js/lib/account/AccountView.js index ce976094..4a213e16 100644 --- a/StoneIsland/www/js/lib/account/AccountView.js +++ b/StoneIsland/www/js/lib/account/AccountView.js @@ -28,6 +28,7 @@ var AccountView = View.extend({ console.log("populate addresses:", data.AddressBook.addressBookItem) if (! data.AddressBook) { console.log("no addresses") + cb && cb() return } data.AddressBook.addressBookItem.forEach(function(item){ @@ -42,9 +43,25 @@ var AccountView = View.extend({ }) cb && cb() }, - + + listCreditCards: function(cb){ + sdk.payment.list_credit_cards({ + success: function(data){ + this.populateCreditCards(data, cb) + }.bind(this) + }) + }, + + populateCreditCards: function(data, cb){ + console.log(data) + if (! data.CreditCards) { + } + cb && cb() + }, + logged_in: function(cb){ this.listAddresses() + this.listCreditCards() $("#nav .login").hide() $("#nav .account, #nav .logout").show() if (! auth.deferred_product && app.last_view) { diff --git a/StoneIsland/www/js/lib/account/PaymentView.js b/StoneIsland/www/js/lib/account/PaymentView.js index d61ab5ab..dcf509c8 100644 --- a/StoneIsland/www/js/lib/account/PaymentView.js +++ b/StoneIsland/www/js/lib/account/PaymentView.js @@ -5,6 +5,23 @@ var PaymentView = FormView.extend({ events: { }, + test_data: { + "Name":"Name", + "Surname":"Surname", + "Address1":"address", + "Address2":"address2", + "City":"Ferrara", + "Province":"NY", + "HolderIsoCountry":"IT", + "ZipCode":"40200", + "Phone":"12343340200", + "Type":"Amex", + "Number":"378282246310005", + "ExpirationMonth":"09", + "ExpirationYear":"2017", + "Cvv":"123", + }, + initialize: function(){ this.$form = this.$("form") this.$msg = this.$(".msg") @@ -17,9 +34,49 @@ var PaymentView = FormView.extend({ if (! auth.logged_in()) { return app.router.go("intro") } app.footer.show("SAVE", "CANCEL") document.body.className = "payment" + this.preload() + }, + + populate: function(data){ + this.data = data || this.data + this.address.populate(data) + this.cc.populate(data) }, - save: function(){ + finalize: function(data){ + return null }, }) + +/* + var new_card = { + "Name":"Name", + "Surname":"Surname", + "Address":"address", + "City":"Ferrara", + "Province":"FE", + "HolderIsoCountry":"IT", + "ZipCode":"40200", + "Type":"Visa", + "Number":"0000567890124285", + "ExpirationMonth":"02", + "ExpirationYear":"2017", + } + promise(sdk.payment.add_credit_card, { data: new_card }).then(function(data){ + last_guid = data['CreditCard']['Guid'] + assert(data.Header.StatusCode == 201) + assert(!! last_guid) + done() + }) + + promise(sdk.payment.list_credit_cards, { data: {} }).then(function(data){ + assert(data.Header.StatusCode == 201) + console.log(data) + done() + }) + + promise(sdk.payment.delete_credit_card, { guid: last_guid }).then(function(data){ + assert(data.Header.StatusCode == 200) + done() +*/
\ No newline at end of file diff --git a/StoneIsland/www/js/lib/nav/CreditCardView.js b/StoneIsland/www/js/lib/nav/CreditCardView.js index 8d805b80..a942446d 100644 --- a/StoneIsland/www/js/lib/nav/CreditCardView.js +++ b/StoneIsland/www/js/lib/nav/CreditCardView.js @@ -1,5 +1,5 @@ -var CreditCardView = View.extend({ +var CreditCardView = SerializableView.extend({ template: $("#creditcard_template").html(), @@ -16,7 +16,6 @@ var CreditCardView = View.extend({ this.$el.html(this.template) this.$number = this.$("[name=Number]") - console.log(this.$number) this.$number.validateCreditCard(this.updateCard.bind(this), this.cardOptions) }, @@ -27,25 +26,25 @@ var CreditCardView = View.extend({ }, updateCard: function(card){ - console.log(card) + // console.log(card) // card.card_type.name // card.card_type.valid }, validate_presence: { 'Number': 'Please enter your credit card number.', - 'CVV': 'Please enter your security code.', + 'Cvv': 'Please enter your security code.', }, validate_fields: function(data, errors){ - var card = this.$number.validateCreditCard(this.cardOptions) - - if (! card.valid) { errors.push([ "Number", "Your card number is invalid." ]) + if (! card.valid) { errors.push([ "Number", "Your card number is invalid." ]) } if (! data.ExpirationMonth || data.ExpirationMonth == "NONE") { errors.push([ "ExpirationMonth", "Please enter the expiration month." ]) } if (! data.ExpirationYear || data.ExpirationYear == "NONE") { errors.push([ "ExpirationYear", "Please select the expiration month." ]) } data.UserId = auth.user_id - + if (card.valid) { + data.Type = card.card_type.name + } }, }) |
