Created
March 8, 2019 14:08
-
-
Save cleopatra27/2551f25891a5574847b9e831ae251cf3 to your computer and use it in GitHub Desktop.
java class for ravepay mobile money
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class mobileMoney implements RequestHandler<mobilemoneyPayload, String> { | |
@POST | |
@Consumes({MediaType.APPLICATION_JSON}) | |
@Produces(MediaType.APPLICATION_JSON) | |
public String handleRequest(mobilemoneyPayload mobilemoneyPayload, Context context) { | |
PaymentServices paymentservices = new PaymentServices(); | |
// ReferenceUtil referenceutil = new ReferenceUtil(); | |
InetAddress localhost = null; | |
try { | |
localhost = InetAddress.getLocalHost(); | |
} catch (UnknownHostException ex) { | |
Logger.getLogger(mobileMoney.class.getName()).log(Level.SEVERE, null, ex); | |
} | |
mobilemoneyPayload.setIP((localhost).toString()); | |
System.out.println("IP is ===>" + localhost); | |
Date date = new Date(); | |
//String ref = referenceutil.generateRandomString(10); | |
mobilemoneyPayload.setTxRef("MC" + date); | |
mobilemoneyPayload.setOrderRef("MC" + date); | |
mobilemoneyPayload.setPBFPubKey(raveConfig.PUBLIC_KEY); | |
mobilemoneyPayload.setRedirect_url(raveConfig.REDIRECT_URL); | |
if ( null != mobilemoneyPayload.getPayment_type())switch (mobilemoneyPayload.getPayment_type()) { | |
case "mobilemoneygh": | |
mobilemoneyPayload.setIs_mobile_money_gh(1); | |
break; | |
case "mpesa": | |
mobilemoneyPayload.setIs_mpesa("1"); | |
mobilemoneyPayload.setIs_mpesa_lipa(1); | |
break; | |
case "mobilemoneyuganda": | |
mobilemoneyPayload.setIs_mobile_money_ug(1); | |
break; | |
case "mobilemoneyzambia": | |
mobilemoneyPayload.setIs_mobile_money_ug(1); | |
break; | |
default: | |
break; | |
} | |
TripleDES tripledes = new TripleDES(); | |
// String encrytedsecretkey = tripledes.getKey(raveConfig.SECRET_KEY); | |
String payload = new JSONObject(mobilemoneyPayload).toString(); | |
System.out.println("payload is ===>" + payload); | |
String Encryteddata = tripledes.encryptData(payload, raveConfig.ENCRYPTION_KEY); | |
System.out.println("Encryteddata is ===>" + Encryteddata); | |
String response = paymentservices.doflwmobilemoney(Encryteddata); | |
return response; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment