def _cart_xml(self, order): template = get_template(self.settings["CART_XML_TEMPLATE"].value) ssl = get_satchmo_setting('SSL', default_value=False) shopping_url = lookup_url(self.settings, 'satchmo_checkout-success', True, ssl) edit_url = lookup_url(self.settings, 'satchmo_cart', True, ssl) ctx = Context({"order" : order, "continue_shopping_url" : shopping_url, "edit_cart_url" : edit_url, "currency" : self.settings.CURRENCY_CODE.value, }) return template.render(ctx)
def _cart_xml(self, order): template = get_template(self.settings["CART_XML_TEMPLATE"].value) ssl = get_satchmo_setting('SSL', default_value=False) shopping_url = lookup_url(self.settings, 'satchmo_checkout-success', True, ssl) edit_url = lookup_url(self.settings, 'satchmo_cart', True, ssl) ctx = Context({ "order": order, "continue_shopping_url": shopping_url, "edit_cart_url": edit_url, "currency": self.settings.CURRENCY_CODE.value, }) return template.render(ctx)
from django.contrib.sites.models import Site try: from django.core.urlresolvers import reverse except ImportError: from django.urls import reverse from keyedcache import cache_delete from l10n.models import Country from l10n.utils import moneyfmt from product.utils import rebuild_pricing from satchmo_store.shop.satchmo_settings import get_satchmo_setting from satchmo_store.shop.tests import get_step1_post_data from django.core.cache import cache domain = 'http://example.com' prefix = get_satchmo_setting('SHOP_BASE') if prefix == '/': prefix = '' class ShopTest(TestCase): fixtures = [ 'initial_data.yaml', 'l10n-data.yaml', 'sample-store-data.yaml', 'products.yaml', 'test-config.yaml' ] def setUp(self): # Every test needs a client cache_delete() self.client = Client() self.US = Country.objects.get(iso2_code__iexact="US")
# # SERMEPA / ServiRed payments module for Satchmo # # Author: Michal Salaban <michal (at) salaban.info> # with a great help of Fluendo S.A., Barcelona # # Based on "Guia de comercios TPV Virtual SIS" ver. 5.18, 15/11/2008, SERMEPA # For more information about integration look at http://www.sermepa.es/ # # TODO: SERMEPA interface provides possibility of recurring payments, which # could be probably used for SubscriptionProducts. This module doesn't support it. # from django.conf.urls.defaults import patterns from satchmo_store.shop.satchmo_settings import get_satchmo_setting ssl = get_satchmo_setting('SSL', default_value=False) urlpatterns = patterns( '', (r'^$', 'payment.modules.sermepa.views.pay_ship_info', { 'SSL': ssl }, 'SERMEPA_satchmo_checkout-step2'), (r'^confirm/$', 'payment.modules.sermepa.views.confirm_info', { 'SSL': ssl }, 'SERMEPA_satchmo_checkout-step3'), (r'^success/$', 'payment.views.checkout.success', { 'SSL': ssl }, 'SERMEPA_satchmo_checkout-success'), (r'^failure/$', 'payment.views.checkout.failure', { 'SSL': ssl }, 'SERMEPA_satchmo_checkout-failure'), (r'^notify/$', 'payment.modules.sermepa.views.notify_callback', {
from django.conf.urls.defaults import patterns from livesettings import config_get_group from satchmo_store.shop.satchmo_settings import get_satchmo_setting ssl = get_satchmo_setting('SSL', default_value=False) config = config_get_group('PAYMENT_CREDITCARD') ssl = get_satchmo_setting('SSL', default_value=False) urlpatterns = patterns('', (r'^$', 'satchmoutils.payments.modules.creditcard.views.pay_ship_info', {'SSL': ssl}, 'CREDITCARD_satchmo_checkout-step2'), (r'^confirm/$', 'satchmoutils.payments.modules.creditcard.views.confirm_info', {'SSL': ssl}, 'CREDITCARD_satchmo_checkout-step3'), (r'^success/$', 'satchmoutils.payments.modules.creditcard.views.success', {'SSL': ssl}, 'CREDITCARD_satchmo_checkout-success'), (r'^error/$', 'satchmoutils.payments.modules.creditcard.views.error', {'SSL': ssl}, 'CREDITCARD_satchmo_checkout-error'), (r'^confirmorder/$', 'payment.views.confirm.confirm_free_order', {'SSL' : ssl, 'key' : 'CREDITCARD'}, 'CREDITCARD_satchmo_checkout_free-confirm') )
from django.conf import settings from django.conf.urls.defaults import * from django.contrib import databrowse from django.contrib.auth.decorators import login_required from django.core.urlresolvers import reverse from django.views.generic.simple import direct_to_template from satchmo_store.urls import urlpatterns as satchmo_urls from satchmo_store.contact.views import ajax_get_state from satchmo_store.shop.satchmo_settings import get_satchmo_setting from payment.views.checkout import success from localsite.views import sfst_success, confirm_info ssl = get_satchmo_setting('SSL', default_value=True) handler404 = 'sfst.localsite.views.view_404' handler500 = 'sfst.localsite.views.view_500' # Public URLS urlpatterns = patterns('localsite.views', url(r'^$', 'home', {'SSL': ssl}, name='home'), # url(r'^cart/$', 'cart', name='cart'), url(r'^affiliate-checkout/$', 'affiliate_checkout', {'SSL': ssl}, name='affiliate_checkout'), url(r'^product/(?P<tour_type_slug>[\w\-]+)/$', 'product', {'SSL': ssl}, name='product'), url(r'^ajax-get-schedule/(?P<tour_type_id>\d+)/$', 'ajax_get_schedule', {'SSL': ssl}, name='ajax_get_schedule'), url(r'^ajax-get-schedule-adjust/(?P<tour_type_id>\d+)/$', 'ajax_get_schedule', {'SSL': ssl}, name='ajax_get_schedule_adjust'), url(r'^accounts/dispatcher/', 'login_dispatcher', {'SSL': ssl}, name='login_dispatcher'), url(r'^clear-affiliate', 'clear_affiliate', {'SSL': ssl}, name='clear_affiliate'), url(r'^get-city-country-details/$', 'zip_to_city_country', {'SSL': ssl}, name='zip_to_city_country'), url(r'^customer-adjust/(?P<order_hash>\w+)/$', 'customer_order_detail',
from django.core.urlresolvers import reverse as url from django.test import TestCase from django.test.client import Client from django.utils.encoding import smart_str from django.utils.translation import get_language from django.contrib.sites.models import Site from keyedcache import cache_delete from l10n.models import Country from l10n.utils import moneyfmt from product.utils import rebuild_pricing from satchmo_store.shop.satchmo_settings import get_satchmo_setting from satchmo_store.shop.tests import get_step1_post_data from django.core.cache import cache domain = 'http://example.com' prefix = get_satchmo_setting('SHOP_BASE') if prefix == '/': prefix = '' class ShopTest(TestCase): fixtures = ['l10n-data.yaml', 'sample-store-data.yaml', 'products.yaml', 'test-config.yaml', 'initial_data.yaml'] def setUp(self): # Every test needs a client cache_delete() self.client = Client() self.US = Country.objects.get(iso2_code__iexact = "US") current_site = Site.objects.get_current() cache_key = "cat-%s-%s" % (current_site.id, get_language()) cache.delete(cache_key) rebuild_pricing()
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 = timezone.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))
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(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.')}) # 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 = timezone.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(request, template, ctx)
from django.conf.urls.defaults import patterns from satchmo_store.shop.satchmo_settings import get_satchmo_setting ssl = get_satchmo_setting("SSL", default_value=False) urlpatterns = patterns( "", (r"^$", "satchmo.payment.paybox.views.pay_ship_info", {"SSL": ssl}, "PAYBOX_satchmo_checkout-step2"), ( r"^confirm/$", "site_v1.ext.satchmo.payment.paybox.views.confirm_info", {"SSL": ssl}, "PAYBOX_satchmo_checkout-step3", ), (r"^success/$", "payment.views.checkout.success", {"SSL": ssl}, "PAYBOX_satchmo_checkout-success"), ( r"^failure/$", "django.views.generic.simple.direct_to_template", {"SSL": ssl, "template": "shop/checkout/failure.html"}, "PAYBOX_satchmo_checkout-failure", ), ( r"^cancelled/$", "django.views.generic.simple.direct_to_template", {"SSL": ssl, "template": "shop/checkout/cancelled.html"}, "PAYBOX_satchmo_checkout-cancelled", ), (r"^cb/$", "satchmo.payment.paybox.views.cb", {"SSL": ssl}, "PAYBOX_satchmo_checkout-cb"), ( r"^confirmorder/$", "payment.views.confirm.confirm_free_order",
def confirm_info(request): payment_module = config_get_group('PAYMENT_DOTPAY') 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 # DOTPAY 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 DOTPAY 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 amount = order.balance template = lookup_template(payment_module, 'shop/checkout/dotpay/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.DOTPAY_DOTID.value, payment_module.MERCHANT_CURRENCY.value, "0", #TransactionType url_callback, signature_code, ) ) ) else: signature_data = ''.join( map(str, ( amount, xchg_order_id, payment_module.DOTPAY_DOTID.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, 'DOTPAY_DOTID': payment_module.DOTPAY_DOTID.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'), 'contact':order.contact, } return render_to_response(template, ctx, context_instance=RequestContext(request))
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'), } log.debug(ctx) return render_to_response(template, ctx, context_instance=RequestContext(request))