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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
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()
*/
|