-
Notifications
You must be signed in to change notification settings - Fork 10
/
StripeGetResponseValues.cls
64 lines (57 loc) · 2.23 KB
/
StripeGetResponseValues.cls
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
/*
@Name : StripeGetResponseValues
@Author : Aslam Bari/Sanjay Mankani (http://www.aslambari.com/stripe_apex_toolkit.html)
@Date : 6 Oct, 2011
@Description : This class contains methods to parse response from Stripe.
*/
public class StripeGetResponseValues{
public string getValue(string accRecordJson, string fieldName){
integer startIdx = accRecordJson.indexOf(fieldName);
integer endIdx = -1;
if(startIdx > 0){
endIdx = accRecordJson.indexOf('",', startIdx);
}
if(startIdx > 0 && endIdx > startIdx){
return accRecordJson.substring(startIdx + fieldName.length() + 2,endIdx);
}
return '';
}
public string getNumValue(string accRecordJson, string fieldName){
integer startIdx = accRecordJson.indexOf(fieldName);
integer endIdx = -1;
if(startIdx > 0){
endIdx = accRecordJson.indexOf(',', startIdx);
}
if(startIdx > 0 && endIdx > startIdx){
//system.debug('### ' +startIdx + '---' + endIdx);
return accRecordJson.substring(startIdx + fieldName.length() + 1,endIdx);
}
return '';
}
public string getLastValue(string accRecordJson, string fieldName){
integer startIdx = accRecordJson.indexOf(fieldName);
integer endIdx = -1;
if(startIdx > 0){
endIdx = accRecordJson.indexOf('"\n', startIdx);
}
system.debug('$$startIdx='+startIdx);
system.debug('$$endIdx='+endIdx);
if(startIdx > 0 && endIdx > startIdx){
return accRecordJson.substring(startIdx + fieldName.length() + 2,endIdx);
}
return '';
}
/*public string getLastNumValue(string accRecordJson, string fieldName){
integer startIdx = accRecordJson.indexOf(fieldName);
integer endIdx = -1;
if(startIdx > 0){
endIdx = accRecordJson.indexOf('\n', startIdx);
}
system.debug('$$startIdx='+startIdx);
system.debug('$$endIdx='+endIdx);
if(startIdx > 0 && endIdx > startIdx){
return accRecordJson.substring(startIdx + fieldName.length() + 2,endIdx);
}
return '';
}*/
}