Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
trismegisto-services
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mauro Paolo Josue Zuñiga Mallqui
trismegisto-services
Commits
ab761f56
Commit
ab761f56
authored
Jul 03, 2025
by
Mauro Paolo Josue Zuñiga Mallqui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ADD] MODIFICACIONES
parent
b61c6ddc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
57 deletions
+86
-57
bbvaRest.java
...web/multitask/trismegistoservices/rest/BBVA/bbvaRest.java
+24
-0
bbvaService.java
...titask/trismegistoservices/services/BBVA/bbvaService.java
+62
-57
No files found.
src/main/java/web/multitask/trismegistoservices/rest/BBVA/bbvaRest.java
View file @
ab761f56
...
@@ -4,6 +4,7 @@ import org.json.JSONObject;
...
@@ -4,6 +4,7 @@ import org.json.JSONObject;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
web.multitask.trismegistoservices.services.BBVA.bbvaService
;
import
web.multitask.trismegistoservices.services.BBVA.bbvaService
;
import
web.multitask.trismegistoservices.services.BBVA.bbvaUtils
;
@RestController
@RestController
@CrossOrigin
(
origins
=
"*"
)
@CrossOrigin
(
origins
=
"*"
)
...
@@ -25,5 +26,28 @@ public class bbvaRest {
...
@@ -25,5 +26,28 @@ public class bbvaRest {
return
ResponseEntity
.
ok
(
jsonResponse
.
toMap
());
return
ResponseEntity
.
ok
(
jsonResponse
.
toMap
());
}
}
@PostMapping
(
"/private/prepareRequest"
)
public
ResponseEntity
<?>
getHeader
(
@RequestBody
String
json
)
{
bbvaUtils
utils
=
new
bbvaUtils
();
String
token
=
utils
.
getToken
();
JSONObject
jsonObject
=
new
JSONObject
(
json
);
if
(
token
.
isEmpty
()){
return
ResponseEntity
.
internalServerError
().
body
(
new
JSONObject
()
.
put
(
"token"
,
""
)
.
put
(
"message"
,
"No token generated"
)
.
put
(
"status"
,
false
));
}
else
{
String
digest
=
utils
.
hashDigest
(
json
);
String
txt
=
utils
.
txtToSign
(
jsonObject
,
digest
);
String
signature
=
utils
.
createSignature
(
txt
);
System
.
out
.
println
(
"token = "
+
token
);
System
.
out
.
println
(
"digest = "
+
digest
);
System
.
out
.
println
(
"signature = "
+
signature
);
return
ResponseEntity
.
ok
(
utils
.
peticionHTTP
(
token
,
digest
,
signature
,
jsonObject
).
toMap
());
}
}
}
}
src/main/java/web/multitask/trismegistoservices/services/BBVA/bbvaService.java
View file @
ab761f56
...
@@ -3,6 +3,7 @@ package web.multitask.trismegistoservices.services.BBVA;
...
@@ -3,6 +3,7 @@ package web.multitask.trismegistoservices.services.BBVA;
import
org.json.JSONArray
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.Objects
;
import
java.util.Objects
;
@Service
@Service
...
@@ -10,20 +11,20 @@ public class bbvaService {
...
@@ -10,20 +11,20 @@ public class bbvaService {
bbvaUtils
utils
=
new
bbvaUtils
();
bbvaUtils
utils
=
new
bbvaUtils
();
public
JSONObject
generalService
(
JSONObject
json
){
public
JSONObject
generalService
(
JSONObject
json
)
{
JSONObject
jsonBillResponse
=
queryBill
(
json
);
JSONObject
jsonBillResponse
=
queryBill
(
json
);
if
(
jsonBillResponse
.
optBoolean
(
"status"
,
false
))
{
if
(
jsonBillResponse
.
optBoolean
(
"status"
,
false
))
{
return
generateQR
(
jsonBillResponse
);
return
generateQR
(
jsonBillResponse
);
}
else
{
}
else
{
return
jsonBillResponse
;
return
jsonBillResponse
;
}
}
}
}
private
JSONObject
queryBill
(
JSONObject
json
){
private
JSONObject
queryBill
(
JSONObject
json
)
{
JSONObject
returnMessage
=
new
JSONObject
();
JSONObject
returnMessage
=
new
JSONObject
();
int
serviceID
=
json
.
optInt
(
"service_id"
,
0
);
int
serviceID
=
json
.
optInt
(
"service_id"
,
0
);
String
actualServiceID
;
String
actualServiceID
;
switch
(
serviceID
)
{
switch
(
serviceID
)
{
...
@@ -42,46 +43,46 @@ public class bbvaService {
...
@@ -42,46 +43,46 @@ public class bbvaService {
}
}
String
documentNumber
=
json
.
getString
(
"document_number"
);
String
documentNumber
=
json
.
getString
(
"document_number"
);
String
endpoint
=
"/pe/bill-payments/v1/services/"
+
actualServiceID
+
"/bills"
;
String
endpoint
=
"/pe/bill-payments/v1/services/"
+
actualServiceID
+
"/bills"
;
String
queryParamater
=
"?billReference.value="
+
documentNumber
;
String
queryParamater
=
"?billReference.value="
+
documentNumber
;
String
method
=
"get"
;
String
method
=
"get"
;
JSONObject
jsonRequest
=
new
JSONObject
();
JSONObject
jsonRequest
=
new
JSONObject
();
jsonRequest
.
put
(
"endpoint"
,
endpoint
);
jsonRequest
.
put
(
"endpoint"
,
endpoint
);
jsonRequest
.
put
(
"extra"
,
queryParamater
);
jsonRequest
.
put
(
"extra"
,
queryParamater
);
jsonRequest
.
put
(
"method"
,
method
);
jsonRequest
.
put
(
"method"
,
method
);
String
token
=
utils
.
getToken
();
String
token
=
utils
.
getToken
();
String
digest
=
utils
.
hashDigest
(
jsonRequest
.
toString
());
String
digest
=
utils
.
hashDigest
(
jsonRequest
.
toString
());
String
txt
=
utils
.
txtToSign
(
jsonRequest
,
digest
);
String
txt
=
utils
.
txtToSign
(
jsonRequest
,
digest
);
String
signature
=
utils
.
createSignature
(
txt
);
String
signature
=
utils
.
createSignature
(
txt
);
JSONObject
jsonResponse
=
utils
.
peticionHTTP
(
token
,
digest
,
signature
,
jsonRequest
);
JSONObject
jsonResponse
=
utils
.
peticionHTTP
(
token
,
digest
,
signature
,
jsonRequest
);
JSONArray
dataFound
=
jsonResponse
.
optJSONArray
(
"data"
,
new
JSONArray
());
JSONArray
dataFound
=
jsonResponse
.
optJSONArray
(
"data"
,
new
JSONArray
());
JSONObject
firstElement
=
dataFound
.
optJSONObject
(
0
,
new
JSONObject
());
JSONObject
firstElement
=
dataFound
.
optJSONObject
(
0
,
new
JSONObject
());
if
(
firstElement
.
isEmpty
())
{
if
(
firstElement
.
isEmpty
())
{
returnMessage
.
put
(
"message"
,
"No se encontró ninguna deuda"
);
returnMessage
.
put
(
"message"
,
"No se encontró ninguna deuda"
);
returnMessage
.
put
(
"status"
,
false
);
returnMessage
.
put
(
"status"
,
false
);
return
returnMessage
;
return
returnMessage
;
}
}
int
month
=
json
.
optInt
(
"month"
,
0
);
int
month
=
json
.
optInt
(
"month"
,
0
);
int
year
=
json
.
optInt
(
"year"
,
0
);
int
year
=
json
.
optInt
(
"year"
,
0
);
int
amount
=
json
.
optInt
(
"amount"
,
0
);
int
amount
=
json
.
optInt
(
"amount"
,
0
);
String
monthString
=
utils
.
numberToMonth
(
month
);
String
monthString
=
utils
.
numberToMonth
(
month
);
String
numberElement
=
firstElement
.
optString
(
"number"
,
""
);
String
numberElement
=
firstElement
.
optString
(
"number"
,
""
);
if
(!(
numberElement
.
contains
(
monthString
)
&&
numberElement
.
contains
(
String
.
valueOf
(
year
))))
{
if
(!(
numberElement
.
contains
(
monthString
)
&&
numberElement
.
contains
(
String
.
valueOf
(
year
))))
{
returnMessage
.
put
(
"message"
,
"La deuda viegente no coincide con el "
+
monthString
+
" de "
+
year
);
returnMessage
.
put
(
"message"
,
"La deuda viegente no coincide con el "
+
monthString
+
" de "
+
year
);
returnMessage
.
put
(
"status"
,
false
);
returnMessage
.
put
(
"status"
,
false
);
return
returnMessage
;
return
returnMessage
;
}
}
String
maturityDate
=
json
.
optString
(
"maturity_date"
,
""
);
String
maturityDate
=
json
.
optString
(
"maturity_date"
,
""
);
String
maturityDateElement
=
firstElement
.
optString
(
"maturityDate"
,
""
);
String
maturityDateElement
=
firstElement
.
optString
(
"maturityDate"
,
""
);
if
(!
Objects
.
equals
(
maturityDateElement
,
maturityDate
))
{
if
(!
Objects
.
equals
(
maturityDateElement
,
maturityDate
))
{
returnMessage
.
put
(
"message"
,
"La deuda no tiene la fecha de vencimiento correcta - "
+
maturityDateElement
);
returnMessage
.
put
(
"message"
,
"La deuda no tiene la fecha de vencimiento correcta - "
+
maturityDateElement
);
returnMessage
.
put
(
"status"
,
false
);
returnMessage
.
put
(
"status"
,
false
);
return
returnMessage
;
return
returnMessage
;
}
}
...
@@ -89,9 +90,9 @@ public class bbvaService {
...
@@ -89,9 +90,9 @@ public class bbvaService {
JSONArray
amounts
=
firstElement
.
optJSONArray
(
"amounts"
,
new
JSONArray
());
JSONArray
amounts
=
firstElement
.
optJSONArray
(
"amounts"
,
new
JSONArray
());
JSONObject
firstAmount
=
amounts
.
optJSONObject
(
0
,
new
JSONObject
());
JSONObject
firstAmount
=
amounts
.
optJSONObject
(
0
,
new
JSONObject
());
JSONObject
amountValue
=
firstAmount
.
optJSONObject
(
"amountValue"
,
new
JSONObject
());
JSONObject
amountValue
=
firstAmount
.
optJSONObject
(
"amountValue"
,
new
JSONObject
());
int
amountElement
=
amountValue
.
optInt
(
"amount"
,
0
);
int
amountElement
=
amountValue
.
optInt
(
"amount"
,
0
);
if
(
amountElement
!=
amount
)
{
if
(
amountElement
!=
amount
)
{
returnMessage
.
put
(
"message"
,
"El monto de la deuda no es correcto - "
+
amountElement
);
returnMessage
.
put
(
"message"
,
"El monto de la deuda no es correcto - "
+
amountElement
);
returnMessage
.
put
(
"status"
,
false
);
returnMessage
.
put
(
"status"
,
false
);
return
returnMessage
;
return
returnMessage
;
}
}
...
@@ -106,7 +107,7 @@ public class bbvaService {
...
@@ -106,7 +107,7 @@ public class bbvaService {
return
returnMessage
;
return
returnMessage
;
}
}
public
JSONObject
generateQR
(
JSONObject
json
){
public
JSONObject
generateQR
(
JSONObject
json
)
{
JSONObject
returnMessage
=
new
JSONObject
();
JSONObject
returnMessage
=
new
JSONObject
();
...
@@ -128,7 +129,7 @@ public class bbvaService {
...
@@ -128,7 +129,7 @@ public class bbvaService {
String
additionalPaymentFieldId
=
"0"
;
String
additionalPaymentFieldId
=
"0"
;
String
additionalPaymentFieldValue
=
json
.
getString
(
"documentNumber"
);
String
additionalPaymentFieldValue
=
json
.
getString
(
"documentNumber"
);
String
serviceProvider
=
"ASOCIACION SACO OLIVEROS"
;
String
serviceProvider
=
"ASOCIACION SACO OLIVEROS"
;
String
partnerId
=
"00
07
"
;
String
partnerId
=
"00
22
"
;
String
partnerEmail
=
"sistemas@sacooliveros.edu.pe"
;
String
partnerEmail
=
"sistemas@sacooliveros.edu.pe"
;
String
partnerPhoneNumber
=
"993521358"
;
String
partnerPhoneNumber
=
"993521358"
;
String
partnerTypeId
=
"AGENT"
;
String
partnerTypeId
=
"AGENT"
;
...
@@ -161,19 +162,19 @@ public class bbvaService {
...
@@ -161,19 +162,19 @@ public class bbvaService {
String
token
=
utils
.
getToken
();
String
token
=
utils
.
getToken
();
String
digest
=
utils
.
hashDigest
(
jsonRequest
.
toString
());
String
digest
=
utils
.
hashDigest
(
jsonRequest
.
toString
());
String
txt
=
utils
.
txtToSign
(
jsonRequest
,
digest
);
String
txt
=
utils
.
txtToSign
(
jsonRequest
,
digest
);
String
signature
=
utils
.
createSignature
(
txt
);
String
signature
=
utils
.
createSignature
(
txt
);
JSONObject
jsonResponse
=
utils
.
peticionHTTP
(
token
,
digest
,
signature
,
jsonRequest
);
JSONObject
jsonResponse
=
utils
.
peticionHTTP
(
token
,
digest
,
signature
,
jsonRequest
);
JSONObject
qrCode
=
jsonResponse
.
optJSONObject
(
"qrCode"
,
new
JSONObject
());
JSONObject
qrCode
=
jsonResponse
.
optJSONObject
(
"qrCode"
,
new
JSONObject
());
if
(!
qrCode
.
isEmpty
())
{
if
(!
qrCode
.
isEmpty
())
{
returnMessage
.
put
(
"hashCode"
,
qrCode
.
get
(
"hashCode"
));
returnMessage
.
put
(
"hashCode"
,
qrCode
.
get
(
"hashCode"
));
returnMessage
.
put
(
"id"
,
qrCode
.
get
(
"id"
));
returnMessage
.
put
(
"id"
,
qrCode
.
get
(
"id"
));
returnMessage
.
put
(
"message"
,
"Well-generated QRCode"
);
returnMessage
.
put
(
"message"
,
"Well-generated QRCode"
);
returnMessage
.
put
(
"status"
,
true
);
returnMessage
.
put
(
"status"
,
true
);
}
else
{
}
else
{
returnMessage
.
put
(
"message"
,
jsonResponse
.
get
(
"message"
));
returnMessage
.
put
(
"message"
,
jsonResponse
.
get
(
"message"
));
returnMessage
.
put
(
"status"
,
false
);
returnMessage
.
put
(
"status"
,
false
);
}
}
...
@@ -181,46 +182,50 @@ public class bbvaService {
...
@@ -181,46 +182,50 @@ public class bbvaService {
return
returnMessage
;
return
returnMessage
;
}
}
public
JSONObject
getStatus
(
String
id
){
public
JSONObject
getStatus
(
String
id
)
{
JSONObject
returnMessage
=
new
JSONObject
();
JSONObject
returnMessage
=
new
JSONObject
();
String
endpoint
=
"/pe/request-to-pay/v1/qrs/"
+
id
+
"/status"
;
try
{
String
method
=
"get"
;
JSONObject
jsonRequest
=
new
JSONObject
()
String
endpoint
=
"/pe/request-to-pay/v1/qrs/"
+
id
+
"/status"
;
.
put
(
"method"
,
method
)
String
method
=
"get"
;
.
put
(
"endpoint"
,
endpoint
);
String
token
=
utils
.
getToken
();
JSONObject
jsonRequest
=
new
JSONObject
()
String
digest
=
utils
.
hashDigest
(
jsonRequest
.
toString
());
.
put
(
"method"
,
method
)
String
txt
=
utils
.
txtToSign
(
jsonRequest
,
digest
);
.
put
(
"endpoint"
,
endpoint
);
String
signature
=
utils
.
createSignature
(
txt
);
JSONObject
jsonResponse
=
utils
.
peticionHTTP
(
token
,
digest
,
signature
,
jsonRequest
);
String
token
=
utils
.
getToken
();
String
digest
=
utils
.
hashDigest
(
jsonRequest
.
toString
());
String
txt
=
utils
.
txtToSign
(
jsonRequest
,
digest
);
String
signature
=
utils
.
createSignature
(
txt
);
JSONObject
jsonResponse
=
utils
.
peticionHTTP
(
token
,
digest
,
signature
,
jsonRequest
);
JSONObject
data
=
jsonResponse
.
optJSONObject
(
"data"
,
new
JSONObject
());
JSONObject
data
=
jsonResponse
.
optJSONObject
(
"data"
,
new
JSONObject
());
if
(!
data
.
isEmpty
())
{
if
(!
data
.
isEmpty
()){
JSONObject
billFirstElement
=
data
.
optJSONArray
(
"bills"
,
new
JSONArray
()).
getJSONObject
(
0
);
JSONObject
billFirstElement
=
data
.
optJSONArray
(
"bills"
,
new
JSONArray
()).
getJSONObject
(
0
);
String
billId
=
billFirstElement
.
getString
(
"id"
);
JSONObject
statusBill
=
billFirstElement
.
optJSONObject
(
"status"
,
new
JSONObject
());
String
nameStatus
=
statusBill
.
getString
(
"name"
);
String
billId
=
billFirstElement
.
getString
(
"id"
);
returnMessage
.
put
(
"message"
,
"PAGADO"
);
//nameStatus
JSONObject
statusBill
=
billFirstElement
.
optJSONObject
(
"status"
,
new
JSONObject
());
returnMessage
.
put
(
"status"
,
true
);
//nameStatus.equals("PAGADO")
String
nameStatus
=
statusBill
.
getString
(
"name"
);
String
idStatus
=
statusBill
.
getString
(
"id"
);
returnMessage
.
put
(
"id"
,
id
);
}
else
{
returnMessage
.
put
(
"billId"
,
billId
);
returnMessage
.
put
(
"message"
,
"Id not found"
);
returnMessage
.
put
(
"statusName"
,
nameStatus
);
returnMessage
.
put
(
"status"
,
false
);
returnMessage
.
put
(
"statusId"
,
idStatus
);
}
}
else
{
return
returnMessage
;
returnMessage
.
put
(
"message"
,
"id not found"
);
}
catch
(
Exception
e
)
{
returnMessage
.
put
(
"message"
,
e
.
getMessage
());
returnMessage
.
put
(
"status"
,
false
);
returnMessage
.
put
(
"status"
,
false
);
return
returnMessage
;
}
}
return
returnMessage
;
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment