getPasscode
last analyzed

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 2
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
11
import static com.github.theresasogunle.Encryption.encryptData;
12
import org.json.JSONException;
13
14
import org.json.JSONObject;
15
16
17
18
19
/**
20
 *
21
 * @author Theresa
22
 */
23
public class AccountCharge {
24
 
25
    Encryption e=new Encryption();
26
    
27
    private String accountnumber,accountbank,currency,country,
0 ignored issues
show
Coding Style introduced by
Declaring several variables on the same line makes your code hard to read. Consider delaring currency on a separate line.
Loading history...
Coding Style introduced by
Declaring several variables on the same line makes your code hard to read. Consider delaring country on a separate line.
Loading history...
Coding Style introduced by
Declaring several variables on the same line makes your code hard to read. Consider delaring accountbank on a separate line.
Loading history...
28
               amount,email,phonenumber,firstname,lastname,IP,
0 ignored issues
show
Coding Style introduced by
Declaring several variables on the same line makes your code hard to read. Consider delaring lastname on a separate line.
Loading history...
Coding Style introduced by
Declaring several variables on the same line makes your code hard to read. Consider delaring IP on a separate line.
Loading history...
Coding Style introduced by
Declaring several variables on the same line makes your code hard to read. Consider delaring firstname on a separate line.
Loading history...
Coding Style introduced by
Declaring several variables on the same line makes your code hard to read. Consider delaring amount on a separate line.
Loading history...
Coding Style introduced by
Declaring several variables on the same line makes your code hard to read. Consider delaring email on a separate line.
Loading history...
Coding Style introduced by
Declaring several variables on the same line makes your code hard to read. Consider delaring phonenumber on a separate line.
Loading history...
29
               txRef,passcode,device_fingerprint;
0 ignored issues
show
Coding Style introduced by
Declaring several variables on the same line makes your code hard to read. Consider delaring txRef on a separate line.
Loading history...
Coding Style introduced by
Declaring several variables on the same line makes your code hard to read. Consider delaring passcode on a separate line.
Loading history...
Coding Style introduced by
Declaring several variables on the same line makes your code hard to read. Consider delaring device_fingerprint on a separate line.
Loading history...
30
    
31
    private String transaction_reference;//to be called
32
    private String otp;//to be called
33
 
34
    public JSONObject setJSON() {
35
        JSONObject json=new JSONObject();
36
        try{
37
        json.put("PBFPubKey",RaveConstant.PUBLIC_KEY);
38
        json.put("accountnumber",this.getAccountnumber());//expected result'
39
        json.put("accountbank",this.getAccountbank());
40
        json.put("currency", this.getCurrency());
41
        json.put("country", this.getCountry());
42
        json.put("amount", this.getAmount());
43
        json.put("firstname", this.getFirstname());
44
        json.put("lastname", this.getLastname());
45
        json.put("passcode", this.getPasscode());
46
        json.put("email", this.getEmail());
47
        json.put("IP", this.getIP());
48
        json.put("payment_type", "account");
49
        json.put("txRef", this.getTxRef());
50
        json.put("device_fingerprint", this.getDevice_fingerprint());
51
52
        }catch( JSONException ex){ex.getMessage();}
0 ignored issues
show
Best Practice introduced by
Ignoring an Exception may lead to hard to find bugs. Consider logging or rethrowing the original exception. If you want to throw a different exception, you can set the original exception as its cause to preserve the stacktrace.

When instantiating a new Exception, you can set another Exception as its cause.

See the Oracle documentation on Throwables.

Usage example

throw new Exception("Exception Message", originalException);

Complete Example:

class ReThrowException {
  public static void throwsException() {
        try {
            throw new Exception("I am the original exception");
        } catch (final Exception e) {
            throw new RuntimeException("I am the new exception", e);
        }
    }
    public static void main(String[] args) {
        try {
            throwsException();
        }
        catch (final RuntimeException e) {
            System.out.println(e.getMessage());
            System.out.println("and my cause is: " + e.getCause().getMessage());
            e.printStackTrace();
        }
    }
}
Loading history...
53
        return json;
54
   }
55
     
56
57
    /**
58
    *
59
60
    * @return json
61
    */ 
62
    
63
    public JSONObject chargeAccount() {
64
       
65
        JSONObject json=setJSON();
66
        
67
        
68
        String message= json.toString();
69
        
70
        String encrypt_secret_key=Encryption.getKey(RaveConstant.SECRET_KEY);
71
        String client= encryptData(message,encrypt_secret_key);
72
73
        Charge ch=new Charge();
74
        
75
        return ch.charge(client);
76
77
    }
78
     public JSONObject chargeAccount(boolean polling) {
0 ignored issues
show
Unused Code introduced by
Your method has more parameters than it evaluates. Consider removing polling.
Loading history...
79
       
80
        JSONObject json=setJSON();
81
        
82
        Polling p=new Polling();
83
        
84
        return p.handleTimeoutCharge(json);
85
86
    }
87
     
88
89
     public JSONObject validateAccountCharge(){
90
      Charge vcharge= new Charge();
91
     return vcharge.validateAccountCharge(this.getTransaction_reference(), this.getOtp());
92
    }
93
94
    
95
      public JSONObject validateAccountCharge(boolean polling){
0 ignored issues
show
Unused Code introduced by
Your method has more parameters than it evaluates. Consider removing polling.
Loading history...
96
      Polling p=new Polling();
97
      return p.validateAccountChargeTimeout(this.getTransaction_reference(),this.getOtp());
98
    }
99
100
    /**
101
     * @return the accountnumber
102
     */
103
    public String getAccountnumber() {
104
        return accountnumber;
105
    }
106
107
    /**
108
     * @param accountnumber the accountnumber to set
109
     * @return AccountCharge
110
     */
111
    public AccountCharge setAccountnumber(String accountnumber) {
112
        this.accountnumber = accountnumber;
113
        return this;
114
    }
115
116
    /**
117
     * @return the accountbank
118
     */
119
    public String getAccountbank() {
120
        return accountbank;
121
    }
122
123
    /**
124
     * @param accountbank the accountbank to set
125
     * @return AccountCharge
126
     */
127
    public AccountCharge setAccountbank(String accountbank) {
128
        this.accountbank = accountbank;
129
         return this;
130
    }
131
132
    /**
133
     * @return the currency
134
     */
135
    public String getCurrency() {
136
        return currency;
137
    }
138
139
    /**
140
     * @param currency the currency to set
141
     * @return AccountCharge
142
     */
143
    public AccountCharge setCurrency(String currency) {
144
        this.currency = currency;
145
         return this;
146
    }
147
148
    /**
149
     * @return the country
150
     */
151
    public String getCountry() {
152
        return country;
153
    }
154
155
    /**
156
     * @param country the country to set
157
     * @return AccountCharge
158
     */
159
    public AccountCharge setCountry(String country) {
160
        this.country = country;
161
         return this;
162
    }
163
164
    /**
165
     * @return the amount
166
     */
167
    public String getAmount() {
168
        return amount;
169
    }
170
171
    /**
172
     * @param amount the amount to set
173
     * @return AccountCharge
174
     */
175
    public AccountCharge setAmount(String amount) {
176
        this.amount = amount;
177
         return this;
178
    }
179
180
    /**
181
     * @return the email
182
     */
183
    public String getEmail() {
184
        return email;
185
    }
186
187
    /**
188
     * @param email the email to set
189
     * @return AccountCharge
190
     */
191
    public AccountCharge setEmail(String email) {
192
        this.email = email;
193
         return this;
194
    }
195
196
    /**
197
     * @return the phonenumber
198
     */
199
    public String getPhonenumber() {
200
        return phonenumber;
201
    }
202
203
    /**
204
     * @param phonenumber the phonenumber to set
205
     * @return AccountCharge
206
     */
207
    public AccountCharge setPhonenumber(String phonenumber) {
208
        this.phonenumber = phonenumber;
209
         return this;
210
    }
211
212
    /**
213
     * @return the firstname
214
     * 
215
     */
216
    public String getFirstname() {
217
        return firstname;
218
    }
219
220
    /**
221
     * @param firstname the firstname to set
222
     * @return AccountCharge
223
     */
224
    public AccountCharge setFirstname(String firstname) {
225
        this.firstname = firstname;
226
         return this;
227
    }
228
229
    /**
230
     * @return the lastname
231
     */
232
    public String getLastname() {
233
        return lastname;
234
    }
235
236
    /**
237
     * @param lastname the lastname to set
238
     * @return AccountCharge
239
     */
240
    public AccountCharge setLastname(String lastname) {
241
        this.lastname = lastname;
242
         return this;
243
    }
244
245
    /**
246
     * @return the IP
247
     */
248
    public String getIP() {
249
        return IP;
250
    }
251
252
    /**
253
     * @param IP the IP to set
254
     * @return AccountCharge
255
     */
256
    public AccountCharge setIP(String IP) {
257
        this.IP = IP;
258
         return this;
259
    }
260
261
    /**
262
     * @return the txRef
263
     */
264
    public String getTxRef() {
265
        return txRef;
266
    }
267
268
    /**
269
     * @param txRef the txRef to set
270
     * @return AccountCharge
271
     */
272
    public AccountCharge setTxRef(String txRef) {
273
        this.txRef = txRef;
274
         return this;
275
    }
276
277
    /**
278
     * @return the passcode
279
     */
280
    public String getPasscode() {
281
        return passcode;
282
    }
283
284
    /**
285
     * @param passcode the passcode to set
286
     * @return AccountCharge
287
     */
288
    public AccountCharge setPasscode(String passcode) {
289
        this.passcode = passcode;
290
         return this;
291
    }
292
293
    /**
294
     * @return the device_fingerprint
295
     */
296
    public String getDevice_fingerprint() {
297
        return device_fingerprint;
298
    }
299
300
    /**
301
     * @param device_fingerprint the device_fingerprint to set
302
     * @return AccountCharge
303
     */
304
    public AccountCharge setDevice_fingerprint(String device_fingerprint) {
305
        this.device_fingerprint = device_fingerprint;
306
         return this;
307
    }
308
309
    /**
310
     * @return the transaction_reference
311
     */
312
    public String getTransaction_reference() {
313
        return transaction_reference;
314
    }
315
316
    /**
317
     * @param transaction_reference the transaction_reference to set
318
     * @return AccountCharge
319
     */
320
    public AccountCharge setTransaction_reference(String transaction_reference) {
321
        this.transaction_reference = transaction_reference;
322
         return this;
323
    }
324
325
    /**
326
     * @return the otp
327
     */
328
    public String getOtp() {
329
        return otp;
330
    }
331
332
    /**
333
     * @param otp the otp to set
334
     * @return AccountCharge
335
     */
336
    public AccountCharge setOtp(String otp) {
337
        this.otp = otp;
338
         return this;
339
    }
340
    
341
342
    
343
   
344
    
345
}
346