• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python dynamic.lookup_url函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中satchmo_utils.dynamic.lookup_url函数的典型用法代码示例。如果您正苦于以下问题:Python lookup_url函数的具体用法?Python lookup_url怎么用?Python lookup_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了lookup_url函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: one_step

def one_step(request):
    payment_module = config_get_group('PAYMENT_AUTOSUCCESS')

    #First verify that the customer exists
    try:
        contact = Contact.objects.from_request(request, create=False)
    except Contact.DoesNotExist:
        url = lookup_url(payment_module, 'satchmo_checkout-step1')
        return HttpResponseRedirect(url)
    #Verify we still have items in the cart
    tempCart = Cart.objects.from_request(request)
    if tempCart.numItems == 0:
        template = lookup_template(payment_module, 'shop/checkout/empty_cart.html')
        return render_to_response(template,
                                  context_instance=RequestContext(request))

    # Create a new order
    newOrder = Order(contact=contact)
    pay_ship_save(newOrder, tempCart, contact,
        shipping="", discount="", notes="")
        
    request.session['orderID'] = newOrder.id
    
    processor = get_processor_by_key('PAYMENT_AUTOSUCCESS')
    processor.prepare_data(newOrder)
    payment = processor.process(newOrder)
        
    tempCart.empty()
    success = lookup_url(payment_module, 'satchmo_checkout-success')
    return HttpResponseRedirect(success)
开发者ID:eyeyunianto,项目名称:satchmo,代码行数:30,代码来源:views.py


示例2: get_payment

def get_payment(request):
    payment_module = config_get_group('PAYMENT_PAYMENTSPRO')
    
    # get necessary order info from satchmo
    try:
        order = Order.objects.from_request(request)
    except Order.DoesNotExist:
        url = lookup_url(payment_module, 'satchmo_checkout-step1')
        return redirect(url)
     
    # now some context hacking:
    order_sub_total = order.sub_total + order.shipping_cost
    
    current_site = Site.objects.get_current().domain
    url = request.build_absolute_uri().split('?')[0]
    if settings.PAYPAL_CHECKOUT_SECURE:
        log.debug("secure paypal checkout")
        url = url.replace('http://', 'https://')
    log.debug("paypal express check out url: {0}".format(url))
    #url = "http://" + current_site + reverse('PAYMENTSPRO_satchmo_checkout-step3')
    
    # === now the django-paypal stuff ===
    
    # Fix of the 0.01 balance problem. 
    # Bug: The payment amount sent to paypal, when formatted to two floating 
    # points, was rounded, but the order.total is not. This would sometimes 
    # cause a balance in 0 < balance < 0.01 which translated to a balance of 
    # 0.01 to remain on the order.
    amt = "{0:.2f}".format(order.total)
    diff = order.total - Decimal(amt)
    if diff > Decimal("0") and diff < Decimal("0.01"):
        order.total = Decimal(amt)
        order.save()
    
    item = {
        "amt": amt,
        "invnum": order.id,
        "cancelurl": url,
        "returnurl": url,
        "currencycode": payment_module.CURRENCY_CODE.value,
        "paymentaction": "Authorization",
        }
    
    kw = { 
        "item": item,
        "payment_form_cls": SatchmoPaymentsProPaymentForm,
        "payment_template": "shop/checkout/paymentspro/payment.html",
        "confirm_template": "shop/checkout/paymentspro/confirm.html",
        "success_url": lookup_url(payment_module, 
                                  'satchmo_checkout-success'),
        "context": {"order": order, "order_sub_total": order_sub_total }}
    
    
    ppp = PayPalPro(**kw)
    return ppp(request)
开发者ID:marconius,项目名称:Satchmo-PayPal--PaymentsPro-,代码行数:55,代码来源:views.py


示例3: _cart_xml

    def _cart_xml(self, order):
        template = get_template(self.settings["CART_XML_TEMPLATE"].value)

        shopping_url = lookup_url(self.settings, 'satchmo_checkout-success', True, self.settings.SSL.value)
        edit_url = lookup_url(self.settings, 'satchmo_cart', True, self.settings.SSL.value)
        ctx = Context({"order" : order,
                       "continue_shopping_url" : shopping_url,
                       "edit_cart_url" : edit_url,
                       "currency" : self.settings.CURRENCY_CODE.value,
                       })
        return template.render(ctx)
开发者ID:jtslade,项目名称:satchmo-svn,代码行数:11,代码来源:views.py


示例4: credit_pay_ship_process_form

def credit_pay_ship_process_form(request, contact, working_cart, payment_module, *args, **kwargs):
    """Handle the form information.
    Returns:
        (True, destination) on success
        (False, form) on failure
    """
    
    def _get_form(request, payment_module, *args, **kwargs):
        processor = payment_module.MODULE.load_module('processor')
        log.debug('processor=%s', processor)
        if hasattr(processor, 'FORM'):
            log.debug('getting form from module')
            formclass = processor.FORM
        else:
            log.debug('using default form')
            formclass = CreditPayShipForm
        
        form = formclass(request, payment_module, *args, **kwargs)
        return form

    if request.method == "POST":
        new_data = request.POST.copy()
        
        form = _get_form(request, payment_module, new_data, *args, **kwargs)
        if form.is_valid():
            form.save(request, working_cart, contact, payment_module)
            url = lookup_url(payment_module, 'satchmo_checkout-step3')
            return (True, http.HttpResponseRedirect(url))
        else:
            log.debug('Form errors: %s', form.errors)
    else:
        form = _get_form(request, payment_module, *args, **kwargs)

    return (False, form)
开发者ID:hnejadi,项目名称:xerobis,代码行数:34,代码来源:payship.py


示例5: one_step

def one_step(request):
    # First verify that the customer exists
    try:
        contact = Contact.objects.from_request(request, create=False)
    except Contact.DoesNotExist:
        url = lookup_url(payment_config, "satchmo_checkout-step1")
        return HttpResponseRedirect(url)
    # Verify we still have items in the cart
    tempCart = Cart.objects.from_request(request)
    if tempCart.numItems == 0:
        template = lookup_template(payment_config, "shop/checkout/empty_cart.html")
        return render_to_response(template, context_instance=RequestContext(request))

    # Create a new order
    newOrder = Order(contact=contact)
    pay_ship_save(newOrder, tempCart, contact, shipping="", discount="", notes="")

    request.session["orderID"] = newOrder.id

    processor = get_processor_by_key("PAYMENT_REWARD_POINTS")
    processor.prepare_data(newOrder)
    processor_result = processor.process(newOrder)

    if processor_result.success:
        tempCart.empty()
        return success(request)
    else:
        return failure(request)
开发者ID:ubiquitousthey,项目名称:django-rewards,代码行数:28,代码来源:views.py


示例6: giftcert_pay_ship_process_form

def giftcert_pay_ship_process_form(request, contact, working_cart, payment_module, allow_skip):
    if request.method == "POST":
        new_data = request.POST.copy()
        form = GiftCertPayShipForm(request, payment_module, new_data)
        if form.is_valid():
            data = form.cleaned_data

            # Create a new order.
            newOrder = get_or_create_order(request, working_cart, contact, data)            
            newOrder.add_variable(GIFTCODE_KEY, data['giftcode'])
            
            request.session['orderID'] = newOrder.id
            
            url = None
            gift_certificate = GiftCertificate.objects.get(code=data['giftcode'], valid=True, 
                    site=Site.objects.get_current())
            # Check to see if the giftcertificate is not enough
            # If it isn't, then process it and prompt for next payment method
            if gift_certificate.balance < newOrder.balance:
                controller = confirm.ConfirmController(request, gc)
                controller.confirm()
                url = reverse('satchmo_balance_remaining')
            else:
                url = lookup_url(payment_module, 'satchmo_checkout-step3')
            return (True, http.HttpResponseRedirect(url))
    else:
        form = GiftCertPayShipForm(request, payment_module)

    return (False, form)
开发者ID:eyeyunianto,项目名称:satchmo,代码行数:29,代码来源:views.py


示例7: __call__

    def __call__(self, request):
        #First verify that the customer exists
        try:
            contact = Contact.objects.from_request(request, create=False)
        except Contact.DoesNotExist:
            url = lookup_url(self.payment_module, 'satchmo_checkout-step1')
            return HttpResponseRedirect(url)
        #Verify we still have items in the cart
        tempCart = Cart.objects.from_request(request)
        if tempCart.numItems == 0:
            template = lookup_template(
                self.payment_module,
                'shop/checkout/empty_cart.html'
            )
            return render_to_response(
                template, context_instance=RequestContext(request)
            )
            
        data = {}
        if request.method == 'POST':
            data['discount'] = request.post.get('discount_code')
        
        
        success = lookup_url(
            self.payment_module,
            '%s_satchmo_checkout-success' % self.processor.key,
        )
        
        order = get_or_create_order(request, tempCart, contact, data)
        
        self.preprocess_order(order)
        
        # Add status
        order.add_status('New', _("Payment needs to be confirmed"))
        # Process payment
        self.processor.prepare_data(order)
        self.processor.process(order)
        tempCart.empty()

        self.postprocess_order(order)
        order.save()

        return HttpResponseRedirect(success)
开发者ID:abstract-open-solutions,项目名称:satchmo-utils,代码行数:43,代码来源:views.py


示例8: simple_pay_ship_process_form

def simple_pay_ship_process_form(request, contact, working_cart, payment_module, allow_skip=True):
    if request.method == "POST":
        new_data = request.POST.copy()
        form = SimplePayShipForm(request, payment_module, new_data)
        if form.is_valid():
            form.save(request, working_cart, contact, payment_module)
            url = lookup_url(payment_module, 'satchmo_checkout-step3')
            return (True, http.HttpResponseRedirect(url))
        else:
            return (False, form)
    else:
        order_data = None
        try:
            order = Order.objects.from_request(request)
            if order.shipping_model:
                order_data = {}
                order_data['shipping'] = order.shipping_model
            ordershippable = order.is_shippable
        except Order.DoesNotExist:
            pass

        form = SimplePayShipForm(request, payment_module, order_data)
        if allow_skip:
            skipping = False
            skipstep = form.shipping_hidden or not ordershippable or (len(form.shipping_dict) == 1)
            if skipstep:               
                log.debug('Skipping pay ship, nothing to select for shipping')
                # no shipping choice = skip this step
                form.save(request, working_cart, contact, payment_module, 
                    data={'shipping' : form.fields['shipping'].initial})
                skipping = True
            elif not form.is_needed():
                log.debug('Skipping pay ship because form is not needed, nothing to pay')
                form.save(request, working_cart, contact, None, 
                    data={'shipping' : form.shipping_dict.keys()[0]})
                skipping = True
            
            if skipping:
                url = lookup_url(payment_module, 'satchmo_checkout-step3')
                return (True, http.HttpResponseRedirect(url))
                
        return (False, form)
开发者ID:34,项目名称:T,代码行数:42,代码来源:payship.py


示例9: stripe_pay_ship_process_form

def stripe_pay_ship_process_form(request, contact, working_cart, payment_module, allow_skip=True, *args, **kwargs):
    def _get_form(request, payment_module, *args, **kwargs):
        return StripePayShipForm(request, payment_module, *args, **kwargs) 

    
    if request.method == "POST":
        new_data = request.POST.copy()
        #if using saved card, fill in the stripe token field with the customer_id
        if not new_data['stripe_token'] and new_data['use_saved_cc']:
            new_data['stripe_token'] = utils.check_stripe_customer(threadlocals.get_current_user())
        form = _get_form(request, payment_module, new_data, *args, **kwargs)

        if form.is_valid():
            data = form.cleaned_data
            form.save(request, working_cart, contact, payment_module, data=data)
            url = lookup_url(payment_module, 'satchmo_checkout-step3')
            return (True, http.HttpResponseRedirect(url))
        else:
            log.info('Form didn\'t pass!!!!')
            for error in form.errors:
              log.info(error)
            pass
    else:
        order_data = {}
        try:
            order = Order.objects.from_request(request)
            if order.shipping_model:
                order_data['shipping'] = order.shipping_model

            kwargs['initial'] = order_data
            ordershippable = order.is_shippable
        except Order.DoesNotExist:
            pass

        form = _get_form(request, payment_module, *args, **kwargs)
        if not form.is_needed():
            form.save(request, working_cart, contact, None, data={'shipping': form.shipping_dict.keys()[0]})

            url = lookup_url(payment_module, 'satchmo_checkout-step3')
            return (True, http.HttpResponseRedirect(url))

    return (False, form)
