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
Labels
Merge Requests
17
Merge Requests
17
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
36591420
Commit
36591420
authored
Jan 29, 2018
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_payzen: Include script to redirect to Manual Payment from a Website.
parent
a6bae06d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
190 additions
and
0 deletions
+190
-0
master/bt5/slapos_payzen/SkinTemplateItem/portal_skins/slapos_payzen/PaymentTransaction_redirectToManualPayzenPayment.py
...ayzen/PaymentTransaction_redirectToManualPayzenPayment.py
+36
-0
master/bt5/slapos_payzen/SkinTemplateItem/portal_skins/slapos_payzen/PaymentTransaction_redirectToManualPayzenPayment.xml
...yzen/PaymentTransaction_redirectToManualPayzenPayment.xml
+62
-0
master/bt5/slapos_payzen/TestTemplateItem/portal_components/test.erp5.testSlapOSPayzenSkins.py
...Item/portal_components/test.erp5.testSlapOSPayzenSkins.py
+92
-0
No files found.
master/bt5/slapos_payzen/SkinTemplateItem/portal_skins/slapos_payzen/PaymentTransaction_redirectToManualPayzenPayment.py
0 → 100644
View file @
36591420
from
zExceptions
import
Unauthorized
portal
=
context
.
getPortalObject
()
person
=
portal
.
ERP5Site_getAuthenticatedMemberPersonValue
()
if
getattr
(
context
,
"PaymentTransaction_getVADSUrlDict"
,
None
)
is
None
:
raise
ValueError
(
"PaymentTransaction_getVADSUrlDict is missing on this site"
)
if
person
is
None
:
raise
Unauthorized
(
"Error"
)
def
wrapWithShadow
(
payment_transaction
,
person_relative_url
):
vads_url_dict
=
payment_transaction
.
PaymentTransaction_getVADSUrlDict
()
_
,
transaction_id
=
payment_transaction
.
PaymentTransaction_getPayzenId
()
vads_url_already_registered
=
vads_url_dict
.
pop
(
'vads_url_already_registered'
)
if
transaction_id
is
not
None
:
return
context
.
REQUEST
.
RESPONSE
.
redirect
(
vads_url_already_registered
)
system_event
=
payment_transaction
.
PaymentTransaction_createPayzenEvent
(
title
=
'User navigation script for %s'
%
payment_transaction
.
getTitle
(),
destination_section
=
person_relative_url
,
)
system_event
.
generateManualPaymentPage
(
**
vads_url_dict
)
return
system_event
.
contentValues
(
portal_type
=
"Payzen Event Message"
)[
0
].
getTextContent
()
return
person
.
Person_restrictMethodAsShadowUser
(
shadow_document
=
person
,
callable_object
=
wrapWithShadow
,
argument_list
=
[
context
,
person
.
getRelativeUrl
()])
master/bt5/slapos_payzen/SkinTemplateItem/portal_skins/slapos_payzen/PaymentTransaction_redirectToManualPayzenPayment.xml
0 → 100644
View file @
36591420
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
PaymentTransaction_redirectToManualPayzenPayment
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_payzen/TestTemplateItem/portal_components/test.erp5.testSlapOSPayzenSkins.py
View file @
36591420
...
...
@@ -620,6 +620,98 @@ class TestSlapOSPayzenAccountingTransaction_getPaymentState(
line
.
setGroupingReference
(
"TEST%s"
%
self
.
new_id
)
self
.
assertEquals
(
"Paid"
,
invoice
.
AccountingTransaction_getPaymentState
())
class
TestSlapOSPayzenPaymentTransaction_redirectToManualPayzenPayment
(
SlapOSTestCaseMixinWithAbort
):
def
test_PaymentTransaction_redirectToManualPayzenPayment
(
self
):
payment
=
self
.
createPaymentTransaction
()
self
.
assertRaises
(
ValueError
,
payment
.
PaymentTransaction_redirectToManualPayzenPayment
)
def
_simulatePaymentTransaction_getVADSUrlDict
(
self
):
script_name
=
'PaymentTransaction_getVADSUrlDict'
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
raise
ValueError
(
'Precondition failed: %s exists in custom'
%
script_name
)
createZODBPythonScript
(
self
.
portal
.
portal_skins
.
custom
,
script_name
,
'*args, **kwargs'
,
'# Script body
\
n
'
"""payment_transaction_url = context.getRelativeUrl()
return dict(vads_url_already_registered="%s/already_registered" % (payment_transaction_url),
vads_url_cancel="%s/cancel" % (payment_transaction_url),
vads_url_error="%s/error" % (payment_transaction_url),
vads_url_referral="%s/referral" % (payment_transaction_url),
vads_url_refused="%s/refused" % (payment_transaction_url),
vads_url_success="%s/success" % (payment_transaction_url),
vads_url_return="%s/return" % (payment_transaction_url),
)"""
)
def
_dropPaymentTransaction_getVADSUrlDict
(
self
):
script_name
=
'PaymentTransaction_getVADSUrlDict'
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
self
.
portal
.
portal_skins
.
custom
.
manage_delObjects
(
script_name
)
def
test_PaymentTransaction_redirectToManualPayzenPayment_unauthorzied
(
self
):
payment
=
self
.
createPaymentTransaction
()
self
.
_simulatePaymentTransaction_getVADSUrlDict
()
try
:
self
.
assertRaises
(
Unauthorized
,
payment
.
PaymentTransaction_redirectToManualPayzenPayment
)
finally
:
self
.
_dropPaymentTransaction_getVADSUrlDict
()
def
test_PaymentTransaction_redirectToManualPayzenPayment_redirect
(
self
):
person
=
self
.
makePerson
()
invoice
=
self
.
createPayzenSaleInvoiceTransaction
(
destination_section
=
person
.
getRelativeUrl
())
self
.
tic
()
payment
=
invoice
.
SaleInvoiceTransaction_getPayzenPaymentRelatedValue
()
payment
.
setResourceValue
(
self
.
portal
.
currency_module
.
EUR
)
self
.
tic
()
self
.
login
(
person
.
getUserId
())
self
.
_simulatePaymentTransaction_getVADSUrlDict
()
try
:
text_content
=
payment
.
PaymentTransaction_redirectToManualPayzenPayment
()
finally
:
self
.
_dropPaymentTransaction_getVADSUrlDict
()
payment_transaction_url
=
payment
.
getRelativeUrl
()
for
item
in
[
"vads_site_id"
,
payment_transaction_url
,
"vads_url_cancel"
,
"%s/cancel"
%
(
payment_transaction_url
),
"vads_url_error"
,
"%s/error"
%
(
payment_transaction_url
),
"vads_url_referral"
,
"%s/referral"
%
(
payment_transaction_url
),
"vads_url_refused"
,
"%s/refused"
%
(
payment_transaction_url
),
"vads_url_success"
,
"%s/success"
%
(
payment_transaction_url
),
"vads_url_return"
,
"%s/return"
%
(
payment_transaction_url
)]:
self
.
assertTrue
(
item
in
text_content
,
"%s not in %s"
%
(
item
,
text_content
))
def
test_PaymentTransaction_redirectToManualPayzenPayment_already_registered
(
self
):
person
=
self
.
makePerson
()
invoice
=
self
.
createPayzenSaleInvoiceTransaction
(
destination_section
=
person
.
getRelativeUrl
())
self
.
tic
()
payment
=
invoice
.
SaleInvoiceTransaction_getPayzenPaymentRelatedValue
()
payment
.
setResourceValue
(
self
.
portal
.
currency_module
.
EUR
)
payment
.
PaymentTransaction_generatePayzenId
()
self
.
tic
()
self
.
login
(
person
.
getUserId
())
self
.
_simulatePaymentTransaction_getVADSUrlDict
()
try
:
redirect
=
payment
.
PaymentTransaction_redirectToManualPayzenPayment
()
finally
:
self
.
_dropPaymentTransaction_getVADSUrlDict
()
self
.
assertEquals
(
"%s/already_registered"
%
payment
.
getRelativeUrl
(),
redirect
)
class
TestSlapOSPayzenSaleInvoiceTransaction_getPayzenPaymentRelatedValue
(
SlapOSTestCaseMixinWithAbort
):
...
...
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