Commit cb523ac3 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_advanced_ecommerce: add wechat payment

parent 4fe39328
<?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>trade_no,**kw</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSection_checkWechatPaymentStatus</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -38,4 +38,5 @@ for amount in sale_order.getAggregatedAmountList():
# clean up shopping cart
context.WebSection_resetShoppingCart()
# Display nice message
context.Base_redirect('SaleOrder_viewThankYouMessage')
if not batch_mode:
context.Base_redirect('SaleOrder_viewThankYouMessage')
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
<value> <string>batch_mode=False</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>your_wechat_payment</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSection_viewWechatPayment</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>WebSection_viewWechatPayment</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<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_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSection_viewWechatPaymentWidget</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<tal:block tal:define="payment_url python: request.get('payment_url', '');
price python: int(request.get('price', '0')) / 100.0;
trade_no python: request.get('trade_no', '')
" >
<p>请使用微信扫描下方二维码来完成支付</p>
<input id='trade_no' type="hidden" tal:attributes="value python: trade_no">
<h2 style="float:left;">支付 <span tal:content="python: price"></span> 元</h2>
<div style="clear:both"></div>
<div style="position:absolute;left:50%;">
<div class='qr_code' position='relative'>
<div class="qr_code_wrapper" style="line-height: 300px;
display:none;
text-align: center;
position: absolute;
font-size: 14px;
color: #fff;
background: rgba(0,0,0,.6);
width: 300px;
height: 300px;
cursor: pointer;">
<span style='display: block;font-size: 14px;color: #fff;margin-top: 10px;'>请点击继续</span>
</div>
<img class="wechat_qrcode" width="294" style="border: 1px solid grey;"
tal:attributes="src python:'Base_generateBarcodeImage?barcode_type=qrcode&data=%s' % payment_url">
</div>
<img src="advanced_ecommerce_image/wechat_description.png" width="300">
</div>
<script>
$(document).ready(function() {
var timer = 0,
wrapper = $(".qr_code_wrapper"),
trade_no = $('#trade_no').val(),
loop;
function restartCheckingIfNeeded() {
timer += 1;
if (timer > 40) {
wrapper.css("display", "block");
} else {
console.log('restart')
setTimeout(checkPaymentStatus, 3000);
}
}
function checkPaymentStatus(){
$.ajax({
url:'WebSection_checkWechatPaymentStatus',
data:{
trade_no: trade_no
},
success:function(result_dict){
result_dict = JSON.parse(result_dict);
if (result_dict['status'] == 'success') {
window.location.href="SaleOrder_viewThankYouMessage";
} else if (result_dict['status'] == 'cancelled') {
window.location.href="?portal_status_message=订单已取消"
} else {
restartCheckingIfNeeded();
}
},
error: function (error){
console.log(error);
restartCheckingIfNeeded();
}
});
}
checkPaymentStatus()
wrapper.click(function() {
timer = 0;
wrapper.css("display", "none");
setTimeout(checkPaymentStatus, 3000)
});
});
</script>
</tal:block>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Image" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string>wechat_description.png</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <int>86</int> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <int>260</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Image" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string>wechat_image.png</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/png</string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <int>86</int> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <int>103</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -9,7 +9,9 @@
<item>
<key> <string>delegated_list</string> </key>
<value>
<list/>
<list>
<string>enabled</string>
</list>
</value>
</item>
<item>
......@@ -50,6 +52,12 @@
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>enabled</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
......@@ -69,6 +77,10 @@
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>cart_box</string> </value>
......@@ -87,4 +99,17 @@
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: not request.get(\'payment_url\', None) and len(here.SaleOrder_getShoppingCartItemList())</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment