|
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.test; |
|
7
|
|
|
|
|
8
|
|
|
import com.rave.AccountCharge; |
|
9
|
|
|
import com.rave.AlternativePayment; |
|
10
|
|
|
import com.rave.Bank; |
|
11
|
|
|
import com.rave.CardCharge; |
|
12
|
|
|
import com.rave.Environment; |
|
13
|
|
|
import com.rave.ExchangeRates; |
|
14
|
|
|
import com.rave.Fees; |
|
15
|
|
|
import com.rave.IntegrityChecksum; |
|
16
|
|
|
import com.rave.PreAuthorization; |
|
17
|
|
|
import com.rave.RaveConstant; |
|
18
|
|
|
import com.rave.Refund; |
|
19
|
|
|
import com.rave.Transaction; |
|
20
|
|
|
|
|
21
|
|
|
import org.json.JSONException; |
|
22
|
|
|
import org.json.JSONObject; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* |
|
26
|
|
|
* @author Theresa |
|
27
|
|
|
*/ |
|
28
|
|
|
|
|
29
|
|
|
public class Test { |
|
|
|
|
|
|
30
|
|
|
public static void main(String [] args) throws JSONException{ |
|
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
RaveConstant.PUBLIC_KEY="FLWPUBK-d8369e6826011f8a1f9f6c7c14a09b80-X"; |
|
33
|
|
|
RaveConstant.SECRET_KEY="FLWSECK-8abf446c71a58aaa858323f3a9ed156b-X"; |
|
34
|
|
|
RaveConstant.ENVIRONMENT=Environment.STAGING; |
|
35
|
|
|
|
|
36
|
|
|
chargeAccountTest(); |
|
37
|
|
|
chargeCardTest(); |
|
38
|
|
|
getBanks(); |
|
39
|
|
|
exchangeRatesTest(); |
|
40
|
|
|
feesTest(); |
|
41
|
|
|
checksumTest(); |
|
42
|
|
|
preAuthTest(); |
|
43
|
|
|
refundTest(); |
|
44
|
|
|
verifyRequeryXquery(); |
|
45
|
|
|
alternativePaymentTest(); |
|
46
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
|
|
49
|
|
|
} |
|
50
|
|
|
public static void chargeAccountTest()throws JSONException{ |
|
51
|
|
|
AccountCharge ch=new AccountCharge(); |
|
52
|
|
|
ch.setAccountnumber("0690000031") |
|
53
|
|
|
.setAccountbank("044") |
|
54
|
|
|
.setAmount("1000") |
|
55
|
|
|
.setCountry("NG") |
|
56
|
|
|
.setCurrency("NGN") |
|
57
|
|
|
.setLastname("Theresa") |
|
58
|
|
|
.setIP("1.3.4.4") |
|
|
|
|
|
|
59
|
|
|
.setTxRef("MX-678DH") |
|
60
|
|
|
.setEmail("[email protected]"); |
|
61
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
JSONObject result=ch.chargeAccount(); |
|
64
|
|
|
System.out.println(result); |
|
65
|
|
|
|
|
66
|
|
|
|
|
67
|
|
|
//validate |
|
68
|
|
|
ch.setTransaction_reference("ACHG-1520795373963"); |
|
69
|
|
|
ch.setOtp("12345"); |
|
70
|
|
|
//for polling JSONObject polling=ch.validateAccountCharge(true); |
|
71
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
JSONObject val=ch.validateAccountCharge(); |
|
|
|
|
|
|
74
|
|
|
|
|
75
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
public static void chargeCardTest()throws JSONException{ |
|
78
|
|
|
CardCharge ch=new CardCharge(); |
|
79
|
|
|
ch.setCardno("4187427415564246") |
|
80
|
|
|
.setCvv("828") |
|
81
|
|
|
.setCurrency("NGN") |
|
82
|
|
|
.setCountry("NG") |
|
83
|
|
|
.setAmount("9000") |
|
84
|
|
|
.setExpiryyear("19") |
|
85
|
|
|
.setExpirymonth("09") |
|
86
|
|
|
.setEmail("[email protected]") |
|
87
|
|
|
.setIP("103.238.105.185") |
|
|
|
|
|
|
88
|
|
|
.setTxRef("MXX-ASC-4578") |
|
89
|
|
|
.setDevice_fingerprint("69e6b7f0sb72037aa8428b70fbe03986c"); |
|
90
|
|
|
|
|
91
|
|
|
//for master card and verve |
|
92
|
|
|
ch.setPin("3310") |
|
93
|
|
|
.setSuggested_auth("PIN"); |
|
94
|
|
|
|
|
95
|
|
|
JSONObject result=ch.chargeMasterAndVerveCard(); |
|
96
|
|
|
System.out.println(result); |
|
97
|
|
|
|
|
98
|
|
|
|
|
99
|
|
|
JSONObject poll=ch.chargeMasterAndVerveCard(true); |
|
|
|
|
|
|
100
|
|
|
|
|
101
|
|
|
//for visa and intl cards |
|
102
|
|
|
ch.setRedirect_url("http://www.google.com"); |
|
103
|
|
|
JSONObject chargevisa=ch.chargeVisaAndIntl(); |
|
104
|
|
|
System.out.println(chargevisa); |
|
105
|
|
|
//if timeout, poll JSONObject pollvisa=ch.chargeVisaAndIntl(true); |
|
106
|
|
|
//validate |
|
107
|
|
|
ch.setOtp("12345"); |
|
108
|
|
|
ch.setTransactionreference("FLW-MOCK-9d8197a1ca6152d762b0b068a80f536b"); |
|
109
|
|
|
|
|
110
|
|
|
JSONObject validateCharge=ch.validateCardCharge(); |
|
111
|
|
|
System.out.println(validateCharge); |
|
112
|
|
|
//if timeout JSONObject validatepoll=ch.validateCardCharge(true); |
|
113
|
|
|
|
|
114
|
|
|
} |
|
115
|
|
|
public static void getBanks() throws JSONException{ |
|
116
|
|
|
|
|
117
|
|
|
Bank b= new Bank(); |
|
118
|
|
|
System.out.println(b.getAllBanks()); |
|
119
|
|
|
|
|
120
|
|
|
} |
|
121
|
|
|
private static void exchangeRatesTest(){ |
|
122
|
|
|
|
|
123
|
|
|
ExchangeRates e=new ExchangeRates(); |
|
124
|
|
|
e.setAmount("500") |
|
125
|
|
|
.setDestination_currency("USD") |
|
126
|
|
|
.setOrigin_currency("NGN"); |
|
127
|
|
|
System.out.println( e.forex()); |
|
128
|
|
|
|
|
129
|
|
|
|
|
130
|
|
|
} |
|
131
|
|
|
public static void feesTest(){ |
|
132
|
|
|
Fees fee=new Fees(); |
|
133
|
|
|
fee.setAmount("500") |
|
134
|
|
|
.setCard6("829222") |
|
135
|
|
|
.setCurrency("NGN"); |
|
136
|
|
|
|
|
137
|
|
|
System.out.println(fee.getFees()); |
|
138
|
|
|
System.out.println(fee.getFeesForCard6()); |
|
139
|
|
|
} |
|
140
|
|
|
public static void checksumTest() { |
|
141
|
|
|
IntegrityChecksum ch=new IntegrityChecksum(); |
|
142
|
|
|
|
|
143
|
|
|
ch.setAmount("20") |
|
144
|
|
|
.setPayment_method("both") |
|
145
|
|
|
.setCustom_description("Pay Internet") |
|
146
|
|
|
.setCustom_logo("http://localhost/payporte-3/skin/frontend/ultimo/shoppy/custom/images/logo.svg") |
|
147
|
|
|
.setCountry("NG") |
|
148
|
|
|
.setCurrency("NGN") |
|
149
|
|
|
.setCustomer_email( "[email protected]") |
|
150
|
|
|
.setCustomer_firstname("Temi") |
|
151
|
|
|
.setCustomer_lastname("Adelewa") |
|
152
|
|
|
.setCustomer_phone("234099940409") |
|
153
|
|
|
.setTxref("MG-CKSKKHH"); |
|
154
|
|
|
|
|
155
|
|
|
String hash= ch.integrityChecksum(); |
|
156
|
|
|
|
|
157
|
|
|
System.out.println(hash); |
|
158
|
|
|
|
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
public static void preAuthTest()throws JSONException{ |
|
162
|
|
|
PreAuthorization ch=new PreAuthorization(); |
|
163
|
|
|
|
|
164
|
|
|
//card charge |
|
165
|
|
|
|
|
166
|
|
|
ch.setCardno("5438898014560229") |
|
167
|
|
|
.setCharge_type("preauth") |
|
168
|
|
|
.setCvv("812") |
|
169
|
|
|
.setExpirymonth("08") |
|
170
|
|
|
.setExpiryyear("20") |
|
171
|
|
|
.setCurrency("NGN") |
|
172
|
|
|
.setCountry("NG") |
|
173
|
|
|
.setAmount("100") |
|
174
|
|
|
.setEmail("[email protected]") |
|
175
|
|
|
.setPhonenumber("08056552980") |
|
176
|
|
|
.setFirstname("user") |
|
177
|
|
|
.setLastname("example") |
|
178
|
|
|
.setIP("40.198.14") |
|
179
|
|
|
.setTxRef("MXX-ASC-4578") |
|
180
|
|
|
.setRedirect_url("https://rave-web.herokuapp.com/receivepayment") |
|
181
|
|
|
.setDevice_fingerprint("69e6b7f0b72037aa8428b70fbe03986c"); |
|
182
|
|
|
|
|
183
|
|
|
|
|
184
|
|
|
|
|
185
|
|
|
JSONObject response=ch.preAuthorizeCard(); |
|
186
|
|
|
|
|
187
|
|
|
|
|
188
|
|
|
ch.setFlwref("FLW-MOCK-d310263f5f73e51d01e6dab32c893679") |
|
189
|
|
|
.setAction("refund"); |
|
190
|
|
|
JSONObject capture= ch.capture(); |
|
191
|
|
|
JSONObject refund= ch.refundOrVoid(); |
|
192
|
|
|
|
|
193
|
|
|
System.out.println(capture); |
|
194
|
|
|
System.out.println(refund); |
|
195
|
|
|
System.out.println(response); |
|
196
|
|
|
} |
|
197
|
|
|
public static void refundTest(){ |
|
198
|
|
|
Refund rf=new Refund(); |
|
199
|
|
|
rf.setRef("FLW-MOCK-d310263f5f73e51d01e6dab32c893679"); |
|
200
|
|
|
System.out.println(rf.refund()); |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
public static void verifyRequeryXquery(){ |
|
204
|
|
|
Transaction t=new Transaction(); |
|
205
|
|
|
t.setFlwref("FLW-MOCK-d310263f5f73e51d01e6dab32c893679") |
|
206
|
|
|
.setTxRef(""); |
|
207
|
|
|
t.verifyTransactionXrequery(); |
|
208
|
|
|
System.out.println(t.verifyTransactionRequery()); |
|
209
|
|
|
|
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
public static void alternativePaymentTest() throws JSONException{ |
|
213
|
|
|
AlternativePayment ch=new AlternativePayment(); |
|
214
|
|
|
|
|
215
|
|
|
//available for only zenith and GTB |
|
216
|
|
|
ch.setAccountnumber("0690000004") |
|
217
|
|
|
.setAccountbank("044") |
|
218
|
|
|
.setCurrency("NGN") |
|
219
|
|
|
.setCountry("NG") |
|
220
|
|
|
.setAmount("6000") |
|
221
|
|
|
.setFirstname("pin") |
|
222
|
|
|
.setLastname("pin") |
|
223
|
|
|
.setPin("3310") |
|
224
|
|
|
.setEmail("[email protected]") |
|
225
|
|
|
.setIP("103.238.105.185") |
|
|
|
|
|
|
226
|
|
|
.setTxRef("MXX-ASC-4578"); |
|
227
|
|
|
|
|
228
|
|
|
JSONObject chargeussd=ch.chargeNigerianUssd(); |
|
229
|
|
|
System.out.println(chargeussd); |
|
230
|
|
|
|
|
231
|
|
|
|
|
232
|
|
|
//for ghana mobile money |
|
233
|
|
|
|
|
234
|
|
|
|
|
235
|
|
|
ch.setOrderRef("0690000") |
|
236
|
|
|
.setNetwork("MTN") |
|
237
|
|
|
.setCurrency("GHS") |
|
238
|
|
|
.setCountry("GH") |
|
239
|
|
|
.setAmount("4000") |
|
240
|
|
|
.setFirstname("pin") |
|
241
|
|
|
.setLastname("pin") |
|
242
|
|
|
.setPin("3310") |
|
243
|
|
|
.setEmail("[email protected]") |
|
244
|
|
|
.setIP("103.238.105.185") |
|
|
|
|
|
|
245
|
|
|
.setTxRef("MXX-90-49578") |
|
246
|
|
|
.setPhonenumber("08020000000"); |
|
247
|
|
|
|
|
248
|
|
|
|
|
249
|
|
|
|
|
250
|
|
|
|
|
251
|
|
|
JSONObject chargegh=ch.chargeGhanaMobileMoney(); |
|
252
|
|
|
System.out.println(chargegh); |
|
253
|
|
|
|
|
254
|
|
|
//for kenya mpesa |
|
255
|
|
|
|
|
256
|
|
|
|
|
257
|
|
|
|
|
258
|
|
|
ch.setCurrency("KES") |
|
259
|
|
|
.setCountry("KE") |
|
260
|
|
|
.setAmount("6000") |
|
261
|
|
|
.setFirstname("pin") |
|
262
|
|
|
.setLastname("pin") |
|
263
|
|
|
.setPin("3310") |
|
264
|
|
|
.setEmail("[email protected]") |
|
265
|
|
|
.setIP("103.238.105.185") |
|
|
|
|
|
|
266
|
|
|
.setTxRef("MXX-ASC-4578") |
|
267
|
|
|
.setOrderRef("y77yy") |
|
268
|
|
|
.setPhonenumber("0903672978"); |
|
269
|
|
|
|
|
270
|
|
|
JSONObject chargempesa=ch.chargeKenyaMpesa(); |
|
271
|
|
|
System.out.println(chargempesa); |
|
272
|
|
|
|
|
273
|
|
|
|
|
274
|
|
|
//complete Transaction |
|
275
|
|
|
Transaction t=new Transaction(); |
|
276
|
|
|
t.setFlwref("FLW-MOCK-XXXXXXXXXXXXXXXXXXXXXXX"); |
|
277
|
|
|
// System.out.println( t.verifyTransactionRequery()); |
|
278
|
|
|
|
|
279
|
|
|
} |
|
280
|
|
|
} |
|
281
|
|
|
|