summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/lib/account/PaymentView.js
blob: dcf509c82033a8f84b4123428e0cc2b67b16bbff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
var PaymentView = FormView.extend({
  
  el: "#payment",

  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")
    this.address = new AddressView ({ parent: this })
    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.preload()
  },
  
  populate: function(data){
    this.data = data || this.data
    this.address.populate(data)
    this.cc.populate(data)
  },
  
  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()
*/