开发者ID:trwalzer,项目名称:satchmo-stripe,代码行数:42,代码来源:views.py


示例10: confirm_info

def confirm_info(request):
    payment_module = config_get_group('PAYMENT_OGONE')

    try:
        order = Order.objects.from_request(request)
    except Order.DoesNotExist:
        url = lookup_url(payment_module, 'satchmo_checkout-step1')
        return HttpResponseRedirect(url)

    tempCart = Cart.objects.from_request(request)
    if tempCart.numItems == 0 and not order.is_partially_paid:
        template = lookup_template(payment_module, 'shop/checkout/empty_cart.html')
        return render_to_response(template,
                                  context_instance=RequestContext(request))

    # Check if the order is still valid
    if not order.validate(request):
        context = RequestContext(request,
                                 {'message': _('Your order is no longer valid.')})
        return render_to_response('shop/404.html', context_instance=context)

    template = lookup_template(payment_module, 'shop/checkout/ogone/confirm.html')

    processor_module = payment_module.MODULE.load_module('processor')
    processor = processor_module.PaymentProcessor(payment_module)
    
    pending_payment = processor.create_pending_payment(order=order)
    payment = pending_payment.capture
    
    log.debug('Creating payment %s for order %s', payment, order)
    
    success_url = reverse_full_url('OGONE_satchmo_checkout-success')
    failure_url = reverse_full_url('OGONE_satchmo_checkout-failure')
    homeurl = reverse_full_url('satchmo_shop_home')
    catalogurl = reverse_full_url('satchmo_category_index')
    
    # Get Ogone settings from Satchmo
    settings = get_ogone_settings()
    
    context = get_ogone_request(payment, 
                                settings,
                                accepturl=success_url,
                                cancelurl=failure_url,
                                declineurl=failure_url,
                                exceptionurl=failure_url,
                                homeurl=homeurl,
                                catalogurl=catalogurl,
                                language=getattr(request, 'LANGUAGE_CODE', 'en_US'))
    
    context.update({'order': order})
    
    return render_to_response(template, context, RequestContext(request))
开发者ID:curaloucura,项目名称:satchmo-payment-ogone,代码行数:52,代码来源:views.py


示例11: stripe_pay_ship_process_form

def stripe_pay_ship_process_form(request, contact, working_cart, payment_module, allow_skip=True, *args, **kwargs):
    def _get_form(request, payment_module, *args, **kwargs):
        return StripePayShipForm(request, payment_module, *args, **kwargs) 

    if request.method == "POST":
        new_data = request.POST.copy()
        form = _get_form(request, payment_module, new_data, *args, **kwargs)
        if form.is_valid():
            data = form.cleaned_data
            form.save(request, working_cart, contact, payment_module, data=data)
            url = lookup_url(payment_module, 'satchmo_checkout-step3')
            return (True, http.HttpResponseRedirect(url))
        else:
            pass
    else:
        order_data = {}
        try:
            order = Order.objects.from_request(request)
            if order.shipping_model:
                order_data['shipping'] = order.shipping_model
            if order.credit_card:
                # check if valid token
                pass

            kwargs['initial'] = order_data
            ordershippable = order.is_shippable
        except Order.DoesNotExist:
            pass

        form = _get_form(request, payment_module, *args, **kwargs)
        if not form.is_needed():
            form.save(request, working_cart, contact, None, data={'shipping', form.shipping_dict.keys()[0]})

            url = lookup_url(payment_module, 'satchmo_checkout-step3')
            return (True, http.HttpResponseRedirect(url))

    return (False, form)
开发者ID:buddylindsey,项目名称:satchmo-stripe,代码行数:37,代码来源:views.py


