本文整理汇总了Python中satchmo_utils.dynamic.lookup_template函数的典型用法代码示例。如果您正苦于以下问题:Python lookup_template函数的具体用法?Python lookup_template怎么用?Python lookup_template使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lookup_template函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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
示例2: 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
示例3: 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
示例4: pay_ship_info
def pay_ship_info(request):
template = 'satchmo_stripe/pay_ship.html'
payment_module = stripe
form_handler = stripe_pay_ship_process_form
result = payship.pay_ship_info_verify(request, payment_module)
if not result[0]:
return result[1]
contact = result[1]
working_cart = result[2]
success, form = form_handler(request, contact, working_cart, payment_module)
if success:
return form
template = lookup_template(payment_module, template)
live = gateway_live(payment_module)
ctx = RequestContext(request, {
'form': form,
'PAYMENT_LIVE': live,
})
return render_to_response(template, context_instance=ctx)
开发者ID:buddylindsey,项目名称:satchmo-stripe,代码行数:25,代码来源:views.py
示例5: 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
示例6: pay_ship_render_form
def pay_ship_render_form(request, form, template, payment_module, cart):
template = lookup_template(payment_module, template)
ctx = RequestContext(request, {
'form': form,
'PAYMENT_LIVE': gateway_live(payment_module),
})
return render_to_response(template, context_instance=ctx)
开发者ID:34,项目名称:T,代码行数:8,代码来源:payship.py
示例7: confirm_secure3d
def confirm_secure3d(request, secure3d_template='shop/checkout/sagepay/secure3d_form.html',
confirm_template='shop/checkout/confirm.html', extra_context={}):
"""Handles confirming an order and processing the charges when secured by secure3d.
"""
payment_module = config_get_group('PAYMENT_SAGEPAY')
controller = confirm.ConfirmController(request, payment_module, extra_context=extra_context)
controller.template['CONFIRM'] = confirm_template
if not controller.sanity_check():
return controller.response
auth3d = request.session.get('3D', None)
if not auth3d:
controller.processorMessage = _('3D Secure transaction expired. Please try again.')
else:
if request.method == "POST":
returnMD = request.POST.get('MD', None)
if not returnMD:
template = lookup_template(payment_module, secure3d_template)
ctx = RequestContext(request, {'order': controller.order, 'auth': auth3d })
return render_to_response(template, context_instance=ctx)
elif returnMD == auth3d['MD']:
pares = request.POST.get('PaRes', None)
controller.processor.prepare_data(controller.order)
controller.processor.prepare_data3d(returnMD, pares)
if controller.process():
return controller.onSuccess(controller)
else:
controller.processorMessage = _('3D Secure transaction was not approved by payment gateway. Please contact us.')
else:
template = lookup_template(payment_module, secure3d_template)
ctx =RequestContext(request, {
'order': controller.order, 'auth': auth3d
})
return render_to_response(template, context_instance=ctx)
return secure3d_form_handler(controller)
开发者ID:eyeyunianto,项目名称:satchmo,代码行数:39,代码来源:views.py
示例8: pay_ship_render_form
def pay_ship_render_form(request, form, template, payment_module, cart):
template = lookup_template(payment_module, template)
if cart.numItems > 0:
products = [item.product for item in cart.cartitem_set.all()]
sale = find_best_auto_discount(products)
else:
sale = None
ctx = RequestContext(request, {
'form': form,
'sale' : sale,
'PAYMENT_LIVE': payment_live(payment_module),
})
return render_to_response(template, ctx)
开发者ID:jtslade,项目名称:satchmo-svn,代码行数:15,代码来源:payship.py
示例9: pay_ship_info
def pay_ship_info(request):
template = 'satchmo_stripe/pay_ship.html'
payment_module = stripe_config
form_handler = stripe_pay_ship_process_form
result = payship.pay_ship_info_verify(request, payment_module)
if not result[0]:
return result[1]
contact = result[1]
working_cart = result[2]
success, form = form_handler(request, contact, working_cart, payment_module)
if success:
return form
template = lookup_template(payment_module, template)
live = gateway_live(payment_module)
last4=''
cc_type=''
user = threadlocals.get_current_user()
if user and user.is_authenticated:
stripe_id = utils.check_stripe_customer(threadlocals.get_current_user())
if stripe_id:
customer = utils.get_customer(stripe_id)
if customer:
last4 = customer.active_card.last4
cc_type = customer.active_card.type
if utils.card_is_about_to_expire(customer.active_card):
#Raise message telling user that the card is about to expire
message = "The %s card ending in %s will expire in less than %d days, please enter a new card" % (cc_type,last4,payment_module.MIN_DAYS.value)
messages.add_message(request, messages.WARNING, message)
cc_type = ''
last4=''
ctx = RequestContext(request, {
'form': form,
'PAYMENT_LIVE': live,
'saved_card' : last4,
'cc_type' : cc_type,
'show_save_option' : payment_module.CAPTURE.value,
})
return render_to_response(template, context_instance=ctx)
开发者ID:trwalzer,项目名称:satchmo-stripe,代码行数:46,代码来源:views.py
示例10: __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
示例11: 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
示例12: _get_shipping_choices
def _get_shipping_choices(request, paymentmodule, cart, contact, default_view_tax=False):
"""Iterate through legal shipping modules, building the list for display to the user.
Returns the shipping choices list, along with a dictionary of shipping choices, useful
for building javascript that operates on shipping choices.
"""
shipping_options = []
shipping_dict = {}
if not cart.is_shippable:
methods = [shipping_method_by_key('NoShipping'),]
else:
methods = shipping_methods()
for method in methods:
method.calculate(cart, contact)
if method.valid():
template = lookup_template(paymentmodule, 'shipping/options.html')
t = loader.get_template(template)
shipcost = method.cost()
shipping_tax = None
taxed_shipping_price = None
if config_value_safe('TAX','TAX_SHIPPING', False):
shipping_tax = TaxClass.objects.get(title=config_value('TAX', 'TAX_CLASS'))
taxer = _get_taxprocessor(request)
total = shipcost + taxer.by_price(shipping_tax, shipcost)
taxed_shipping_price = moneyfmt(total)
c = RequestContext(request, {
'amount': shipcost,
'description' : method.description(),
'method' : method.method(),
'expected_delivery' : method.expectedDelivery(),
'default_view_tax' : default_view_tax,
'shipping_tax': shipping_tax,
'taxed_shipping_price': taxed_shipping_price})
shipping_options.append((method.id, t.render(c)))
shipping_dict[method.id] = shipcost
return shipping_options, shipping_dict
开发者ID:hnejadi,项目名称:xerobis,代码行数:39,代码来源:forms.py
示例13: confirm_info
def confirm_info(request):
payment_module = config_get_group('PAYMENT_CREDITCARD')
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/creditcard/confirm.html'
)
if payment_module.LIVE.value:
log.debug("live order on %s", payment_module.KEY.value)
url = payment_module.POST_URL.value
account = payment_module.MERCHANT_ID.value
else:
url = payment_module.POST_TEST_URL.value
account = payment_module.MERCHANT_TEST_ID.value
try:
address = lookup_url(payment_module,
payment_module.RETURN_ADDRESS.value, include_server=True)
except urlresolvers.NoReverseMatch:
address = payment_module.RETURN_ADDRESS.value
processor_module = payment_module.MODULE.load_module('processor')
processor = processor_module.PaymentProcessor(payment_module)
processor.create_pending_payment(order=order)
default_view_tax = config_value('TAX', 'DEFAULT_VIEW_TAX')
recurring = None
order_items = order.orderitem_set.all()
for item in order_items:
if item.product.is_subscription:
recurring = {
'product':item.product,
'price':item.product.price_set.all()[0].price.quantize(Decimal('.01'))
}
trial0 = recurring['product'].subscriptionproduct.get_trial_terms(0)
if len(order_items) > 1 or trial0 is not None \
or recurring['price'] < order.balance:
recurring['trial1'] = {'price': order.balance,}
if trial0 is not None:
recurring['trial1']['expire_length'] = trial0.expire_length
recurring['trial1']['expire_unit'] = trial0.expire_unit[0]
trial1 = recurring['product'].subscriptionproduct.get_trial_terms(1)
if trial1 is not None:
recurring['trial2']['expire_length'] = trial1.expire_length
recurring['trial2']['expire_unit'] = trial1.expire_unit[0]
recurring['trial2']['price'] = trial1.price
gpc = GestPayCrypt()
gpc.SetShopLogin(account)
gpc.SetShopTransactionID(str(order.id))
gpc.SetAmount("%.2f" % order.total)
a = gpc.GetShopLogin()
b = ''
if gpc.Encrypt() == None:
print "Authorization Failed"
else:
b = gpc.GetEncryptedString()
encrypt = url
params = "?a=%s&b=%s" % (a, b)
url = "%s%s" % (encrypt, params)
ctx = RequestContext(request, {
'order': order,
'post_url': url,
'default_view_tax': default_view_tax,
'business': account,
'currency_code': payment_module.CURRENCY_CODE.value,
'return_address': address,
'invoice': order.id,
'subscription': recurring,
'PAYMENT_LIVE' : gateway_live(payment_module)
})
return render_to_response(template, context_instance=ctx)
开发者ID:abstract-open-solutions,项目名称:satchmo-utils,代码行数:99,代码来源:views.py
示例14: _get_shipping_choices
def _get_shipping_choices(request, paymentmodule, cart, contact, default_view_tax=False, order=None):
"""Iterate through legal shipping modules, building the list for display to the user.
Returns the shipping choices list, along with a dictionary of shipping choices, useful
for building javascript that operates on shipping choices.
"""
shipping_options = []
shipping_dict = {}
rendered = {}
if not order:
try:
order = Order.objects.from_request(request)
except Order.DoesNotExist:
pass
discount = None
if order:
try:
discount = Discount.objects.by_code(order.discount_code)
except Discount.DoesNotExist:
pass
if not cart.is_shippable:
methods = [shipping_method_by_key('NoShipping'),]
else:
methods = shipping_methods()
tax_shipping = config_value_safe('TAX','TAX_SHIPPING', False)
shipping_tax = None
if tax_shipping:
taxer = _get_taxprocessor(request)
shipping_tax = TaxClass.objects.get(title=config_value('TAX', 'TAX_CLASS'))
for method in methods:
method.calculate(cart, contact)
if method.valid():
template = lookup_template(paymentmodule, 'shipping/options.html')
t = loader.get_template(template)
shipcost = finalcost = method.cost()
if discount and order:
order.shipping_cost = shipcost
discount.calc(order)
shipdiscount = discount.item_discounts.get('Shipping', 0)
else:
shipdiscount = 0
# set up query to determine shipping price to show
shipprice = Price()
shipprice.price = shipcost
shipadjust = PriceAdjustmentCalc(shipprice)
if shipdiscount:
shipadjust += PriceAdjustment('discount', _('Discount'), shipdiscount)
satchmo_shipping_price_query.send(cart, adjustment=shipadjust)
shipdiscount = shipadjust.total_adjustment()
if shipdiscount:
finalcost -= shipdiscount
shipping_dict[method.id] = {'cost' : shipcost, 'discount' : shipdiscount, 'final' : finalcost}
taxed_shipping_price = None
if tax_shipping:
taxcost = taxer.by_price(shipping_tax, finalcost)
total = finalcost + taxcost
taxed_shipping_price = moneyfmt(total)
shipping_dict[method.id]['taxedcost'] = total
shipping_dict[method.id]['tax'] = taxcost
c = RequestContext(request, {
'amount': finalcost,
'description' : method.description(),
'method' : method.method(),
'expected_delivery' : method.expectedDelivery(),
'default_view_tax' : default_view_tax,
'shipping_tax': shipping_tax,
'taxed_shipping_price': taxed_shipping_price})
rendered[method.id] = t.render(c)
#now sort by price, low to high
sortme = [(value['cost'], key) for key, value in shipping_dict.items()]
sortme.sort()
shipping_options = [(key, rendered[key]) for cost, key in sortme]
shipping_choices_query.send(sender=cart, cart=cart,
paymentmodule=paymentmodule, contact=contact,
default_view_tax=default_view_tax, order=order,
shipping_options = shipping_options,
shipping_dict = shipping_dict)
return shipping_options, shipping_dict
开发者ID:mpango,项目名称:satchmo,代码行数:93,代码来源:forms.py
示例15: confirm_info
def confirm_info(request):
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)
# from here on just setting and calling variables
template = lookup_template(payment_module, 'shop/checkout/paysbuy/confirm.html')
if payment_module.LIVE.value:
log.debug("live order on %s", payment_module.KEY.value)
url = payment_module.CONNECTION.value
psb = payment_module.PSB.value
account = payment_module.BIZ.value
secure_code = payment_module.SECURE_CODE.value
else:
url = payment_module.CONNECTION_TEST.value
psb = payment_module.PSB_TEST.value
account = payment_module.BIZ_TEST.value
secure_code = payment_module.SECURE_CODE_TEST.value
try:
address = lookup_url(payment_module,
payment_module.FRONT_URL.value, include_server=True)
except urlresolvers.NoReverseMatch:
address = payment_module.FRONT_URL.value
try:
cart = Cart.objects.from_request(request)
except:
cart = None
try:
contact = Contact.objects.from_request(request)
except:
contact = None
if cart and contact:
cart.customer = contact
log.debug(':::Updating Cart %s for %s' % (cart, contact))
cart.save()
if payment_module.OPT_FIX_REDIRECT.value:
opt_fix_redirect = '1'
else:
opt_fix_redirect= ''
if payment_module.OPT_FIX_METHOD.value:
opt_fix_method = '1'
else:
opt_fix_method = ''
total_plus_tax = 0
for o in order.orderitem_set.all():
total_plus_tax = total_plus_tax + o.total_with_tax
processor_module = payment_module.MODULE.load_module('processor')
processor = processor_module.PaymentProcessor(payment_module)
processor.create_pending_payment(order=order)
ship_tax_total = total_plus_tax + order.shipping_cost
psb_post_out_dict = {
'order': order,
'post_url': url,
'psb': psb[:10],
'biz': account[:200],
'secure_code': secure_code[:200],
'amount': ship_tax_total,
'paypal': ""[:2],
'commission': payment_module.COMMISSION_CODE.value[:200],
'default_pay_method': payment_module.PAY_METHOD.value[:1],
'currencyCode': payment_module.CURRENCY_CODE.value,
'lang': payment_module.LANGUAGE.value[:1],
'postURL': address[:500],
'reqURL': payment_module.BACK_URL.value[:500],
'opt_fix_redirect': opt_fix_redirect[:1],
'opt_fix_method': opt_fix_method[:1],
'opt_name': contact.full_name[:200],
'opt_email': contact.email[:200],
'opt_mobile': str(contact.primary_phone)[:200],
'opt_address': str(contact.shipping_address)[:200],
'opt_detail': ""[:200],
'invoice': str(order.id)[:200],
'itm': "Thailand Furniture Purchase"[:200],
'PAYMENT_LIVE' : payment_module.LIVE.value,
'OrderPaidInFull': order.paid_in_full,
}
ctx = RequestContext(request, psb_post_out_dict)
if not payment_module.LIVE.value:
if order.notes:
admin_notes = order.notes + u'\n'
else:
admin_notes = ""
order.notes = admin_notes + 'TEST' + u'\n'
order.add_status(status='New', notes=_("Payment sent to Paysbuy."))
#.........这里部分代码省略.........
开发者ID:MorganShorter,项目名称:satchmo-payment-module-paysbuy,代码行数:101,代码来源:views.py
示例16: lookup_template
def lookup_template(self, key):
"""Shortcut method to the the proper template from the `paymentModule`"""
return lookup_template(self.paymentModule, self.templates[key])
开发者ID:eyeyunianto,项目名称:satchmo,代码行数:3,代码来源:confirm.py
示例17: confirm_info
def confirm_info(request):
payment_module = config_get_group('PAYMENT_PAGSEGURO')
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/pagseguro/confirm.html')
if payment_module.LIVE.value:
log.debug("live order on %s", payment_module.KEY.value)
url = payment_module.POST_URL.value
account = payment_module.BUSINESS.value
else:
url = payment_module.POST_TEST_URL.value
account = payment_module.BUSINESS_TEST.value
try:
address = lookup_url(payment_module,
payment_module.RETURN_ADDRESS.value, include_server=True)
except urlresolvers.NoReverseMatch:
address = payment_module.RETURN_ADDRESS.value
try:
cart = Cart.objects.from_request(request)
except:
cart = None
try:
contact = Contact.objects.from_request(request)
except:
contact = None
if cart and contact:
cart.customer = contact
log.debug(':::Updating Cart %s for %s' % (cart, contact))
cart.save()
processor_module = payment_module.MODULE.load_module('processor')
processor = processor_module.PaymentProcessor(payment_module)
processor.create_pending_payment(order=order)
default_view_tax = config_value('TAX', 'DEFAULT_VIEW_TAX')
order.add_status("Temp")
recurring = None
pagseguro = Pagseguro(tipo='CP', email_cobranca=account, moeda='BRL', encoding='UTF-8', ref_transacao=order.id, tipo_frete='EN')
pagseguro.cliente(nome=order.contact.first_name,
end=order.contact.billing_address.street1,
cep=order.contact.billing_address.postal_code,
email=order.contact.email,
)
for item in order.orderitem_set.all():
pagseguro.item(id=item.product.id,
descr=item.description,
qty=int(item.quantity),
valor="%.2f" % item.unit_price,
peso=int(item.product.weight or 0)
)
pagsegurohtml = pagseguro.mostra(imprime=False, abre=False, fecha=False)
# Run only if subscription products are installed
if 'product.modules.subscription' in settings.INSTALLED_APPS:
order_items = order.orderitem_set.all()
for item in order_items:
if not item.product.is_subscription:
continue
recurring = {'product':item.product, 'price':item.product.price_set.all()[0].price.quantize(Decimal('.01')),}
trial0 = recurring['product'].subscriptionproduct.get_trial_terms(0)
if len(order_items) > 1 or trial0 is not None or recurring['price'] < order.balance:
recurring['trial1'] = {'price': order.balance,}
if trial0 is not None:
recurring['trial1']['expire_length'] = trial0.expire_length
recurring['trial1']['expire_unit'] = trial0.subscription.expire_unit[0]
# else:
# recurring['trial1']['expire_length'] = recurring['product'].subscriptionproduct.get_trial_terms(0).expire_length
trial1 = recurring['product'].subscriptionproduct.get_trial_terms(1)
if trial1 is not None:
recurring['trial2']['expire_length'] = trial1.expire_length
recurring['trial2']['expire_unit'] = trial1.subscription.expire_unit[0]
recurring['trial2']['price'] = trial1.price
ctx = RequestContext(request, {'order': order,
'post_url': url,
'default_view_tax': default_view_tax,
#.........这里部分代码省略.........
开发者ID:alanjds,项目名称:satchmo-payment-pagseguro,代码行数:101,代码来源:views.py
示例18: confirm_info
def confirm_info(request):
payment_module = config_get_group('PAYMENT_PAGOSONLINE')
try:
order = Order.objects.from_request(request)
get_buyer_email = Contact.objects.filter(id=order.contact_id)
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
prueba = 0
else:
post_url = payment_module.POST_TEST_URL.value
prueba = 1
#
# PAGOSONLINE system does not accept multiple payment attempts with the same refVenta, 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 PAGOSONLINE page and clicks 'back' button (e.g. to correct contact data),
# the next payment attempt will be rejected.
#
# To provide higher probability of refVenta uniqueness, we add YYYY:DD:MM:hh:mm:ss timestamp part
# to the order id, separated by 'T' character in the following way:
#
# refVenta: xxxxxxxTYYYYDDMMHHMMSS
#
now = datetime.now()
xchg_order_id = "%dT%04d%02d%02d%02d%02d%02d" % (order.id, now.year, now.day, now.month, now.hour, now.minute, now.second)
signature_code = payment_module.MERCHANT_SIGNATURE_CODE.value
userId = payment_module.MERCHANT_USERID_CODE.value
amount = "%.2f" % order.balance
log.debug("Amount for confirm Info %s" % amount)
coin = payment_module.MERCHANT_CURRENCY.value
signature_data = '~'.join(
map(str, (
signature_code,
userId,
xchg_order_id,
amount,
coin,
)))
try:
cartnumber = request.session['cart']
except KeyError:
log.debug("No cart number found %s", request.session)
signature=md5(signature_data).hexdigest()
template = lookup_template(payment_module, 'shop/checkout/pagosonline/confirm.html')
url_callback = _resolve_local_url(payment_module, payment_module.MERCHANT_URL_CALLBACK, ssl=get_satchmo_setting('SSL'))
url_ans = _resolve_local_url(payment_module, payment_module.MERCHANT_URL_OK)
# url_ko = _resolve_local_url(payment_module, payment_module.MERCHANT_URL_KO)
try:
request.user.email
emailComprador = request.user.email
except:
emailComprador = get_buyer_email[0].email
float_balance = float(order.balance)
no_iva = float_balance/1.16
iva = round(0.16*no_iva,2)
log.debug("IVA = %f" % iva)
ctx = {
'live': live,
'post_url': post_url,
'coin': payment_module.MERCHANT_CURRENCY.value,
'url_callback': url_callback,
'url_ans': url_ans,
'usuarioId': userId,
'order': order,
'xchg_order_id': xchg_order_id,
'amount': amount,
'iva': iva,
'signature': signature,
'prueba': prueba,
'emailComprador': emailComprador,
'default_view_tax': config_value('TAX', 'DEFAULT_VIEW_TAX'),
}
#.........这里部分代码省略.........
开发者ID:angvp,项目名称:pagosonline,代码行数:101,代码来源:views.py
示例19: confirm_info
def confirm_info(request):
payment_module = config_get_group('PAYMENT_PAYPOINT')
try:
order = Order.objects.from_request(request)
except Order.DoesNotExist:
url = lookup_url(payment_module, 'satchmo_checkout-step1')
return redirect(url)
tmp_cart = Cart.objects.from_request(request)
if tmp_cart.numItems == 0:
template = lookup_template(
payment_module,
'shop/checkout/empty_cart.html'
)
return render(request, template)
# Check if the order is still valid
if not order.validate(request):
return render(
request,
'shop/404.html',
{'message': _('Your order is no longer valid')}
)
template = lookup_template(
payment_module,
'shop/checkout/paypoint/confirm.html'
)
live = payment_module.LIVE.value
if live:
log.debug('Live order on %s', payment_module.KEY.value)
url = payment_module.POST_URL.value
merchant = payment_module.MERCHANT_NAME.value
secret = payment_module.SECRET.value
else:
log.debug('Test order on %s', payment_module.KEY.value)
url = payment_module.TEST_POST_URL.value
merchant = payment_module.TEST_MERCHANT_NAME.value
secret = payment_module.TEST_SECRET.value
try:
cart = Cart.objects.from_request(request)
except:
cart = None
try:
contact = Contact.objects.from_request(request)
except:
contact = None
if cart and contact:
cart.customer = contact
log.debug('-> Adding %s to %s' % (contact, cart))
cart.save()
trans_id = '%07d' % order.id
digest = '%s%s%s' % (trans_id, order.balance, secret)
digest = hashlib.md5(digest).hexdigest()
site = Site.objects.get_current()
callback = 'http://%s%s' % \
(site, reverse('PAYPOINT_satchmo_checkout-success'))
ctx = {
'merchant': merchant,
'trans_id': trans_id,
'amount': order.balance,
'callback': callback,
'digest': digest,
'currency': payment_module.CURRENCY_CODE.value,
'PAYMENT_LIVE': live,
'post_url': url,
'order': order
}
return render(request, template, ctx)
开发者ID:wearefarm,项目名称:satchmo-paypoint,代码行数:77,代码来源:views.py
示 |
请发表评论