summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/lib/account
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/www/js/lib/account')
-rw-r--r--StoneIsland/www/js/lib/account/AccountView.js19
-rw-r--r--StoneIsland/www/js/lib/account/PaymentView.js59
2 files changed, 76 insertions, 2 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