示例12: purchaseorder_process_form

def purchaseorder_process_form(request, contact, working_cart, payment_module, allow_skip):
    log.debug('purchaseorder_process_form')
    if request.method == "POST":
        log.debug('handling POST')
        new_data = request.POST.copy()
        form = PurchaseorderPayShipForm(request, payment_module, new_data)
        if form.is_valid():
            form.save(request, working_cart, contact, payment_module)
            url = lookup_url(payment_module, 'satchmo_checkout-step3')
            return (True, http.HttpResponseRedirect(url))
    else:
        log.debug('new form')
        form = PurchaseorderPayShipForm(request, payment_module)

    return (False, form)
开发者ID:eyeyunianto,项目名称:satchmo,代码行数:15,代码来源:views.py


示例13: confirm_info

def confirm_info(request):
    payment_module = config_get_group('PAYMENT_GOOGLE')

    if not 'orderID' in request.session:
        url = lookup_url(payment_module, 'satchmo_checkout-step1')
        return http.HttpResponseRedirect(url)

    tempCart = Cart.objects.from_request(request)
    if tempCart.numItems == 0:
        template = lookup_template(payment_module, 'shop/checkout/empty_cart.html')
        return render_to_response(template, RequestContext(request))
            
    try:
        order = Order.objects.from_request(request)

    except Order.DoesNotExist:
        order = None

    if not (order and order.validate(request)):
        context = RequestContext(request,
            {'message': _('Your order is no longer valid.')})
        return render_to_response('shop/404.html', context)    

    live = payment_live(payment_module)
    gcart = GoogleCart(order, payment_module, live)
    log.debug("CART:\n%s", gcart.cart_xml)
    template = lookup_template(payment_module, 'shop/checkout/confirm.html')

    if live:
        merchant_id = payment_module.MERCHANT_ID.value
        url_template = payment_module.POST_URL.value
    else:
        merchant_id = payment_module.MERCHANT_TEST_ID.value
        url_template = payment_module.POST_TEST_URL.value
        
    post_url =  url_template % {'MERCHANT_ID' : merchant_id}
    default_view_tax = config_value('TAX', 'DEFAULT_VIEW_TAX')
    
    ctx = RequestContext(request, {
        'order': order,
        'post_url': post_url,
        'default_view_tax': default_view_tax,
        'google_cart' : gcart.encoded_cart(),
        'google_signature' : gcart.encoded_signature(),
        'PAYMENT_LIVE' : live
    })

    return render_to_response(template, ctx)
开发者ID:jtslade,项目名称:satchmo-svn,代码行数:48,代码来源:views.py


示例14: form_valid

    def form_valid(self, form):
        contact = self.get_contact()
        new_data = self.request.POST.copy()
        tempCart = self.get_cart()

        if contact is None and self.request.user \
            and self.request.user.is_authenticated():
            contact = Contact(user=self.request.user)
        custID = form.save(self.request, cart=tempCart, contact=contact)
        self.request.session[CUSTOMER_ID] = custID

        modulename = new_data['paymentmethod']
        if not modulename.startswith('PAYMENT_'):
            modulename = 'PAYMENT_' + modulename
        paymentmodule = config_get_group(modulename)
        url = lookup_url(paymentmodule, 'satchmo_checkout-step2')
        self._success_url = url
        return super(CheckoutForm, self).form_valid(form)
开发者ID:ThissDJ,项目名称:designhub,代码行数:18,代码来源:contact.py


示例15: pay_ship_info_verify

def pay_ship_info_verify(request, payment_module):
    """Verify customer and cart.
    Returns:
    True, contact, cart on success
    False, destination of failure
    """
    # Verify that the customer exists.
    try:
        contact = Contact.objects.from_request(request, create=False)
    except Contact.DoesNotExist:
        log.debug('No contact, returning to step 1 of checkout')
        url = lookup_url(payment_module, 'satchmo_checkout-step1')
        return (False, http.HttpResponseRedirect(url))

    # Verify that we still have items in the cart.
    tempCart = Cart.objects.from_request(request)
    if tempCart.numItems == 0:
        template = lookup_template(payment_module, 'shop/checkout/empty_cart.html')
        return (False, render_to_response(template, RequestContext(request)))
            
    return (True, contact, tempCart)
