コード例 #1
0
def getjspayparam(request):
    try:
        api_pub = JsApi_pub()
        neworder = UnifiedOrder_pub()
        #"out_trade_no", "body", "total_fee", "notify_url", "trade_type"
        trade_no = uuid.uuid4().get_hex()
        neworder.setParameter('out_trade_no', trade_no)
        neworder.setParameter('body', u'e食部落美食')
        #wni: below is for weixin pay test
        #neworder.setParameter('total_fee','1')
        #neworder.setParameter('total_fee',str(request.session.order.total*100))
        #neworder.setParameter('total_fee',str(float(request.session['order']['total']*100)))
        #tmp_total = request.session['order'].get_tmp_total(request)

        order_vars = _order_totals({"request": request})
        #print order_vars["order_total"]
        #neworder.setParameter('total_fee',str(request.session['wni_wxpay_total']*100))
        neworder.setParameter('total_fee',
                              str(int(order_vars['order_total'] * 100)))
        neworder.setParameter('trade_type', 'JSAPI')
        neworder.setParameter('openid', request.session['openid'])
        neworder.setParameter(
            'notify_url', 'http://%s/weixin/payback' % settings.SITE_DOMAIN)
    except Exception, e:
        with open('/tmp/wni.log', 'a') as f:
            f.write('order part exception:%s\n' % str(e))
            f.write('request.order is:%s\n' % str(request.session['order']))
            f.write('request.cart is:%s\n' % str(request.session['cart']))
コード例 #2
0
ファイル: views.py プロジェクト: Gokhu18/ecommerce-1
def get_paypal_params(request):
    """
    A function to construct JSON variable from the request object.

    The constructed object is then passed to Paypal Chechout button renderer.
    The variable is passed to the js function from the cart.html template.
    """
    items = []
    ot = _order_totals({'request': request})
    shipping = ot.get("shipping_total")
    tax = ot.get("tax_total")
    subtotal = float(request.cart.total_price())
    total = float(ot.get('order_total'))
    for item in request.cart:
        items.append({
            'name': item.description, 'quantity': item.quantity,
            'price': float(item.unit_price), 'sku': item.sku,
            'currency': 'USD'
        })
    transactions = [{
        'amount': {
            'total': total,
            'currency': 'USD',
            'details': {
                'subtotal': subtotal,
                'tax': tax,
                'shipping': shipping
            }
        },
        'item_list': {
            'items': items
        }
    }]
    data = {
        'transactions': transactions,
        'note_to_payer': 'Please contact us for any questions with the order.'
    }
    return json.dumps(data)
コード例 #3
0
def order_totals_offcanvas(context):
    """
    Off-canvas version of order_totals.
    """
    return _order_totals(context)
コード例 #4
0
def my_order_totals(context):
    context = _order_totals(context)
    context['personalization_total'] = context['request'].session.get('personalization_total', '0.0')
    context['order_total'] += Decimal(str(context.get('personalization_total', '0.0')))
    return context
コード例 #5
0
def order_totals_text(context):
    """
    Text version of order_totals.
    """
    return _order_totals(context)
コード例 #6
0
def order_totals_in_table(context):
    """
    HTML version of order_totals.
    """
    return _order_totals(context)
コード例 #7
0
def get_total(context):
    """Return order total."""
    ot = _order_totals(context)
    total = ot.get('order_total')
    return total
コード例 #8
0
def order_total(context):
    """
    HTML version of order_totals.
    """
    return _order_totals(context)