Fonepay Payment library for java
<dependency>
<groupId>com.fonepay</groupId>
<artifactId>payment</artifactId>
<version>0.9</version>
</dependency>
implementation 'com.fonepay:payment:0.9'
Check https://github.com/fonepay/Fonepay-Spring-Boot-Integration-Sample for example on how to used this libray.
FonepayPaymentRequest fonepayPaymentRequest =
FonepayPaymentRequestBuilder.aFonepayPaymentRequest()
.withMerchantCodePid(paymentRequest.getMerchantCodePid())
.withProductNumberPrn(paymentRequest.getProductNumberPrn())
.withAmountAmt(paymentRequest.getAmountAmt())
.withRemarks1(paymentRequest.getRemarks1())
.withFonepayUrl(fonepayPaymentUrl)
.withMerchantWebsiteReturnUrl(merchantPaymentSuccessReturnUrl)
.withMerchantSecretKey(merchantSecretKey)
.build();
String fonepayPaymentRequestUrl = FonepayService.generateFonepayUrlForPaymentRequest(fonepayPaymentRequest);
Note: Redirect user to fonepayPaymentRequestUrl.
FonepayPaymentVerificationRequest fonepayPaymentVerification =
FonepayPaymentVerificationRequestBuilder.aFonepayPaymentVerificationRequest()
.withProductNumberPrn(productNumberPrn)
.withMerchantCodePid(merchantCodePID)
.withBillIdBid(billId)
.withFonepayTraceIdUniqueUid(fonepayTraceIdUid)
.withFonepayVerificationUrl(fonepayPaymentUrl)
.withMerchantRequestedAmountAmt(paymentRequest.getAmountAmt() + "")
.withMerchantSecretKey(merchantSecretKey)
.build();
String fonepayUrlForPaymentVerification = FonepayService.generateFonepayUrlForPaymentVerificationRequest(fonepayPaymentVerification);
Note: Call fonepayUrlForPaymentVerification api url to verify payment.