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
Boxiang Sun
slapos.core
Commits
b24cd627
Commit
b24cd627
authored
Oct 02, 2019
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: slapos_subscription_request: Check the currency to determine the payment method
parent
08948d2a
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
42 additions
and
24 deletions
+42
-24
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscription.py
..._request/SubscriptionRequestModule_requestSubscription.py
+1
-1
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscription.xml
...request/SubscriptionRequestModule_requestSubscription.xml
+1
-1
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscriptionProxy.py
...est/SubscriptionRequestModule_requestSubscriptionProxy.py
+26
-14
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscriptionProxy.xml
...st/SubscriptionRequestModule_requestSubscriptionProxy.xml
+1
-1
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_applyCondition.py
...ubscription_request/SubscriptionRequest_applyCondition.py
+2
-2
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_createRelatedSaleInvoiceTransaction.py
...ubscriptionRequest_createRelatedSaleInvoiceTransaction.py
+4
-1
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_createRelatedSaleInvoiceTransaction.xml
...bscriptionRequest_createRelatedSaleInvoiceTransaction.xml
+1
-1
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_requestPaymentTransaction.py
..._request/SubscriptionRequest_requestPaymentTransaction.py
+5
-2
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_requestPaymentTransaction.xml
...request/SubscriptionRequest_requestPaymentTransaction.xml
+1
-1
No files found.
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscription.py
View file @
b24cd627
...
@@ -19,6 +19,6 @@ user_input_dict = {
...
@@ -19,6 +19,6 @@ user_input_dict = {
"amount"
:
amount
}
"amount"
:
amount
}
return
context
.
SubscriptionRequestModule_requestSubscriptionProxy
(
return
context
.
SubscriptionRequestModule_requestSubscriptionProxy
(
default_email_text
,
subscription_reference
,
payment_mode
,
default_email_text
,
subscription_reference
,
confirmation_required
=
bool
(
confirmation_required
),
confirmation_required
=
bool
(
confirmation_required
),
user_input_dict
=
user_input_dict
,
batch_mode
=
0
)
user_input_dict
=
user_input_dict
,
batch_mode
=
0
)
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscription.xml
View file @
b24cd627
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
name=None, default_email_text=None,
payment_mode=None,
subscription_reference=None, amount=0, confirmation_required=True, REQUEST=None, **kw
</string>
</value>
<value>
<string>
name=None, default_email_text=None, subscription_reference=None, amount=0, confirmation_required=True, REQUEST=None, **kw
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
...
...
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscriptionProxy.py
View file @
b24cd627
...
@@ -7,9 +7,8 @@ if REQUEST is not None:
...
@@ -7,9 +7,8 @@ if REQUEST is not None:
person
,
person_is_new
=
context
.
SubscriptionRequest_createUser
(
email
,
user_input_dict
[
'name'
])
person
,
person_is_new
=
context
.
SubscriptionRequest_createUser
(
email
,
user_input_dict
[
'name'
])
web_site
=
context
.
getWebSiteValue
()
web_site
=
context
.
getWebSiteValue
()
# Check if user is already exist, otherwise redirect to ask confirmation
# if payment mode not selected, ask user to confirm and select one.
if
confirmation_required
and
not
person_is_new
:
if
not
payment_mode
:
base_url
=
web_site
.
absolute_url
()
base_url
=
web_site
.
absolute_url
()
return
context
.
REQUEST
.
RESPONSE
.
redirect
(
return
context
.
REQUEST
.
RESPONSE
.
redirect
(
...
@@ -28,17 +27,16 @@ subscription_request = context.subscription_request_module.newContent(
...
@@ -28,17 +27,16 @@ subscription_request = context.subscription_request_module.newContent(
subscription_request
.
setDefaultEmailText
(
email
)
subscription_request
.
setDefaultEmailText
(
email
)
def
wrapWithShadow
(
subscription_request
,
amount
,
subscription_reference
,
payment_mode
):
def
wrapWithShadow
(
subscription_request
,
amount
,
subscription_reference
):
subscription_request
.
activate
(
tag
=
"subscription_condition_%s"
%
subscription_request
.
getId
()
subscription_request
.
activate
(
tag
=
"subscription_condition_%s"
%
subscription_request
.
getId
()
).
SubscriptionRequest_applyCondition
(
subscription_reference
)
).
SubscriptionRequest_applyCondition
(
subscription_reference
)
return
subscription_request
.
SubscriptionRequest_requestPaymentTransaction
(
amount
=
amount
,
return
subscription_request
.
SubscriptionRequest_requestPaymentTransaction
(
amount
=
amount
,
tag
=
"subscription_%s"
%
subscription_request
.
getId
()
,
payment_mode
=
payment_mode
)
tag
=
"subscription_%s"
%
subscription_request
.
getId
())
payment
=
person
.
Person_restrictMethodAsShadowUser
(
payment
=
person
.
Person_restrictMethodAsShadowUser
(
shadow_document
=
person
,
shadow_document
=
person
,
callable_object
=
wrapWithShadow
,
callable_object
=
wrapWithShadow
,
argument_list
=
[
subscription_request
,
user_input_dict
[
"amount"
],
subscription_reference
,
payment_mode
])
argument_list
=
[
subscription_request
,
user_input_dict
[
"amount"
],
subscription_reference
])
if
batch_mode
:
if
batch_mode
:
return
{
'subscription'
:
subscription_request
.
getRelativeUrl
(),
'payment'
:
payment
.
getRelativeUrl
()
}
return
{
'subscription'
:
subscription_request
.
getRelativeUrl
(),
'payment'
:
payment
.
getRelativeUrl
()
}
...
@@ -51,18 +49,32 @@ price = person.Person_restrictMethodAsShadowUser(
...
@@ -51,18 +49,32 @@ price = person.Person_restrictMethodAsShadowUser(
callable_object
=
wrapGetPriceWithShadow
,
callable_object
=
wrapGetPriceWithShadow
,
argument_list
=
[
payment
,])
argument_list
=
[
payment
,])
if
payment_mode
==
"wechat"
:
# currency = subscription_request.getSpecialiseValue().getPriceCurrency()
# XXX: Test
# currency = "currency_module/EUR"
currency
=
"currency_module/CNY"
if
currency
==
"currency_module/CNY"
:
# Wechat payment
'''
portal = context.getPortalObject()
portal = context.getPortalObject()
code_url = portal.Base_getWechatCodeURL(subscription_request.getId(), price, user_input_dict["amount"])
code_url = portal.Base_getWechatCodeURL(subscription_request.getId(), price, user_input_dict["amount"])
web_site = context.getWebSiteValue()
web_site = context.getWebSiteValue()
base_url = web_site.absolute_url()
base_url = web_site.absolute_url()
return context.REQUEST.RESPONSE.redirect(
return context.REQUEST.RESPONSE.redirect(
"%s/#wechat_payment?amount=%s&trade_no=%s&code_url=%s" % (base_url, user_input_dict["amount"], subscription_request.getId(), code_url))
"%s/#wechat_payment?amount=%s&trade_no=%s&code_url=%s" % (base_url, user_input_dict["amount"], subscription_request.getId(), code_url))
'''
def
wrapRedirectWithShadow
(
payment_transaction
,
web_site
):
return
payment_transaction
.
PaymentTransaction_redirectToWechatPayment
(
web_site
)
def
wrapRedirectWithShadow
(
payment_transaction
,
web_site
):
return
person
.
Person_restrictMethodAsShadowUser
(
return
payment_transaction
.
PaymentTransaction_redirectToManualPayzenPayment
(
web_site
)
shadow_document
=
person
,
callable_object
=
wrapRedirectWithShadow
,
argument_list
=
[
payment
,
web_site
])
else
:
# "currency_module/EUR", Payzen payment
def
wrapRedirectWithShadow
(
payment_transaction
,
web_site
):
return
payment_transaction
.
PaymentTransaction_redirectToManualPayzenPayment
(
web_site
)
return
person
.
Person_restrictMethodAsShadowUser
(
return
person
.
Person_restrictMethodAsShadowUser
(
shadow_document
=
person
,
shadow_document
=
person
,
callable_object
=
wrapRedirectWithShadow
,
callable_object
=
wrapRedirectWithShadow
,
argument_list
=
[
payment
,
web_site
])
argument_list
=
[
payment
,
web_site
])
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscriptionProxy.xml
View file @
b24cd627
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
email, subscription_reference,
payment_mode=None,
confirmation_required=False, user_input_dict={}, batch_mode=True, REQUEST=None
</string>
</value>
<value>
<string>
email, subscription_reference, confirmation_required=False, user_input_dict={}, batch_mode=True, REQUEST=None
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
_proxy_roles
</string>
</key>
<key>
<string>
_proxy_roles
</string>
</key>
...
...
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_applyCondition.py
View file @
b24cd627
...
@@ -11,7 +11,7 @@ if subscription_condition_reference is not None:
...
@@ -11,7 +11,7 @@ if subscription_condition_reference is not None:
subscription_condition
=
context
.
portal_catalog
.
getResultValue
(
subscription_condition
=
context
.
portal_catalog
.
getResultValue
(
portal_type
=
"Subscription Condition"
,
portal_type
=
"Subscription Condition"
,
reference
=
subscription_condition_reference
,
reference
=
subscription_condition_reference
,
validation_state
=
"
validated"
)
validation_state
=
"
published"
)
# XXX Wechat workaround, validated?
else
:
else
:
subscription_condition
=
context
.
getSpecialiseValue
()
subscription_condition
=
context
.
getSpecialiseValue
()
...
@@ -36,7 +36,7 @@ context.edit(
...
@@ -36,7 +36,7 @@ context.edit(
root_slave
=
subscription_condition
.
getRootSlave
(),
root_slave
=
subscription_condition
.
getRootSlave
(),
specialise_value
=
subscription_condition
,
specialise_value
=
subscription_condition
,
price
=
subscription_condition
.
getPrice
(),
price
=
subscription_condition
.
getPrice
(),
price_currency
=
subscription_condition
.
getPriceCurrency
()
price_currency
=
"currency_module/CNY"
,
# For test!!!
subscription_condition.getPriceCurrency()
)
)
context
.
setSourceReference
(
subscription_condition
.
getSourceReference
())
context
.
setSourceReference
(
subscription_condition
.
getSourceReference
())
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_createRelatedSaleInvoiceTransaction.py
View file @
b24cd627
...
@@ -7,7 +7,10 @@ portal = context.getPortalObject()
...
@@ -7,7 +7,10 @@ portal = context.getPortalObject()
current_invoice
=
context
.
getCausalityValue
()
current_invoice
=
context
.
getCausalityValue
()
if
current_invoice
is
None
:
if
current_invoice
is
None
:
if
payment_mode
==
"wechat"
:
# currency = context.getSpecialiseValue().getPriceCurrency()
# currency = "currency_module/EUR"
currency
=
"currency_module/CNY"
if
currency
==
"currency_module/CNY"
:
# Wechat payment
invoice_template_path
=
"accounting_module/template_wechat_pre_payment_subscription_sale_invoice_transaction"
invoice_template_path
=
"accounting_module/template_wechat_pre_payment_subscription_sale_invoice_transaction"
else
:
else
:
invoice_template_path
=
"accounting_module/template_pre_payment_subscription_sale_invoice_transaction"
invoice_template_path
=
"accounting_module/template_pre_payment_subscription_sale_invoice_transaction"
...
...
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_createRelatedSaleInvoiceTransaction.xml
View file @
b24cd627
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
amount, tag, payment,
payment_mode=None,
REQUEST=None
</string>
</value>
<value>
<string>
amount, tag, payment, REQUEST=None
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
_proxy_roles
</string>
</key>
<key>
<string>
_proxy_roles
</string>
</key>
...
...
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_requestPaymentTransaction.py
View file @
b24cd627
...
@@ -9,7 +9,10 @@ current_payment = None
...
@@ -9,7 +9,10 @@ current_payment = None
if
current_invoice
is
None
:
if
current_invoice
is
None
:
# Hardcoded value for reservation
# Hardcoded value for reservation
if
payment_mode
==
"wechat"
:
# currency = context.getSpecialiseValue().getPriceCurrency()
# XXX: Test for now
currency
=
"currency_module/CNY"
if
currency
==
"currency_module/CNY"
:
# Wechat payment
payment_template
=
portal
.
restrictedTraverse
(
"accounting_module/slapos_wechat_pre_payment_template"
)
payment_template
=
portal
.
restrictedTraverse
(
"accounting_module/slapos_wechat_pre_payment_template"
)
quantity
=
int
(
amount
)
*
188
quantity
=
int
(
amount
)
*
188
else
:
else
:
...
@@ -43,6 +46,6 @@ if current_invoice is None:
...
@@ -43,6 +46,6 @@ if current_invoice is None:
context
.
reindexObject
(
activate_kw
=
{
'tag'
:
tag
})
context
.
reindexObject
(
activate_kw
=
{
'tag'
:
tag
})
context
.
activate
(
tag
=
tag
).
SubscriptionRequest_createRelatedSaleInvoiceTransaction
(
context
.
activate
(
tag
=
tag
).
SubscriptionRequest_createRelatedSaleInvoiceTransaction
(
amount
,
tag
,
current_payment
.
getRelativeUrl
()
,
payment_mode
)
amount
,
tag
,
current_payment
.
getRelativeUrl
())
return
current_payment
return
current_payment
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_requestPaymentTransaction.xml
View file @
b24cd627
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
amount, tag,
payment_mode=None,
REQUEST=None
</string>
</value>
<value>
<string>
amount, tag, REQUEST=None
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
_proxy_roles
</string>
</key>
<key>
<string>
_proxy_roles
</string>
</key>
...
...
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