Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Riina Antikainen
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 25220039
authored
Dec 16, 2014
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add button to bill list for paytrail payment check
1 parent
f69c4ce6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
2 deletions
code/moya-beans-client/ejbModule/fi/codecrew/moya/beans/VerkkomaksutFiBeanLocal.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/VerkkomaksutFiBean.java
code/moya-web/WebContent/resources/cditools/bills/list.xhtml
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/shop/BillListView.java
code/moya-beans-client/ejbModule/fi/codecrew/moya/beans/VerkkomaksutFiBeanLocal.java
View file @
2522003
...
@@ -18,6 +18,9 @@
...
@@ -18,6 +18,9 @@
*/
*/
package
fi
.
codecrew
.
moya
.
beans
;
package
fi
.
codecrew
.
moya
.
beans
;
import
java.util.List
;
import
java.util.Map
;
import
javax.ejb.Local
;
import
javax.ejb.Local
;
import
fi.codecrew.moya.util.SvmReturnType
;
import
fi.codecrew.moya.util.SvmReturnType
;
...
@@ -33,4 +36,9 @@ public interface VerkkomaksutFiBeanLocal {
...
@@ -33,4 +36,9 @@ public interface VerkkomaksutFiBeanLocal {
boolean
validateReturn
(
SvmReturnType
type
,
String
orderNumber
,
String
timestamp
,
String
paid
,
String
method
,
String
authcode
);
boolean
validateReturn
(
SvmReturnType
type
,
String
orderNumber
,
String
timestamp
,
String
paid
,
String
method
,
String
authcode
);
String
getMerchantId
();
Map
<
Integer
,
String
>
getAuthcodeForBills
(
List
<
Bill
>
bills
);
}
}
code/moya-beans/ejbModule/fi/codecrew/moya/beans/VerkkomaksutFiBean.java
View file @
2522003
...
@@ -27,6 +27,9 @@ import java.math.BigDecimal;
...
@@ -27,6 +27,9 @@ import java.math.BigDecimal;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.annotation.security.DeclareRoles
;
import
javax.annotation.security.DeclareRoles
;
import
javax.annotation.security.RolesAllowed
;
import
javax.annotation.security.RolesAllowed
;
...
@@ -63,6 +66,7 @@ import fi.codecrew.moya.beanutil.DecimalXMLAdapter;
...
@@ -63,6 +66,7 @@ import fi.codecrew.moya.beanutil.DecimalXMLAdapter;
import
fi.codecrew.moya.clientutils.BortalLocalContextHolder
;
import
fi.codecrew.moya.clientutils.BortalLocalContextHolder
;
import
fi.codecrew.moya.enums.apps.BillPermission
;
import
fi.codecrew.moya.enums.apps.BillPermission
;
import
fi.codecrew.moya.facade.BillFacade
;
import
fi.codecrew.moya.facade.BillFacade
;
import
fi.codecrew.moya.facade.LanEventPrivatePropertyFacade
;
import
fi.codecrew.moya.model.Bill
;
import
fi.codecrew.moya.model.Bill
;
import
fi.codecrew.moya.model.LanEventPrivateProperty
;
import
fi.codecrew.moya.model.LanEventPrivateProperty
;
import
fi.codecrew.moya.model.LanEventPrivatePropertyKey
;
import
fi.codecrew.moya.model.LanEventPrivatePropertyKey
;
...
@@ -77,7 +81,7 @@ import fi.codecrew.moya.verkkomaksutfi.PaymentEntry;
...
@@ -77,7 +81,7 @@ import fi.codecrew.moya.verkkomaksutfi.PaymentEntry;
*/
*/
@Stateless
@Stateless
@LocalBean
@LocalBean
@DeclareRoles
({
BillPermission
.
S_CREATE_VERKKOMAKSU
})
@DeclareRoles
({
BillPermission
.
S_CREATE_VERKKOMAKSU
,
BillPermission
.
S_WRITE_ALL
})
public
class
VerkkomaksutFiBean
implements
VerkkomaksutFiBeanLocal
{
public
class
VerkkomaksutFiBean
implements
VerkkomaksutFiBeanLocal
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
VerkkomaksutFiBean
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
VerkkomaksutFiBean
.
class
);
...
@@ -343,4 +347,31 @@ public class VerkkomaksutFiBean implements VerkkomaksutFiBeanLocal {
...
@@ -343,4 +347,31 @@ public class VerkkomaksutFiBean implements VerkkomaksutFiBeanLocal {
logger
.
warn
(
msg
,
params
);
logger
.
warn
(
msg
,
params
);
}
}
@EJB
private
LanEventPrivatePropertyFacade
eventPrivatePropertyFacade
;
@Override
public
String
getMerchantId
()
{
String
ret
=
null
;
if
(
isSvmEnabled
()
&&
permbean
.
hasPermission
(
BillPermission
.
WRITE_ALL
))
{
LanEventPrivateProperty
e
=
eventPrivatePropertyFacade
.
getPropertyForEvent
(
LanEventPrivatePropertyKey
.
VERKKOMAKSU_MERCHANT_ID
);
if
(
e
!=
null
&&
e
.
getTextvalue
()
!=
null
&&
!
e
.
getTextvalue
().
isEmpty
())
ret
=
e
.
getTextvalue
();
}
return
ret
;
}
@Override
public
Map
<
Integer
,
String
>
getAuthcodeForBills
(
List
<
Bill
>
bills
)
{
Map
<
Integer
,
String
>
ret
=
new
HashMap
<>();
if
(
isSvmEnabled
()
&&
permbean
.
hasPermission
(
BillPermission
.
WRITE_ALL
))
{
String
merchantId
=
eventPrivatePropertyFacade
.
getPropertyForEvent
(
LanEventPrivatePropertyKey
.
VERKKOMAKSU_MERCHANT_ID
).
getTextvalue
();
String
merchantPassword
=
eventPrivatePropertyFacade
.
getPropertyForEvent
(
LanEventPrivatePropertyKey
.
VERKKOMAKSU_MERCHANT_PASSWORD
).
getTextvalue
();
for
(
Bill
b
:
bills
)
{
ret
.
put
(
b
.
getId
(),
PasswordFunctions
.
calculateMd5
(
"&"
,
merchantPassword
,
merchantId
,
b
.
getId
().
toString
()).
toUpperCase
());
}
}
return
ret
;
}
}
}
code/moya-web/WebContent/resources/cditools/bills/list.xhtml
View file @
2522003
...
@@ -130,6 +130,16 @@
...
@@ -130,6 +130,16 @@
<h:outputText
rendered=
"#{bill.paidDate == null}"
<h:outputText
rendered=
"#{bill.paidDate == null}"
value=
"#{i18n['bill.isNotPaid']}"
/>
value=
"#{i18n['bill.isNotPaid']}"
/>
</p:column>
</p:column>
<p:column
rendered=
"#{billListView.canWriteBill and not empty billListView.paytrailMerchantId}"
>
<form
target=
"_blank"
action=
"https://payment.paytrail.com/check-payment"
method=
"post"
>
<input
name=
"MERCHANT_ID"
type=
"hidden"
value=
"#{billListView.paytrailMerchantId}"
/>
<input
name=
"ORDER_NUMBER"
type=
"hidden"
value=
"#{bill.id}"
/>
<input
name=
"AUTHCODE"
type=
"hidden"
value=
"#{billListView.getAuthcodeForBill(bill.id)}"
/>
<input
name=
"VERSION"
type=
"hidden"
value=
"2"
/>
<input
name=
"submit"
type=
"submit"
value=
"Check payment state"
/>
</form>
</p:column>
<p:rowExpansion
rendered=
"#{billListView.bills.rowCount lt 20}"
>
<p:rowExpansion
rendered=
"#{billListView.bills.rowCount lt 20}"
>
<p:dataList
value=
"#{bill.billLines}"
var=
"line"
>
<p:dataList
value=
"#{bill.billLines}"
var=
"line"
>
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/shop/BillListView.java
View file @
2522003
...
@@ -20,6 +20,8 @@ package fi.codecrew.moya.web.cdiview.shop;
...
@@ -20,6 +20,8 @@ package fi.codecrew.moya.web.cdiview.shop;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.List
;
import
java.util.Map
;
import
javax.ejb.EJB
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.enterprise.context.ConversationScoped
;
...
@@ -29,6 +31,7 @@ import javax.inject.Named;
...
@@ -29,6 +31,7 @@ import javax.inject.Named;
import
javax.management.RuntimeErrorException
;
import
javax.management.RuntimeErrorException
;
import
fi.codecrew.moya.beans.BillBeanLocal
;
import
fi.codecrew.moya.beans.BillBeanLocal
;
import
fi.codecrew.moya.beans.VerkkomaksutFiBeanLocal
;
import
fi.codecrew.moya.bortal.views.BillSummary
;
import
fi.codecrew.moya.bortal.views.BillSummary
;
import
fi.codecrew.moya.enums.apps.BillPermission
;
import
fi.codecrew.moya.enums.apps.BillPermission
;
import
fi.codecrew.moya.exceptions.BillException
;
import
fi.codecrew.moya.exceptions.BillException
;
...
@@ -70,14 +73,30 @@ public class BillListView extends GenericCDIView {
...
@@ -70,14 +73,30 @@ public class BillListView extends GenericCDIView {
return
null
;
return
null
;
}
}
@EJB
private
VerkkomaksutFiBeanLocal
paytrailBean
;
private
String
paytrailMerchantId
;
private
Map
<
Integer
,
String
>
paytrailAuthcodes
;
public
void
initAllBills
()
{
public
void
initAllBills
()
{
if
(
super
.
requirePermissions
(
BillPermission
.
READ_ALL
))
{
if
(
super
.
requirePermissions
(
BillPermission
.
READ_ALL
))
{
beginConversation
();
beginConversation
();
bills
=
new
ListDataModel
<
Bill
>(
billbean
.
findAll
());
List
<
Bill
>
billList
=
billbean
.
findAll
();
bills
=
new
ListDataModel
<
Bill
>(
billList
);
writeBill
=
permbean
.
hasPermission
(
BillPermission
.
WRITE_ALL
);
writeBill
=
permbean
.
hasPermission
(
BillPermission
.
WRITE_ALL
);
if
(
paytrailBean
.
isSvmEnabled
())
{
setPaytrailMerchantId
(
paytrailBean
.
getMerchantId
());
paytrailAuthcodes
=
paytrailBean
.
getAuthcodeForBills
(
billList
);
}
}
}
}
}
public
String
getAuthcodeForBill
(
Integer
id
)
{
return
paytrailAuthcodes
.
get
(
id
);
}
public
void
initSummaryView
()
public
void
initSummaryView
()
{
{
if
(
super
.
requirePermissions
(
BillPermission
.
READ_ALL
))
{
if
(
super
.
requirePermissions
(
BillPermission
.
READ_ALL
))
{
...
@@ -143,4 +162,12 @@ public class BillListView extends GenericCDIView {
...
@@ -143,4 +162,12 @@ public class BillListView extends GenericCDIView {
this
.
showPayButtons
=
showPayButtons
;
this
.
showPayButtons
=
showPayButtons
;
}
}
public
String
getPaytrailMerchantId
()
{
return
paytrailMerchantId
;
}
public
void
setPaytrailMerchantId
(
String
paytrailMerchantId
)
{
this
.
paytrailMerchantId
=
paytrailMerchantId
;
}
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment