-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathAbstract.js
More file actions
118 lines (96 loc) · 2.72 KB
/
Abstract.js
File metadata and controls
118 lines (96 loc) · 2.72 KB
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
116
117
118
'use strict';
var Success = require('./Success');
var Err = require('./Err');
function CallbackRes(JSON_chunk, String_chunk, option){
option = option || {};
if (option.err) {
var response = Err.buildResponseFromErrorObject(option.err);
JSON_chunk = JSON_chunk || response;
String_chunk = String_chunk || JSON.stringify(response);
}
this.JSON_chunk = JSON_chunk;
this.String_chunk = String_chunk;
}
CallbackRes.prototype = {
isSuccessful: function(){
if (this.JSON_chunk.hasOwnProperty('type')) {
if (this.JSON_chunk.type==='Error') {
return false;
} else {
return true;
};
} else if(this.JSON_chunk.hasOwnProperty('secure')){
return true;
} else {
console.log(this.getFullResponse());
return false;
};
},
isCaptured: function(){
return Success.getParameter('capture',this.JSON_chunk);
},
isRefunded: function(){
return Success.getParameter('refunded',this.JSON_chunk);
},
isActivated: function(){
return Success.getParameter('active',this.JSON_chunk);
},
isStarted: function(){
return Success.getParameter('started',this.JSON_chunk);
},
isExpired: function(){
return Success.getParameter('expired',this.JSON_chunk);
},
isUnderReview: function(){
return Success.getParameter('risk',this.JSON_chunk);
},
getFullResponse: function(type){
if (type==="JSON") {
return this.JSON_chunk;
} else {
return this.String_chunk;
}
},
get3DHtml: function(){
var secure = Success.getParameter('secure',this.JSON_chunk);
return secure.formHTML;
},
getChargeId: function(){
if (this.JSON_chunk.object==='charge') {
return Success.getParameter('id',this.JSON_chunk);
} else {
var all_chargeid = Success.getParameter('charge',this.JSON_chunk);
return all_chargeid[(all_chargeid.length-1)];
}
},
getOnetimeToken: function(){
return Success.getParameter('token',this.JSON_chunk);
},
getPermanentToken: function(){
if (this.JSON_chunk.hasOwnProperty('card')&&this.JSON_chunk.card!=null) {
var card = Success.getParameter('token',this.JSON_chunk);
return card.token;
} else {
return null;
}
},
getCardInfo: function(){
return Success.getParameter('card',this.JSON_chunk);
},
getTrialInfo: function(){
return Success.getParameter('trial',this.JSON_chunk);
},
getSubscriptionId: function(){
return Success.getParameter('id',this.JSON_chunk);
},
getErrorCode: function(){
return Err.getParameter('code',this.JSON_chunk);
},
getErrorDetails: function(){
return Err.getParameter('error',this.JSON_chunk);
},
getErrorObject: function(){
return Err.getParameter('err',this.JSON_chunk);
}
};
module.exports = CallbackRes;