1
|
|
|
/* |
2
|
|
|
* To change this license header, choose License Headers in Project Properties. |
3
|
|
|
* To change this template file, choose Tools | Templates |
4
|
|
|
* and open the template in the editor. |
5
|
|
|
*/ |
6
|
|
|
package com.github.theresasogunle; |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
|
10
|
|
|
import org.json.JSONObject; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* |
14
|
|
|
* @author Theresa |
15
|
|
|
*/ |
16
|
|
|
public class Fees { |
17
|
|
|
private ApiConnection apiConnection; |
18
|
|
|
|
19
|
|
|
Endpoints end= new Endpoints(); |
20
|
|
|
|
21
|
|
|
private String amount; |
22
|
|
|
private String currency; |
23
|
|
|
private String card6; |
24
|
|
|
/** |
25
|
|
|
* |
26
|
|
|
* |
27
|
|
|
* @return JSONObject |
28
|
|
|
* |
29
|
|
|
*/ |
30
|
|
|
|
31
|
|
|
public JSONObject getFees(){ |
32
|
|
|
|
33
|
|
|
this.apiConnection = new ApiConnection(end.getFeesEndPoint()); |
34
|
|
|
|
35
|
|
|
ApiQuery api= new ApiQuery(); |
36
|
|
|
api.putParams("amount", this.getAmount()); |
37
|
|
|
api.putParams("PBFPubKey", RaveConstant.PUBLIC_KEY); |
38
|
|
|
api.putParams("currency", this.getCurrency()); |
39
|
|
|
api.putParams("ptype",2); |
|
|
|
|
40
|
|
|
|
41
|
|
|
|
42
|
|
|
return this.apiConnection.connectAndQuery(api); |
43
|
|
|
} |
44
|
|
|
/*used only when the user has entered first 6digits of their card number, |
45
|
|
|
it also helps determine international fees on the transaction if the card being used is an international card |
46
|
|
|
*/ |
47
|
|
|
|
48
|
|
|
public JSONObject getFeesForCard6(){ |
49
|
|
|
|
50
|
|
|
this.apiConnection = new ApiConnection(end.getFeesEndPoint()); |
51
|
|
|
|
52
|
|
|
ApiQuery api= new ApiQuery(); |
53
|
|
|
api.putParams("amount", this.getAmount()); |
54
|
|
|
api.putParams("PBFPubKey", RaveConstant.PUBLIC_KEY); |
55
|
|
|
api.putParams("currency", this.getCurrency()); |
56
|
|
|
api.putParams("ptype",2); |
|
|
|
|
57
|
|
|
api.putParams("card6", this.getCard6()); |
58
|
|
|
|
59
|
|
|
return this.apiConnection.connectAndQuery(api); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return the amount |
64
|
|
|
*/ |
65
|
|
|
public String getAmount() { |
66
|
|
|
return amount; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @param amount the amount to set |
71
|
|
|
*/ |
72
|
|
|
public Fees setAmount(String amount) { |
73
|
|
|
this.amount = amount; |
74
|
|
|
return this; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return the currency |
79
|
|
|
*/ |
80
|
|
|
public String getCurrency() { |
81
|
|
|
return currency; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param currency the currency to set |
86
|
|
|
*/ |
87
|
|
|
public Fees setCurrency(String currency) { |
88
|
|
|
this.currency = currency; |
89
|
|
|
return this; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return the card6 |
94
|
|
|
*/ |
95
|
|
|
public String getCard6() { |
96
|
|
|
return card6; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @param card6 the card6 to set |
101
|
|
|
*/ |
102
|
|
|
public Fees setCard6(String card6) { |
103
|
|
|
this.card6 = card6; |
104
|
|
|
return this; |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|
Using constants for hard-coded numbers is a best practice. A constant’s name can explain the rationale behind this magic number. It is also easier to find if you ever need to change it.