开发者ID:hnejadi,项目名称:xerobis,代码行数:21,代码来源:payship.py


示例16: giftcert_pay_ship_process_form

def giftcert_pay_ship_process_form(request, contact, working_cart, payment_module):
    if request.method == "POST":
        new_data = request.POST.copy()
        form = GiftCertPayShipForm(request, payment_module, new_data)
        if form.is_valid():
            data = form.cleaned_data

            # Create a new order.
            newOrder = get_or_create_order(request, working_cart, contact, data)            
            newOrder.add_variable(GIFTCODE_KEY, data['giftcode'])
            
            request.session['orderID'] = newOrder.id

            url = None
            if not url:
                url = lookup_url(payment_module, 'satchmo_checkout-step3')
                
            return (True, http.HttpResponseRedirect(url))
    else:
        form = GiftCertPayShipForm(request, payment_module)

    return (False, form)
开发者ID:hnejadi,项目名称:xerobis,代码行数:22,代码来源:views.py


示例17: simple_pay_ship_process_form

def simple_pay_ship_process_form(request, contact, working_cart, payment_module):
    if request.method == "POST":
        new_data = request.POST.copy()
        form = SimplePayShipForm(request, payment_module, new_data)
        if form.is_valid():
            form.save(request, working_cart, contact, payment_module)
    else:
        form = SimplePayShipForm(request, payment_module)
        if config_value('PAYMENT','USE_DISCOUNTS') or not form.shipping_hidden:
            return (False, form)
        else:
            # No discounts, no shipping choice = skip this step
            order = get_or_create_order(
                    request,
                    working_cart,
                    contact,
                    {'shipping': form.fields['shipping'].initial, 'discount': ''}
                    )
            processor_module = payment_module.MODULE.load_module('processor')
            processor = processor_module.PaymentProcessor(payment_module)
            orderpayment = processor.create_pending_payment(order=order)
    url = lookup_url(payment_module, 'satchmo_checkout-step3')
    return (True, http.HttpResponseRedirect(url))
开发者ID:hnejadi,项目名称:xerobis,代码行数:23,代码来源:payship.py


示例18: balance_remaining

def balance_remaining(request):
    """Allow the user to pay the remaining balance."""
    order = None
    orderid = request.session.get('orderID')
    if orderid:
        try:
            order = Order.objects.get(pk=orderid)
        except Order.DoesNotExist:
            # TODO: verify user against current user
            pass
            
    if not order:
        url = urlresolvers.reverse('satchmo_checkout-step1')
        return HttpResponseRedirect(url)

    if request.method == "POST":
        new_data = request.POST.copy()
        form = PaymentMethodForm(data=new_data, order=order)
        if form.is_valid():
            data = form.cleaned_data
            modulename = data['paymentmethod']
            if not modulename.startswith('PAYMENT_'):
                modulename = 'PAYMENT_' + modulename
            
            paymentmodule = config_get_group(modulename)
            url = lookup_url(paymentmodule, 'satchmo_checkout-step2')
            return HttpResponseRedirect(url)
        
    else:
        form = PaymentMethodForm(order=order)
        
    ctx = RequestContext(request, {'form' : form, 
        'order' : order,
        'paymentmethod_ct': len(active_gateways())
    })
    return render_to_response('shop/checkout/balance_remaining.html',
                              context_instance=ctx)
开发者ID:eyeyunianto,项目名称:satchmo,代码行数:37,代码来源:balance.py


示例19: _resolve_local_url

def _resolve_local_url(payment_module, cfgval, ssl=False):
    try:
        return lookup_url(payment_module, cfgval.value, include_server=True, ssl=ssl)
    except urlresolvers.NoReverseMatch:
        return cfgval.value
开发者ID:hnejadi,项目名称:xerobis,代码行数:5,代码来源:views.py


示例20: confirm_info

