Passed
Push — master ( fe77d5...879265 )
by Sogunle
02:02
created

validateCardChargeTimeout(String,String)   A

Complexity

Conditions 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 11
rs 9.85
cc 1
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.rave;
7
8
import static com.rave.Encryption.encryptData;
9
import org.json.JSONException;
10
import org.json.JSONObject;
11
12
/**
13
 *
14
 * @author Theresa
15
 */
16
public class Polling {
17
          ApiConnection apiConnection;
18
      final private Endpoints ed=new Endpoints();
0 ignored issues
show
Coding Style introduced by
The modifiers are customarily declared int the following order: annotations, scope (public, protected, private), abstract, static, final, transient, volatile, synchronized, native, strictfp. Consider reordering your modifiers to comply with this custom.

The Java specification lists the customary order.

Loading history...
19
          Encryption e=new Encryption();
20
          RaveConstant key=new RaveConstant();
21
  
22
  
23
    //if timeout, start polling
24
     /**
25
     * 
26
     *@param json
27
     * @throws JSONException
28
     * @return JSONObject
29
     */
30
    public JSONObject handleTimeoutCharge(JSONObject json){
31
      this.apiConnection = new ApiConnection(ed.getChargeTimeoutEndpoint());
32
        JSONObject tcharge= null;
33
 
34
        String message= json.toString();
35
        
36
        String encrypt_secret_key=Encryption.getKey( RaveConstant.SECRET_KEY);
37
        String client= encryptData(message,encrypt_secret_key);
38
      
39
        String alg="3DES-24";
40
     
41
        ApiQuery api=new ApiQuery();
42
        
43
        api.putParams("PBFPubKey", RaveConstant.PUBLIC_KEY);
44
45
        api.putParams("client", client);
46
47
        api.putParams("alg", alg);
48
      
49
        tcharge=  this.apiConnection.connectAndQuery(api);
50
       
51
        return tcharge;
52
53
    }
54
     /**
55
     * 
56
     * @param transaction_reference
57
     * @param otp 
58
     * @return String
59
     */
60
    public JSONObject validateCardChargeTimeout(String transaction_reference,String otp){
61
       
62
        this.apiConnection = new ApiConnection(ed.getValidateCardChargeTimeoutEndpoint());
63
         ApiQuery api=new ApiQuery();
64
        
65
        api.putParams("PBFPubKey",RaveConstant.PUBLIC_KEY);
66
        api.putParams("transaction_reference", transaction_reference);
67
    
68
        api.putParams("otp", otp);
69
70
        return this.apiConnection.connectAndQuery(api);
71
    }
72
    
73
    
74
      /**
75
     * 
76
     * @param transaction_reference
77
     * @param otp 
78
     * @return String
79
     */
80
    public JSONObject validateAccountChargeTimeout(String transaction_reference,String otp){
81
       
82
        this.apiConnection = new ApiConnection(ed.getValidateAccountChargeTimeoutEndpoint());
83
         ApiQuery api=new ApiQuery();
84
        
85
        api.putParams("PBFPubKey",RaveConstant.PUBLIC_KEY);
86
        api.putParams("transaction_reference", transaction_reference);
87
    
88
        api.putParams("otp", otp);
89
90
        return this.apiConnection.connectAndQuery(api);
91
    }
92
    
93
    
94
95
  
96
    
97
}
98