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
Thomas Gambier
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
state
=
context
.
getSimulationState
()
if
(
state
!=
'started'
)
or
(
context
.
getPaymentMode
()
!=
'payzen'
):
return
else
:
_
,
transaction_id
=
context
.
PaymentTransaction_getPayzenId
()
#
if (state != 'started') or (context.getPaymentMode() != 'payzen'):
#
return
#
else:
_
,
transaction_id
=
context
.
PaymentTransaction_getPayzenId
()
if
transaction_id
is
not
None
:
if
transaction_id
is
not
None
:
# so the payment is registered in payzen
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()
if
transaction
is
None
:
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
error_code
=
data_kw
[
'errorCode'
]
if
error_code
==
'2'
:
status
=
data_kw
[
'status'
]
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
()
# Mark on payment transaction history log that transaction was not processed yet
payzen_event
.
confirm
()
payzen_event
.
acknowledge
(
comment
=
'Transaction not found on payzen side.'
)
if
int
(
DateTime
())
-
int
(
transaction_date
)
>
86400
:
if
isTransitionPossible
(
transaction
,
'cancel'
):
transaction
.
cancel
(
comment
=
'Aborting unknown payzen payment.'
)
else
:
#if int(DateTime()) - int(transaction_date) > 86400:
# if isTransitionPossible(transaction, 'cancel'):
# pass
# 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
,
'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
elif
error_code
==
'0'
:
transaction_code_mapping
=
{
'0'
:
'Initial (being treated)'
,
'1'
:
'To be validated '
,
'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
)
transaction_list
=
answer
[
"transactions"
]
if
len
(
transaction_list
)
!=
1
:
# Unexpected Number of Transactions
payzen_event
.
confirm
(
comment
=
'Unexpected Number of Transaction for this order'
)
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
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
.
acknowledge
(
comment
=
'Automatic acknowledge as result of correct communication'
)
if
isTransitionPossible
(
transaction
,
'confirm'
):
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
auth_amount
=
int
(
data_kw
[
'authA
mount'
])
auth_devise
=
data_kw
[
'authDevise
'
]
auth_amount
=
int
(
transaction_kw
[
'transactionDetails'
][
'cardDetails'
][
'authorizationResponse'
][
'a
mount'
])
auth_devise
=
transaction_kw
[
'transactionDetails'
][
'cardDetails'
][
'authorizationResponse'
][
'currency
'
]
transaction_amount
=
int
((
round
(
transaction
.
PaymentTransaction_getTotalPayablePrice
(),
2
)
*
-
100
))
if
transaction_amount
!=
auth_amount
:
payzen_event
.
confirm
(
comment
=
'Received amount (%r) does not match stored on transaction (%r)'
%
(
auth_amount
,
transaction_amount
))
return
transaction_devise
=
transaction
.
getResourceValue
().
Currency_getIntegrationMapping
()
transaction_devise
=
transaction
.
getResourceReference
()
if
transaction_devise
!=
auth_devise
:
payzen_event
.
confirm
(
comment
=
'Received devise (%r) does not match stored on transaction (%r)'
%
(
auth_devise
,
transaction_devise
))
return
...
...
@@ -100,17 +95,13 @@ elif error_code == '0':
else
:
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
.
acknowledge
(
comment
=
'Refused payzen payment.'
)
if
isTransitionPossible
(
transaction
,
'cancel'
):
transaction
.
cancel
(
comment
=
'Aborting refused payzen payment.'
)
return
else
:
payzen_event
.
confirm
(
comment
=
'Transaction status %r (%r) is not supported'
\
%
(
transaction_status
,
transaction_status_description
))
return
else
:
# Unknown errorCode
payzen_event
.
confirm
(
comment
=
'Unknown errorCode %r'
%
error_code
)
payzen_event
.
confirm
(
comment
=
'Transaction status %r is not supported'
\
%
(
transaction_status
))
return
master/bt5/slapos_payzen/SkinTemplateItem/portal_skins/slapos_payzen/PayzenEvent_processUpdate.xml
View file @
37a63546
...
...
@@ -50,7 +50,7 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
data_kw,
signature,
REQUEST=None
</string>
</value>
<value>
<string>
data_kw, REQUEST=None
</string>
</value>
</item>
<item>
<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 = {
'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_id'
:
transaction_id
,
'vads_order_id'
:
transaction_id
,
'vads_language'
:
'en'
,
'vads_url_cancel'
:
vads_url_cancel
,
'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:
raise
ValueError
(
'Transaction not registered in payzen integration tool'
)
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_id
)
# SENT
sent
=
payzen_event
.
newContent
(
title
=
'Sent
SOAP
'
,
title
=
'Sent
Data
'
,
portal_type
=
'Payzen Event Message'
,
text_content
=
sent_text
)
# RECEIVED
payzen_event
.
newContent
(
title
=
'Received
SOAP
'
,
title
=
'Received
Data
'
,
portal_type
=
'Payzen Event Message'
,
text_content
=
received_text
,
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