def confirm_info(request):
    payment_module = config_get_group('PAYMENT_SERMEPA')

    try:
        order = Order.objects.from_request(request)
    except Order.DoesNotExist:
        url = lookup_url(payment_module, 'satchmo_checkout-step1')
        return HttpResponseRedirect(url)

    tempCart = Cart.objects.from_request(request)
    if tempCart.numItems == 0:
        template = lookup_template(payment_module, 'shop/checkout/empty_cart.html')
        return render_to_response(template,
                                  context_instance=RequestContext(request))

    # Check if the order is still valid
    if not order.validate(request):
        context = RequestContext(request, {'message': _('Your order is no longer valid.')})
        return render_to_response('shop/404.html', context_instance=context)

    # Check if we are in test or real mode
    live = payment_module.LIVE.value
    if live:
        post_url = payment_module.POST_URL.value
        signature_code = payment_module.MERCHANT_SIGNATURE_CODE.value
        terminal = payment_module.MERCHANT_TERMINAL.value
    else:
        post_url = payment_module.POST_TEST_URL.value
        signature_code = payment_module.MERCHANT_TEST_SIGNATURE_CODE.value
        terminal = payment_module.MERCHANT_TEST_TERMINAL.value

    # SERMEPA system does not accept multiple payment attempts with the same ID, even
    # if the previous one has never been finished. The worse is that it does not display
    # any message which could be understood by an end user.
    #
    # If user goes to SERMEPA page and clicks 'back' button (e.g. to correct contact data),
    # the next payment attempt will be rejected.
    #
    # To provide higher probability of ID uniqueness, we add mm:ss timestamp part
    # to the order id, separated by 'T' character in the following way:
    #
    #   ID: oooooooTmmss
    #   c:  123456789012
    #
    # The Satchmo's Order number is therefore limited to 10 million - 1.
    now = datetime.now()
    xchg_order_id = "%07dT%02d%02d" % (order.id, now.minute, now.second)

    amount = "%d" % (order.balance * 100,)    # in cents

    template = lookup_template(payment_module, 'shop/checkout/sermepa/confirm.html')

    url_callback = _resolve_local_url(payment_module, payment_module.MERCHANT_URL_CALLBACK, ssl=get_satchmo_setting('SSL'))
    url_ok = _resolve_local_url(payment_module, payment_module.MERCHANT_URL_OK)
    url_ko = _resolve_local_url(payment_module, payment_module.MERCHANT_URL_KO)

    if payment_module.EXTENDED_SIGNATURE.value:
        signature_data = ''.join(
                map(str, (
                        amount,
                        xchg_order_id,
                        payment_module.MERCHANT_FUC.value,
                        payment_module.MERCHANT_CURRENCY.value,
                        "0", #TransactionType
                        url_callback,
                        signature_code,
                        )
                   )
                )
    else:
        signature_data = ''.join(
                map(str, (
                        amount,
                        xchg_order_id,
                        payment_module.MERCHANT_FUC.value,
                        payment_module.MERCHANT_CURRENCY.value,
                        signature_code,
                        )
                   )
                )

    signature = sha1(signature_data).hexdigest()
    ctx = {
        'live': live,
        'post_url': post_url,
        'MERCHANT_CURRENCY': payment_module.MERCHANT_CURRENCY.value,
        'MERCHANT_FUC': payment_module.MERCHANT_FUC.value,
        'terminal': terminal,
        'MERCHANT_TITULAR': payment_module.MERCHANT_TITULAR.value,
        'url_callback': url_callback,
        'url_ok': url_ok,
        'url_ko': url_ko,
        'order': order,
        'xchg_order_id' : xchg_order_id,
        'amount': amount,
        'signature': signature,
        'default_view_tax': config_value('TAX', 'DEFAULT_VIEW_TAX'),
    }
    return render_to_response(template, ctx, context_instance=RequestContext(request))
开发者ID:ThissDJ,项目名称:designhub,代码行数:99,代码来源:views.py



注:本文中的satchmo_utils.dynamic.lookup_url函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python numbers.trunc_decimal函数代码示例发布时间:2022-05-27
下一篇:
Python dynamic.lookup_template函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap