diff options
Diffstat (limited to 'StoneIsland/platforms/android/assets/www/js/lib/account/PaymentView.js')
| -rwxr-xr-x | StoneIsland/platforms/android/assets/www/js/lib/account/PaymentView.js | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/account/PaymentView.js b/StoneIsland/platforms/android/assets/www/js/lib/account/PaymentView.js new file mode 100755 index 00000000..03dc8cbf --- /dev/null +++ b/StoneIsland/platforms/android/assets/www/js/lib/account/PaymentView.js @@ -0,0 +1,115 @@ +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, checkPhone: false }) + this.cc = new CreditCardView ({ parent: this }) + this.scroller = new IScroll('#payment', app.iscroll_options) + }, + + show: function(){ + if (! auth.logged_in()) { return app.router.go("intro") } + app.footer.show("SAVE", "CANCEL") + document.body.className = "payment" + this.deferScrollToTop() + // 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) + }, + + 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 |
