forked from SeunAdelekan/PaystackJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPaystackInline.java
More file actions
77 lines (63 loc) · 2.84 KB
/
PaystackInline.java
File metadata and controls
77 lines (63 loc) · 2.84 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
import org.json.JSONObject;
import java.util.HashMap;
/**
* Created by Iyanu Adelekan on 19/07/2016.
*/
public class PaystackInline {
public PaystackInline(){
}
private static ApiConnection apiConnection = null;
/*
The following set of methods aids the sending of API
requests for Paystack Standard
*/
public JSONObject paystackStandard(HashMap<String, Object> queryMap) {
apiConnection = new ApiConnection(Definitions.PAYSTACK_INLINE_PAYSTACK_STANDARD);
return apiConnection.connectAndQuery(queryMap);
}
public JSONObject paystackStandard(ApiQuery query) {
apiConnection = new ApiConnection(Definitions.PAYSTACK_INLINE_PAYSTACK_STANDARD);
return apiConnection.connectAndQuery(query);
}
public JSONObject paystackStandard(String reference, int amount,
String email, String plan, String callback_url) {
apiConnection = new ApiConnection(Definitions.PAYSTACK_INLINE_PAYSTACK_STANDARD);
ApiQuery apiQuery = new ApiQuery();
apiQuery.putParams("reference", reference);
apiQuery.putParams("amount", amount);
apiQuery.putParams("email", email);
apiQuery.putParams("plan", plan);
apiQuery.putParams("callback_url", callback_url);
return apiConnection.connectAndQuery(apiQuery);
}
/*
The following set of methods aids the sending of API
requests for VERIFYING Paystack Standard transactions
*/
public JSONObject verifyTransactions(String reference) {
apiConnection = new ApiConnection(Definitions.PAYSTACK_INLINE_VERIFY_TRANSACTIONS + reference);
return apiConnection.connectAndQueryWithGet();
}
/*
The following set of methods aids the sending of API
requests for charging returning customers with Paystack Standard
*/
public JSONObject chargeReturningCustomer(HashMap<String, Object> queryMap) {
apiConnection = new ApiConnection(Definitions.PAYSTACK_INLINE_CHARGE_AUTHORIZATION);
return apiConnection.connectAndQuery(queryMap);
}
public JSONObject chargeReturningCustomer(ApiQuery query) {
apiConnection = new ApiConnection(Definitions.PAYSTACK_INLINE_CHARGE_AUTHORIZATION);
return apiConnection.connectAndQuery(query);
}
public JSONObject chargeReturningCustomer(String authorization_code, String email,
String amount, String reference) {
apiConnection = new ApiConnection(Definitions.PAYSTACK_INLINE_CHARGE_AUTHORIZATION);
ApiQuery apiQuery = new ApiQuery();
apiQuery.putParams("authorization_code", authorization_code);
apiQuery.putParams("email", email);
apiQuery.putParams("amount", amount);
apiQuery.putParams("reference", reference);
return apiConnection.connectAndQuery(apiQuery);
}
}