summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/ios/www/js/lib/account/PaymentView.js
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/platforms/ios/www/js/lib/account/PaymentView.js')
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/account/PaymentView.js93
1 files changed, 91 insertions, 2 deletions
diff --git a/StoneIsland/platforms/ios/www/js/lib/account/PaymentView.js b/StoneIsland/platforms/ios/www/js/lib/account/PaymentView.js
index d61ab5ab..9410fa42 100644
--- a/StoneIsland/platforms/ios/www/js/lib/account/PaymentView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/account/PaymentView.js
@@ -1,14 +1,33 @@
var PaymentView = FormView.extend({
el: "#payment",
+
+ action: sdk.payment.add_credit_card,
events: {
},
+ test_data: {
+ "Name":"Name",
+ "Surname":"Surname",
+ "Address1":"address",
+ "Address2":"address2",
+ "City":"Ferrara",
+ "Province":"NY",
+ "HolderIsoCountry":"IT",
+ "CreditCardCountry": "US",
+ "ZipCode":"40200",
+ "Type":"Visa",
+ "Number":"4111111111111111",
+ "ExpirationMonth":"09",
+ "ExpirationYear":"2017",
+ "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)
},
@@ -17,9 +36,79 @@ 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)
+ },
+
+ finalize: function(data){
+ 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)
},
- save: function(){
+ cancel: function(){
+ app.router.go("intro")
},
})
+
+/*
+ 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