Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Roque
slapos.core
Commits
37a63546
Commit
37a63546
authored
Dec 24, 2020
by
Cédric Le Ninivin
Committed by
Rafael Monnerat
Dec 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_payzen: Start Moving SlapOS Payzen to REST API
parent
eb35deda
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
100 deletions
+92
-100
master/bt5/slapos_payzen/SkinTemplateItem/portal_skins/slapos_payzen/PaymentTransaction_updateStatus.py
...al_skins/slapos_payzen/PaymentTransaction_updateStatus.py
+7
-7
master/bt5/slapos_payzen/SkinTemplateItem/portal_skins/slapos_payzen/PayzenEvent_processUpdate.py
...m/portal_skins/slapos_payzen/PayzenEvent_processUpdate.py
+79
-88
master/bt5/slapos_payzen/SkinTemplateItem/portal_skins/slapos_payzen/PayzenEvent_processUpdate.xml
.../portal_skins/slapos_payzen/PayzenEvent_processUpdate.xml
+1
-1
master/bt5/slapos_payzen/WorkflowTemplateItem/portal_workflow/payzen_interface_workflow/scripts/PayzenEvent_generateNavigationPage.py
...ce_workflow/scripts/PayzenEvent_generateNavigationPage.py
+1
-0
master/bt5/slapos_payzen/WorkflowTemplateItem/portal_workflow/payzen_interface_workflow/scripts/PayzenEvent_updateStatus.py
...en_interface_workflow/scripts/PayzenEvent_updateStatus.py
+4
-4
No files found.
master/bt5/slapos_payzen/SkinTemplateItem/portal_skins/slapos_payzen/PaymentTransaction_updateStatus.py
View file @
37a63546
from
DateTime
import
DateTime
from
DateTime
import
DateTime
state
=
context
.
getSimulationState
()
state
=
context
.
getSimulationState
()
if
(
state
!=
'started'
)
or
(
context
.
getPaymentMode
()
!=
'payzen'
):
#
if (state != 'started') or (context.getPaymentMode() != 'payzen'):
return
#
return
else
:
#
else:
_
,
transaction_id
=
context
.
PaymentTransaction_getPayzenId
()
_
,
transaction_id
=
context
.
PaymentTransaction_getPayzenId
()
if
transaction_id
is
not
None
:
if
transaction_id
is
not
None
:
# so the payment is registered in payzen
# so the payment is registered in payzen
context
.
PaymentTransaction_createPayzenEvent
().
updateStatus
()
context
.
PaymentTransaction_createPayzenEvent
().
updateStatus
()
master/bt5/slapos_payzen/SkinTemplateItem/portal_skins/slapos_payzen/PayzenEvent_processUpdate.py
View file @
37a63546
...
@@ -13,75 +13,70 @@ transaction = payzen_event.getDestinationValue()
...
@@ -13,75 +13,70 @@ transaction = payzen_event.getDestinationValue()
if
transaction
is
None
:
if
transaction
is
None
:
raise
ValueError
(
"Unable to find related transaction"
)
raise
ValueError
(
"Unable to find related transaction"
)
assert
signature
in
(
True
,
False
)
if
signature
is
False
:
# signature is wrong, bye bye
payzen_event
.
confirm
(
comment
=
'Signature does not match'
)
return
isTransitionPossible
=
context
.
getPortalObject
().
portal_workflow
.
isTransitionPossible
isTransitionPossible
=
context
.
getPortalObject
().
portal_workflow
.
isTransitionPossible
error_code
=
data_kw
[
'errorCode'
]
status
=
data_kw
[
'status'
]
if
error_code
==
'2'
:
answer
=
data_kw
[
'answer'
]
if
status
!=
"SUCCESS"
:
error_code
=
answer
[
"error_code"
]
if
error_code
==
"PSP_010"
:
# Transaction Not Found
transaction_date
,
_
=
transaction
.
PaymentTransaction_getPayzenId
()
transaction_date
,
_
=
transaction
.
PaymentTransaction_getPayzenId
()
# Mark on payment transaction history log that transaction was not processed yet
# Mark on payment transaction history log that transaction was not processed yet
payzen_event
.
confirm
()
payzen_event
.
confirm
()
payzen_event
.
acknowledge
(
comment
=
'Transaction not found on payzen side.'
)
payzen_event
.
acknowledge
(
comment
=
'Transaction not found on payzen side.'
)
if
int
(
DateTime
())
-
int
(
transaction_date
)
>
86400
:
#if int(DateTime()) - int(transaction_date) > 86400:
if
isTransitionPossible
(
transaction
,
'cancel'
):
# if isTransitionPossible(transaction, 'cancel'):
transaction
.
cancel
(
comment
=
'Aborting unknown payzen payment.'
)
# pass
else
:
# transaction.cancel(comment='Aborting unknown payzen payment.')
#else:
# Comment the last part until all transaction are using the new REST Api and order_id
storeWorkflowComment
(
transaction
,
storeWorkflowComment
(
transaction
,
'Error code 2 (Not found) did not changed the document state.'
)
'Error code PSP_010 (Not found) did not changed the document state.'
)
return
else
:
# Unknown errorCode
payzen_event
.
confirm
(
comment
=
'Unknown errorCode %r'
%
error_code
)
return
return
elif
error_code
==
'0'
:
transaction_list
=
answer
[
"transactions"
]
transaction_code_mapping
=
{
if
len
(
transaction_list
)
!=
1
:
'0'
:
'Initial (being treated)'
,
# Unexpected Number of Transactions
'1'
:
'To be validated '
,
payzen_event
.
confirm
(
comment
=
'Unexpected Number of Transaction for this order'
)
'2'
:
'To be forced - Contact issuer'
,
'3'
:
'To be validated and authorized'
,
'4'
:
'Waiting for submission'
,
'5'
:
'Waiting for authorization'
,
'6'
:
'Submitted'
,
'7'
:
'Expired'
,
'8'
:
'Refused'
,
'9'
:
'Cancelled'
,
'10'
:
'Waiting'
,
'11'
:
'Being submitted'
,
'12'
:
'Being authorized'
,
'13'
:
'Failed'
,
}
mark_transaction_id_list
=
[
'0'
,
'1'
,
'3'
,
'5'
,
'10'
,
'11'
,
'12'
]
continue_transaction_id_list
=
[
'4'
,
'6'
]
cancel_transaction_id_list
=
[
'8'
]
transaction_status
=
data_kw
[
'transactionStatus'
]
transaction_status_description
=
transaction_code_mapping
.
get
(
transaction_status
,
None
)
if
transaction_status_description
is
None
:
payzen_event
.
confirm
(
comment
=
'Unknown transactionStatus %r'
%
transaction_status
)
return
return
if
transaction_status
in
mark_transaction_id_list
:
transaction_kw
=
transaction_list
[
0
]
# See Full Status list at https://payzen.io/en-EN/rest/V4.0/api/kb/status_reference.html
mark_transaction_id_list
=
[
'AUTHORISED_TO_VALIDATE'
,
'WAITING_AUTHORISATION'
,
'WAITING_AUTHORISATION_TO_VALIDATE'
,
]
continue_transaction_id_list
=
[
'AUTHORISED'
,
'CAPTURED'
,
'PARTIALLY_AUTHORISED'
]
cancel_transaction_id_list
=
[
'REFUSED'
]
transaction_status
=
transaction_kw
[
'detailedStatus'
]
if
transaction_status
in
mark_transaction_id_list
:
# Mark on payment transaction history log that transaction was not processed yet
# Mark on payment transaction history log that transaction was not processed yet
storeWorkflowComment
(
transaction
,
'Transaction status %s (%s) did not changed the document state'
%
(
transaction_status
,
transaction_status_description
))
storeWorkflowComment
(
transaction
,
'Transaction status %s did not changed the document state'
%
(
transaction_status
))
payzen_event
.
confirm
()
payzen_event
.
confirm
()
payzen_event
.
acknowledge
(
comment
=
'Automatic acknowledge as result of correct communication'
)
payzen_event
.
acknowledge
(
comment
=
'Automatic acknowledge as result of correct communication'
)
if
isTransitionPossible
(
transaction
,
'confirm'
):
if
isTransitionPossible
(
transaction
,
'confirm'
):
transaction
.
confirm
(
comment
=
'Confirmed as really saw in PayZen.'
)
transaction
.
confirm
(
comment
=
'Confirmed as really saw in PayZen.'
)
elif
transaction_status
in
continue_transaction_id_list
:
elif
transaction_status
in
continue_transaction_id_list
:
# Check authAmount and authDevise and if match, stop transaction
# Check authAmount and authDevise and if match, stop transaction
auth_amount
=
int
(
data_kw
[
'authA
mount'
])
auth_amount
=
int
(
transaction_kw
[
'transactionDetails'
][
'cardDetails'
][
'authorizationResponse'
][
'a
mount'
])
auth_devise
=
data_kw
[
'authDevise
'
]
auth_devise
=
transaction_kw
[
'transactionDetails'
][
'cardDetails'
][
'authorizationResponse'
][
'currency
'
]
transaction_amount
=
int
((
round
(
transaction
.
PaymentTransaction_getTotalPayablePrice
(),
2
)
*
-
100
))
transaction_amount
=
int
((
round
(
transaction
.
PaymentTransaction_getTotalPayablePrice
(),
2
)
*
-
100
))
if
transaction_amount
!=
auth_amount
:
if
transaction_amount
!=
auth_amount
:
payzen_event
.
confirm
(
comment
=
'Received amount (%r) does not match stored on transaction (%r)'
%
(
auth_amount
,
transaction_amount
))
payzen_event
.
confirm
(
comment
=
'Received amount (%r) does not match stored on transaction (%r)'
%
(
auth_amount
,
transaction_amount
))
return
return
transaction_devise
=
transaction
.
getResourceValue
().
Currency_getIntegrationMapping
()
transaction_devise
=
transaction
.
getResourceReference
()
if
transaction_devise
!=
auth_devise
:
if
transaction_devise
!=
auth_devise
:
payzen_event
.
confirm
(
comment
=
'Received devise (%r) does not match stored on transaction (%r)'
%
(
auth_devise
,
transaction_devise
))
payzen_event
.
confirm
(
comment
=
'Received devise (%r) does not match stored on transaction (%r)'
%
(
auth_devise
,
transaction_devise
))
return
return
...
@@ -100,17 +95,13 @@ elif error_code == '0':
...
@@ -100,17 +95,13 @@ elif error_code == '0':
else
:
else
:
payzen_event
.
confirm
(
comment
=
'Expected to put transaction in stopped state, but achieved only %s state'
%
transaction
.
getSimulationState
())
payzen_event
.
confirm
(
comment
=
'Expected to put transaction in stopped state, but achieved only %s state'
%
transaction
.
getSimulationState
())
elif
transaction_status
in
cancel_transaction_id_list
:
elif
transaction_status
in
cancel_transaction_id_list
:
payzen_event
.
confirm
()
payzen_event
.
confirm
()
payzen_event
.
acknowledge
(
comment
=
'Refused payzen payment.'
)
payzen_event
.
acknowledge
(
comment
=
'Refused payzen payment.'
)
if
isTransitionPossible
(
transaction
,
'cancel'
):
if
isTransitionPossible
(
transaction
,
'cancel'
):
transaction
.
cancel
(
comment
=
'Aborting refused payzen payment.'
)
transaction
.
cancel
(
comment
=
'Aborting refused payzen payment.'
)
return
return
else
:
payzen_event
.
confirm
(
comment
=
'Transaction status %r (%r) is not supported'
\
%
(
transaction_status
,
transaction_status_description
))
return
else
:
else
:
# Unknown errorCode
payzen_event
.
confirm
(
comment
=
'Transaction status %r is not supported'
\
payzen_event
.
confirm
(
comment
=
'Unknown errorCode %r'
%
error_code
)
%
(
transaction_status
))
return
master/bt5/slapos_payzen/SkinTemplateItem/portal_skins/slapos_payzen/PayzenEvent_processUpdate.xml
View file @
37a63546
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
data_kw,
signature,
REQUEST=None
</string>
</value>
<value>
<string>
data_kw, REQUEST=None
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
...
...
master/bt5/slapos_payzen/WorkflowTemplateItem/portal_workflow/payzen_interface_workflow/scripts/PayzenEvent_generateNavigationPage.py
View file @
37a63546
...
@@ -29,6 +29,7 @@ payzen_dict = {
...
@@ -29,6 +29,7 @@ payzen_dict = {
'vads_amount'
:
str
(
int
(
round
((
payment_transaction
.
PaymentTransaction_getTotalPayablePrice
()
*
-
100
),
0
))),
'vads_amount'
:
str
(
int
(
round
((
payment_transaction
.
PaymentTransaction_getTotalPayablePrice
()
*
-
100
),
0
))),
'vads_trans_date'
:
now
.
toZone
(
'UTC'
).
asdatetime
().
strftime
(
'%Y%m%d%H%M%S'
),
'vads_trans_date'
:
now
.
toZone
(
'UTC'
).
asdatetime
().
strftime
(
'%Y%m%d%H%M%S'
),
'vads_trans_id'
:
transaction_id
,
'vads_trans_id'
:
transaction_id
,
'vads_order_id'
:
transaction_id
,
'vads_language'
:
'en'
,
'vads_language'
:
'en'
,
'vads_url_cancel'
:
vads_url_cancel
,
'vads_url_cancel'
:
vads_url_cancel
,
'vads_url_error'
:
vads_url_error
,
'vads_url_error'
:
vads_url_error
,
...
...
master/bt5/slapos_payzen/WorkflowTemplateItem/portal_workflow/payzen_interface_workflow/scripts/PayzenEvent_updateStatus.py
View file @
37a63546
...
@@ -6,20 +6,20 @@ if transaction_id is None:
...
@@ -6,20 +6,20 @@ if transaction_id is None:
raise
ValueError
(
'Transaction not registered in payzen integration tool'
)
raise
ValueError
(
'Transaction not registered in payzen integration tool'
)
payment_service
=
payzen_event
.
getSourceValue
(
portal_type
=
"Payzen Service"
)
payment_service
=
payzen_event
.
getSourceValue
(
portal_type
=
"Payzen Service"
)
data_kw
,
s
ignature
,
sent_text
,
received_text
=
payment_service
.
soap
_getInfo
(
data_kw
,
s
ent_text
,
received_text
=
payment_service
.
rest
_getInfo
(
transaction_date
.
toZone
(
'UTC'
).
asdatetime
(),
transaction_date
.
toZone
(
'UTC'
).
asdatetime
(),
transaction_id
)
transaction_id
)
# SENT
# SENT
sent
=
payzen_event
.
newContent
(
sent
=
payzen_event
.
newContent
(
title
=
'Sent
SOAP
'
,
title
=
'Sent
Data
'
,
portal_type
=
'Payzen Event Message'
,
portal_type
=
'Payzen Event Message'
,
text_content
=
sent_text
)
text_content
=
sent_text
)
# RECEIVED
# RECEIVED
payzen_event
.
newContent
(
payzen_event
.
newContent
(
title
=
'Received
SOAP
'
,
title
=
'Received
Data
'
,
portal_type
=
'Payzen Event Message'
,
portal_type
=
'Payzen Event Message'
,
text_content
=
received_text
,
text_content
=
received_text
,
predecessor_value
=
sent
)
predecessor_value
=
sent
)
payzen_event
.
PayzenEvent_processUpdate
(
data_kw
,
signature
)
payzen_event
.
PayzenEvent_processUpdate
(
data_kw
)
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