Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
A
Afrishop refactored project
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Whispa
Afrishop refactored project
Commits
56bb9d7c
提交
56bb9d7c
authored
11月 07, 2020
作者:
Whispa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
commit commit
上级
efab0723
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
242 行增加
和
134 行删除
+242
-134
CardCharge.java
src/main/java/com/example/afrishop_v3/config/CardCharge.java
+178
-131
Charge.java
src/main/java/com/example/afrishop_v3/config/Charge.java
+2
-2
Endpoints.java
src/main/java/com/example/afrishop_v3/config/Endpoints.java
+9
-1
FlutterWaveController.java
...xample/afrishop_v3/controllers/FlutterWaveController.java
+53
-0
没有找到文件。
src/main/java/com/example/afrishop_v3/config/CardCharge.java
浏览文件 @
56bb9d7c
...
...
@@ -19,106 +19,147 @@ import static com.example.afrishop_v3.config.Encryption.getKey;
/**
*
* @author Theresa
*/
public
class
CardCharge
{
JSONObject
api
=
new
JSONObject
();
Endpoints
ed
=
new
Endpoints
();
JSONObject
api
=
new
JSONObject
();
Endpoints
ed
=
new
Endpoints
();
ApiConnection
apiConnection
;
Encryption
e
=
new
Encryption
();
private
String
cardno
,
cvv
,
expirymonth
,
expiryyear
,
currency
,
country
,
pin
,
suggested_auth
,
amount
,
email
,
phonenumber
,
firstname
,
lastname
,
txRef
,
redirect_url
,
device_fingerprint
,
IP
,
Encryption
e
=
new
Encryption
();
private
String
cardno
,
cvv
,
expirymonth
,
expiryyear
,
currency
,
country
,
pin
,
suggested_auth
,
amount
,
email
,
phonenumber
,
firstname
,
lastname
,
fullname
,
txRef
,
redirect_url
,
device_fingerprint
,
IP
,
charge_type
;
private
String
transactionreference
,
otp
,
authUrl
;
private
String
transactionreference
,
otp
,
authUrl
;
public
void
setFullname
(
String
fullname
)
{
this
.
fullname
=
fullname
;
}
/**
*
* @return JSONObject
*/
*
* @return JSONObject
*/
public
JSONObject
setJSON
()
{
JSONObject
json
=
new
JSONObject
();
try
{
json
.
put
(
"cardno"
,
this
.
getCardno
());
json
.
put
(
"cvv"
,
this
.
getCvv
());
json
.
put
(
"currency"
,
this
.
getCurrency
());
json
.
put
(
"country"
,
this
.
getCountry
());
json
.
put
(
"amount"
,
this
.
getAmount
());
json
.
put
(
"expiryyear"
,
this
.
getExpiryyear
());
json
.
put
(
"expirymonth"
,
this
.
getExpirymonth
());
json
.
put
(
"email"
,
this
.
getEmail
());
json
.
put
(
"IP"
,
this
.
getIP
());
json
.
put
(
"txRef"
,
this
.
getTxRef
());
json
.
put
(
"device_fingerprint"
,
this
.
getDevice_fingerprint
());
// json.put("pin", this.getPin
());
//json.put("suggested_auth", this.getSuggested_auth
());
json
.
put
(
"firstname"
,
this
.
getFirstname
());
json
.
put
(
"lastname"
,
this
.
getLastnam
e
());
json
.
put
(
"redirect_url"
,
this
.
getRedirect_url
());
json
.
put
(
"charge_type"
,
this
.
getCharge_type
()
);
}
catch
(
JSONException
ex
){
ex
.
getMessage
();}
public
JSONObject
setJSON
()
{
JSONObject
json
=
new
JSONObject
();
try
{
json
.
put
(
"cardno"
,
this
.
getCardno
());
json
.
put
(
"cvv"
,
this
.
getCvv
());
json
.
put
(
"currency"
,
this
.
getCurrency
());
json
.
put
(
"country"
,
this
.
getCountry
());
json
.
put
(
"amount"
,
this
.
getAmount
());
json
.
put
(
"expiryyear"
,
this
.
getExpiryyear
());
json
.
put
(
"expirymonth"
,
this
.
getExpirymonth
());
json
.
put
(
"email"
,
this
.
getEmail
());
json
.
put
(
"IP"
,
this
.
getIP
());
json
.
put
(
"txRef"
,
this
.
getTxRef
());
json
.
put
(
"device_fingerprint"
,
this
.
getDevice_fingerprint
());
// json.put("pin", this.getPin
());
//json.put("suggested_auth", this.getSuggested_auth
());
json
.
put
(
"firstname"
,
this
.
getFirstname
());
json
.
put
(
"lastname"
,
this
.
getLastname
());
json
.
put
(
"redirect_url"
,
this
.
getRedirect_url
());
json
.
put
(
"charge_type"
,
this
.
getCharge_typ
e
());
}
catch
(
JSONException
ex
)
{
ex
.
getMessage
(
);
}
return
json
;
}
}
private
JSONObject
getPhoneJSON
()
{
JSONObject
json
=
new
JSONObject
();
try
{
json
.
put
(
"txRef"
,
this
.
getTxRef
());
json
.
put
(
"amount"
,
this
.
getAmount
());
json
.
put
(
"currency"
,
this
.
getCurrency
());
json
.
put
(
"network"
,
"MTN"
);
json
.
put
(
"email"
,
this
.
getEmail
());
json
.
put
(
"phone_number"
,
this
.
getPhonenumber
());
json
.
put
(
"fullname"
,
this
.
getFullname
());
}
catch
(
JSONException
ex
)
{
ex
.
getMessage
();
}
return
json
;
}
public
JSONObject
chargeMasterAndVerveCard
()
throws
JSONException
{
JSONObject
json
=
setJSON
();
json
.
put
(
"PBFPubKey"
,
RaveConstant
.
PUBLIC_KEY
);
json
.
put
(
"pin"
,
this
.
getPin
()
);
json
.
put
(
"suggested_auth"
,
this
.
getSuggested_auth
()
);
JSONObject
json
=
setJSON
();
String
message
=
json
.
toString
();
json
.
put
(
"PBFPubKey"
,
RaveConstant
.
PUBLIC_KEY
);
json
.
put
(
"pin"
,
this
.
getPin
());
json
.
put
(
"suggested_auth"
,
this
.
getSuggested_auth
());
String
encrypt_secret_key
=
getKey
(
RaveConstant
.
SECRET_KEY
);
String
client
=
encryptData
(
message
,
encrypt_secret_key
);
Charge
ch
=
new
Charge
();
String
message
=
json
.
toString
();
String
encrypt_secret_key
=
getKey
(
RaveConstant
.
SECRET_KEY
);
String
client
=
encryptData
(
message
,
encrypt_secret_key
);
Charge
ch
=
new
Charge
();
return
ch
.
charge
(
client
,
ed
.
getChargeEndPoint
());
return
ch
.
charge
(
client
);
}
public
JSONObject
chargeMasterAndVerveCard
(
boolean
polling
)
{
JSONObject
json
=
setJSON
();
json
.
put
(
"PBFPubKey"
,
RaveConstant
.
PUBLIC_KEY
);
json
.
put
(
"pin"
,
this
.
getPin
()
);
json
.
put
(
"suggested_auth"
,
this
.
getSuggested_auth
()
);
Polling
p
=
new
Polling
();
JSONObject
json
=
setJSON
();
json
.
put
(
"PBFPubKey"
,
RaveConstant
.
PUBLIC_KEY
);
json
.
put
(
"pin"
,
this
.
getPin
()
);
json
.
put
(
"suggested_auth"
,
this
.
getSuggested_auth
()
);
Polling
p
=
new
Polling
();
return
p
.
handleTimeoutCharge
(
json
);
}
public
JSONObject
chargeVisaAndIntl
()
throws
JSONException
{
JSONObject
json
=
setJSON
();
json
.
put
(
"PBFPubKey"
,
RaveConstant
.
PUBLIC_KEY
);
json
.
put
(
"redirect_url"
,
this
.
getRedirect_url
()
);
JSONObject
json
=
setJSON
();
json
.
put
(
"PBFPubKey"
,
RaveConstant
.
PUBLIC_KEY
);
json
.
put
(
"redirect_url"
,
this
.
getRedirect_url
());
String
message
=
json
.
toString
();
String
message
=
json
.
toString
();
String
encrypt_secret_key
=
getKey
(
RaveConstant
.
SECRET_KEY
);
String
client
=
encryptData
(
message
,
encrypt_secret_key
);
String
encrypt_secret_key
=
getKey
(
RaveConstant
.
SECRET_KEY
);
String
client
=
encryptData
(
message
,
encrypt_secret_key
);
Charge
ch
=
new
Charge
();
Charge
ch
=
new
Charge
();
return
ch
.
charge
(
client
,
ed
.
getChargeEndPoint
());
return
ch
.
charge
(
client
);
}
public
JSONObject
chargeVisaAndIntl
(
boolean
polling
)
throws
JSONException
{
JSONObject
json
=
setJSON
();
json
.
put
(
"PBFPubKey"
,
RaveConstant
.
PUBLIC_KEY
);
json
.
put
(
"redirect_url"
,
this
.
getRedirect_url
()
);
Polling
p
=
new
Polling
();
public
JSONObject
chargeMobileMoney
()
throws
JSONException
{
JSONObject
json
=
getPhoneJSON
();
json
.
put
(
"PBFPubKey"
,
RaveConstant
.
PUBLIC_KEY
);
json
.
put
(
"redirect_url"
,
this
.
getRedirect_url
());
String
message
=
json
.
toString
();
String
encrypt_secret_key
=
getKey
(
RaveConstant
.
SECRET_KEY
);
String
client
=
encryptData
(
message
,
encrypt_secret_key
);
Charge
ch
=
new
Charge
();
return
ch
.
charge
(
client
,
ed
.
getChargeMobileEndpoint
());
}
public
JSONObject
chargeVisaAndIntl
(
boolean
polling
)
throws
JSONException
{
JSONObject
json
=
setJSON
();
json
.
put
(
"PBFPubKey"
,
RaveConstant
.
PUBLIC_KEY
);
json
.
put
(
"redirect_url"
,
this
.
getRedirect_url
());
Polling
p
=
new
Polling
();
return
p
.
handleTimeoutCharge
(
json
);
}
...
...
@@ -128,33 +169,35 @@ public class CardCharge {
* @return JSONObject
*/
public
JSONObject
validateCardCharge
(){
Charge
vch
=
new
Charge
();
public
JSONObject
validateCardCharge
()
{
Charge
vch
=
new
Charge
();
return
vch
.
validateCardCharge
(
this
.
getTransactionreference
(),
this
.
getOtp
());
}
//if timeout
public
JSONObject
validateCardCharge
(
boolean
polling
){
Polling
p
=
new
Polling
();
public
JSONObject
validateCardCharge
(
boolean
polling
)
{
Polling
p
=
new
Polling
();
return
p
.
validateCardChargeTimeout
(
this
.
getTransactionreference
(),
this
.
getOtp
());
}
/*
if AuthMode::"VBSECURE"or "AVS_VBVSECURECODE"
@params authUrl This requires that you copy the authurl returned in the response
and paste it in the argument and it opens a small window for card validation
*/
public
void
validateCardChargeVB
(){
if
(
Desktop
.
isDesktopSupported
())
{
try
{
Desktop
.
getDesktop
().
browse
(
new
URI
(
this
.
getAuthUrl
()));
}
catch
(
URISyntaxException
|
IOException
ex
){}
public
void
validateCardChargeVB
()
{
if
(
Desktop
.
isDesktopSupported
())
{
try
{
Desktop
.
getDesktop
().
browse
(
new
URI
(
this
.
getAuthUrl
()));
}
catch
(
URISyntaxException
|
IOException
ex
)
{
}
}
}
/**
* @return the cardno
...
...
@@ -165,11 +208,11 @@ public class CardCharge {
/**
* @param cardno the cardno to set
*
@return CardCharge
* @return CardCharge
*/
public
CardCharge
setCardno
(
String
cardno
)
{
this
.
cardno
=
cardno
;
return
this
;
}
...
...
@@ -182,11 +225,11 @@ public class CardCharge {
/**
* @param cvv the cvv to set
*
@return CardCharge
* @return CardCharge
*/
public
CardCharge
setCvv
(
String
cvv
)
{
this
.
cvv
=
cvv
;
return
this
;
}
...
...
@@ -199,11 +242,11 @@ public class CardCharge {
/**
* @param expirymonth the expirymonth to set
*
@return CardCharge
* @return CardCharge
*/
public
CardCharge
setExpirymonth
(
String
expirymonth
)
{
this
.
expirymonth
=
expirymonth
;
return
this
;
}
...
...
@@ -216,11 +259,11 @@ public class CardCharge {
/**
* @param expiryyear the expiryyear to set
*
@return CardCharge
* @return CardCharge
*/
public
CardCharge
setExpiryyear
(
String
expiryyear
)
{
this
.
expiryyear
=
expiryyear
;
return
this
;
}
...
...
@@ -233,11 +276,11 @@ public class CardCharge {
/**
* @param currency the currency to set
*
@return CardCharge
* @return CardCharge
*/
public
CardCharge
setCurrency
(
String
currency
)
{
this
.
currency
=
currency
;
return
this
;
}
...
...
@@ -250,11 +293,11 @@ public class CardCharge {
/**
* @param country the country to set
*
@return CardCharge
* @return CardCharge
*/
public
CardCharge
setCountry
(
String
country
)
{
this
.
country
=
country
;
return
this
;
}
...
...
@@ -267,11 +310,11 @@ public class CardCharge {
/**
* @param pin the pin to set
*
@return CardCharge
* @return CardCharge
*/
public
CardCharge
setPin
(
String
pin
)
{
this
.
pin
=
pin
;
return
this
;
}
...
...
@@ -284,11 +327,11 @@ public class CardCharge {
/**
* @param suggested_auth the suggested_auth to set
*
@return CardCharge
* @return CardCharge
*/
public
CardCharge
setSuggested_auth
(
String
suggested_auth
)
{
this
.
suggested_auth
=
suggested_auth
;
return
this
;
}
...
...
@@ -301,11 +344,11 @@ public class CardCharge {
/**
* @param amount the amount to set
*
@return CardCharge
* @return CardCharge
*/
public
CardCharge
setAmount
(
String
amount
)
{
this
.
amount
=
amount
;
return
this
;
}
...
...
@@ -318,11 +361,11 @@ public class CardCharge {
/**
* @param email the email to set
*
@return CardCharge
* @return CardCharge
*/
public
CardCharge
setEmail
(
String
email
)
{
this
.
email
=
email
;
return
this
;
}
...
...
@@ -333,13 +376,17 @@ public class CardCharge {
return
phonenumber
;
}
public
String
getFullname
()
{
return
fullname
;
}
/**
* @param phonenumber the phonenumber to set
*
@return CardCharge
* @return CardCharge
*/
public
CardCharge
setPhonenumber
(
String
phonenumber
)
{
this
.
phonenumber
=
phonenumber
;
return
this
;
}
...
...
@@ -352,11 +399,11 @@ public class CardCharge {
/**
* @param firstname the firstname to set
*
@return CardCharge
* @return CardCharge
*/
public
CardCharge
setFirstname
(
String
firstname
)
{
this
.
firstname
=
firstname
;
return
this
;
}
...
...
@@ -369,11 +416,11 @@ public class CardCharge {
/**
* @param lastname the lastname to set
*
@return CardCharge
* @return CardCharge
*/
public
CardCharge
setLastname
(
String
lastname
)
{
this
.
lastname
=
lastname
;
return
this
;
}
...
...
@@ -386,11 +433,11 @@ public class CardCharge {
/**
* @param IP the IP to set
*
@return CardCharge
* @return CardCharge
*/
public
CardCharge
setIP
(
String
IP
)
{
this
.
IP
=
IP
;
return
this
;
}
...
...
@@ -403,11 +450,11 @@ public class CardCharge {
/**
* @param txRef the txRef to set
*
@return CardCharge
* @return CardCharge
*/
public
CardCharge
setTxRef
(
String
txRef
)
{
this
.
txRef
=
txRef
;
return
this
;
}
...
...
@@ -420,11 +467,11 @@ public class CardCharge {
/**
* @param redirect_url the redirect_url to set
*
@return CardCharge
* @return CardCharge
*/
public
CardCharge
setRedirect_url
(
String
redirect_url
)
{
this
.
redirect_url
=
redirect_url
;
return
this
;
}
...
...
@@ -437,11 +484,11 @@ public class CardCharge {
/**
* @param device_fingerprint the device_fingerprint to set
*
@return CardCharge
* @return CardCharge
*/
public
CardCharge
setDevice_fingerprint
(
String
device_fingerprint
)
{
this
.
device_fingerprint
=
device_fingerprint
;
return
this
;
}
...
...
@@ -454,11 +501,11 @@ public class CardCharge {
/**
* @param charge_type the charge_type to set
*
@return CardCharge
* @return CardCharge
*/
public
CardCharge
setCharge_type
(
String
charge_type
)
{
this
.
charge_type
=
charge_type
;
return
this
;
}
...
...
@@ -471,11 +518,11 @@ public class CardCharge {
/**
* @param transaction_reference the transaction_reference to set
*
@return CardCharge
* @return CardCharge
*/
public
CardCharge
setTransactionreference
(
String
transaction_reference
)
{
this
.
transactionreference
=
transaction_reference
;
this
.
transactionreference
=
transaction_reference
;
return
this
;
}
...
...
@@ -488,11 +535,11 @@ public class CardCharge {
/**
* @param otp the otp to set
*
@return CardCharge
* @return CardCharge
*/
public
CardCharge
setOtp
(
String
otp
)
{
this
.
otp
=
otp
;
return
this
;
}
...
...
@@ -505,11 +552,11 @@ public class CardCharge {
/**
* @param authUrl the authUrl to set
*
@return CardCharge
* @return CardCharge
*/
public
CardCharge
setAuthUrl
(
String
authUrl
)
{
this
.
authUrl
=
authUrl
;
return
this
;
}
}
src/main/java/com/example/afrishop_v3/config/Charge.java
浏览文件 @
56bb9d7c
...
...
@@ -27,8 +27,8 @@ public class Charge {
//for all charges
public
JSONObject
charge
(
String
client
){
this
.
apiConnection
=
new
ApiConnection
(
e
d
.
getChargeEndPoint
()
);
public
JSONObject
charge
(
String
client
,
String
endpoint
){
this
.
apiConnection
=
new
ApiConnection
(
e
ndpoint
);
String
alg
=
"3DES-24"
;
...
...
src/main/java/com/example/afrishop_v3/config/Endpoints.java
浏览文件 @
56bb9d7c
...
...
@@ -16,6 +16,7 @@ public class Endpoints {
String
url
;
public
String
BANK_ENDPOINT
;
public
static
String
CHARGE_ENDPOINT
;
public
static
String
CHARGE_MOBILE_ENDPOINT
;
public
static
String
CARD_VALIDATE_ENDPOINT
;
public
static
String
ACCOUNT_VALIDATE_ENDPOINT
;
public
static
String
TIMEOUT_ENDPOINT
;
...
...
@@ -47,6 +48,7 @@ public class Endpoints {
BANK_ENDPOINT
=
url
+
"flwv3-pug/getpaidx/api/flwpbf-banks.js?json=1"
;
CHARGE_ENDPOINT
=
url
+
"flwv3-pug/getpaidx/api/charge"
;
CHARGE_MOBILE_ENDPOINT
=
url
+
"flwv3-pug/getpaidx/api/charge?type=mobile_money_rwand"
;
CARD_VALIDATE_ENDPOINT
=
url
+
"flwv3-pug/getpaidx/api/validatecharge"
;
ACCOUNT_VALIDATE_ENDPOINT
=
url
+
"flwv3-pug/getpaidx/api/validate"
;
TIMEOUT_ENDPOINT
=
url
+
"flwv3-pug/getpaidx/api/charge?use_polling=1"
;
...
...
@@ -75,7 +77,13 @@ public class Endpoints {
return
CHARGE_ENDPOINT
;
}
public
String
getValidateCardChargeEndPoint
(){
public
String
getChargeMobileEndpoint
()
{
init
();
return
CHARGE_MOBILE_ENDPOINT
;
}
public
String
getValidateCardChargeEndPoint
(){
init
();
return
CARD_VALIDATE_ENDPOINT
;
...
...
src/main/java/com/example/afrishop_v3/controllers/FlutterWaveController.java
浏览文件 @
56bb9d7c
...
...
@@ -122,6 +122,59 @@ public class FlutterWaveController extends Controller {
}
@PostMapping
(
"/payMobile"
)
public
ResponseEntity
<
String
>
payForOrderByPhone
(
@RequestParam
(
"orderId"
)
String
orderId
,
@RequestBody
FlutterWaveCard
flutterWaveCard
)
{
RaveConstant
.
PUBLIC_KEY
=
PUBLIC_KEY
;
RaveConstant
.
SECRET_KEY
=
SECRET_KEY
;
RaveConstant
.
ENVIRONMENT
=
Environment
.
LIVE
;
//or live
// Result result = new Result();
Optional
<
TbCfOrder
>
byId
=
repository
.
findById
(
orderId
);
JSONObject
json
=
new
JSONObject
();
if
(
byId
.
isPresent
())
{
//TbCfOrderVo tbCfOrderVo = (TbCfOrderVo) orderRedisCache.get(KeyConstant.ORDER_DET + orderId);
TbCfOrder
orderEntity
=
byId
.
get
();
//判断这个订单是否已支付
if
(
OrderStatusEnum
.
PAID
.
getValue
().
equals
(
orderEntity
.
getPayStatus
()))
{
json
.
put
(
"message"
,
"Order paid!"
);
json
.
put
(
"code"
,
ResultCodeEnum
.
ORDER_PAY_ERROR
.
getCode
());
}
else
{
try
{
CardCharge
ch
=
new
CardCharge
();
ch
.
setCardno
(
flutterWaveCard
.
getCard
())
.
setCvv
(
flutterWaveCard
.
getCvv
())
.
setCurrency
(
"USD"
)
.
setCountry
(
"NG"
)
.
setAmount
(
orderEntity
.
getRealityPay
().
toString
())
.
setRedirect_url
(
REDIRECT_URL
+
"/"
+
orderId
)
.
setExpiryyear
(
flutterWaveCard
.
getYear
())
.
setExpirymonth
(
flutterWaveCard
.
getMonth
())
.
setEmail
(
flutterWaveCard
.
getEmail
())
.
setTxRef
(
orderId
);
JSONObject
chargevisa
=
ch
.
chargeMobileMoney
();
JSONObject
object
=
chargevisa
.
getJSONObject
(
"data"
);
boolean
b
=
object
!=
null
&&
object
.
has
(
"authurl"
);
String
message
=
!
b
&&
object
!=
null
&&
object
.
has
(
"message"
)
?
object
.
getString
(
"message"
)
:
ResultCodeEnum
.
SERVICE_ERROR
.
getDesc
();
json
.
put
(
"data"
,
chargevisa
);
json
.
put
(
"code"
,
b
?
ResultCodeEnum
.
SUCCESS
.
getCode
()
:
ResultCodeEnum
.
SERVICE_ERROR
.
getCode
());
json
.
put
(
"message"
,
b
?
ResultCodeEnum
.
SUCCESS
.
getDesc
()
:
message
);
}
catch
(
Exception
e
)
{
json
.
put
(
"code"
,
ResultCodeEnum
.
ORDER_PAY_ERROR
.
getCode
()).
put
(
"message"
,
e
.
getMessage
());
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
}
return
new
ResponseEntity
<>(
json
.
toString
(),
HttpStatus
.
OK
);
}
@GetMapping
(
"/notify/{orderId}"
)
public
Result
verifyFromFlutter
(
@PathVariable
(
"orderId"
)
String
orderId
)
{
return
verifyPay
(
orderId
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论