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)
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)
def pay_ship_render_form(request, form, template, payment_module, cart): template = lookup_template(payment_module, template) ctx = { 'form': form, 'PAYMENT_LIVE': gateway_live(payment_module), } return render(request, template, ctx)
def get_cred(): gateway_settings = config_get_group('PAYMENT_GOOGLE') live = gateway_live(gateway_settings) # get key and value if live: merchant_id = gateway_settings.MERCHANT_ID.value merchant_key = gateway_settings.MERCHANT_KEY.value else: merchant_id = gateway_settings.MERCHANT_TEST_ID.value merchant_key = gateway_settings.MERCHANT_TEST_KEY.value return (merchant_id, merchant_key)
def get_cred(): payment_module = config_get_group('PAYMENT_GOOGLE') live = gateway_live(payment_module) # get key and value if live: merchant_id = payment_module.MERCHANT_ID.value merchant_key = payment_module.MERCHANT_KEY.value else: merchant_id = payment_module.MERCHANT_TEST_ID.value merchant_key = payment_module.MERCHANT_TEST_KEY.value return (merchant_id, merchant_key)
def get_url(): """ Returns the urls needed """ (merchant_id, merchant_key) = get_cred() payment_module = config_get_group('PAYMENT_GOOGLE') live = gateway_live(payment_module) if live: url_template = payment_module.POST_URL.value else: url_template = payment_module.POST_TEST_URL.value post_url = url_template % {'MERCHANT_ID': merchant_id} return post_url
def get_url(): """ Returns the urls needed """ (merchant_id, merchant_key) = get_cred() gateway_settings = config_get_group('PAYMENT_GOOGLE') live = gateway_live(gateway_settings) if live: url_template = gateway_settings.POST_URL.value else: url_template = gateway_settings.POST_TEST_URL.value post_url = url_template % {'MERCHANT_ID' : merchant_id} return post_url
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)
def _onForm(self, controller): """Show the confirmation page for the order. Looks up the proper template for the payment_module. """ template = controller.lookup_template('CONFIRM') controller.order.recalculate_total() context = { 'PAYMENT_LIVE': gateway_live(controller.paymentModule), 'default_view_tax': controller.viewTax, 'order': controller.order, 'errors': controller.processorMessage, 'checkout_step2': controller.lookup_url('satchmo_checkout-step2') } if controller.extra_context: context.update(controller.extra_context) return render(self.request, template, context)
def confirm_info(request): payment_module = stripe_config controller = confirm.ConfirmController(request, payment_module) if not controller.sanity_check(): return controller.response live = gateway_live(payment_module) default_view_tax = config_value('TAX', 'DEFAULT_VIEW_TAX') ctx = { 'PAYMENT_LIVE': live } controller.extra_context = ctx controller.confirm() return controller.response
def _onForm(self, controller): """Show the confirmation page for the order. Looks up the proper template for the payment_module. """ template = controller.lookup_template('CONFIRM') controller.order.recalculate_total() base_env = { 'PAYMENT_LIVE' : gateway_live(controller.paymentModule), 'default_view_tax' : controller.viewTax, 'order': controller.order, 'errors': controller.processorMessage, 'checkout_step2': controller.lookup_url('satchmo_checkout-step2')} if controller.extra_context: base_env.update(controller.extra_context) context = RequestContext(self.request, base_env) return render_to_response(template, context_instance=context)
def confirm_info(request): payment_module = config_get_group('PAYMENT_GOOGLE') controller = confirm.ConfirmController(request, payment_module) if not controller.sanity_check(): return controller.response live = gateway_live(payment_module) gcart = GoogleCart(controller.order, payment_module, live) log.debug("CART:\n%s", gcart.cart_xml) post_url = auth.get_url() default_view_tax = config_value('TAX', 'DEFAULT_VIEW_TAX') ctx = { 'post_url': post_url, 'google_cart' : gcart.encoded_cart(), 'google_signature' : gcart.encoded_signature(), 'PAYMENT_LIVE' : live } controller.extra_context = ctx controller.confirm() return controller.response
def confirm_info(request): payment_module = config_get_group('PAYMENT_GOOGLE') controller = confirm.ConfirmController(request, payment_module) if not controller.sanity_check(): return controller.response live = gateway_live(payment_module) gcart = GoogleCart(controller.order, payment_module, live) log.debug("CART:\n%s", gcart.cart_xml) post_url = auth.get_url() default_view_tax = config_value('TAX', 'DEFAULT_VIEW_TAX') ctx = { 'post_url': post_url, 'google_cart': gcart.encoded_cart(), 'google_signature': gcart.encoded_signature(), 'PAYMENT_LIVE': live } controller.extra_context = ctx controller.confirm() return controller.response
def confirm_info(request): payment_module = config_get_group('PAYMENT_PAYPAL') 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/paypal/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') recurring = None # 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 if item.product.has_variants: price = item.product.productvariation.get_qty_price( item.quantity, True) else: price = item.product.get_qty_price(item.quantity, True) recurring = { 'product': item.product, 'price': 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, '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)
def confirm_info(request): payment_module = config_get_group('PAYMENT_PAYPAL') 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/paypal/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') recurring = None # 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 if item.product.has_variants: price = item.product.productvariation.get_qty_price(item.quantity, True) else: price = item.product.get_qty_price(item.quantity, True) recurring = {'product':item.product, 'price':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, '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)
def confirm_info(request): shop = Config.objects.get_current() payment_module = config_get_group('PAYMENT_PAYBOX') try: order = Order.objects.from_request(request) except Order.DoesNotExist: url = lookup_url(payment_module, 'satchmo_checkout-step1') return HttpResponseRedirect(url) log.debug(order) 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)) # 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/paybox/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.ID.value bksite = payment_module.SITE.value rank = payment_module.RANK.value else: url = payment_module.POST_TEST_URL.value account = payment_module.ID_TEST.value bksite = payment_module.SITE_TEST.value rank = payment_module.RANK_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 processor_module = payment_module.MODULE.load_module('processor') processor = processor_module.PaymentProcessor(payment_module) processor.create_pending_payment(order=order) # Tax default_view_tax = config_value('TAX', 'DEFAULT_VIEW_TAX') amount=order.balance # use external sw for creation of the form (and notification of payment on paybox platform) log.debug("To be payed : %s", amount) # ./modulev3.cgi PBX_MODE=4 PBX_SITE=1999888 binprog = payment_module.BIN_PROG_FULLPATH.value args=[binprog,] args.append('PBX_MODE=4') args.append('PBX_SITE=%s'%bksite) args.append('PBX_RANG=%s'%rank) args.append('PBX_IDENTIFIANT=%s'%account) args.append('PBX_TOTAL=%d'%(int(amount*100))) args.append('PBX_CMD=%s'%order.id) args.append('PBX_PORTEUR=%s'%order.contact.email) args.append('PBX_DEVISE=%s'%PBX_DEVISES_ISO_4217['EUR']) if request.LANGUAGE_CODE=='fr': pbx_country_code='FRA' elif request.LANGUAGE_CODE=='es': pbx_country_code='ESP' elif request.LANGUAGE_CODE=='it': pbx_country_code='ITA' elif request.LANGUAGE_CODE=='de': pbx_country_code='DEU' elif request.LANGUAGE_CODE=='nl': pbx_country_code='NLD' else: pbx_country_code='GBR' args.append('PBX_LANGUE=%s'%pbx_country_code) args.append('PBX_RETOUR=amount:M;ref:R;autho:A;trans:T;type:P;card:C;idtrans:S;country:Y;error:E;valid:D;IP:I;BIN6:N;last2:J;tstmp:W;dgst:H;sign:K') args.append('PBX_OUTPUT=C') returl = lookup_url(payment_module,payment_module.RETURN_ADDRESS.value) args.append('PBX_EFFECTUE=%s%s'%(shop.base_url,returl)) returl = lookup_url(payment_module,payment_module.FAILURE_ADDRESS.value) args.append('PBX_REFUSE=%s%s'%(shop.base_url,returl)) returl = lookup_url(payment_module,payment_module.CANCELLED_ADDRESS.value) args.append('PBX_ANNULE=%s%s'%(shop.base_url,returl)) # Url directly called by paybox servers : in test mode, need to be specified if not payment_module.LIVE.value: http_callback_url = lookup_url(payment_module,'PAYBOX_satchmo_checkout-cb') args.append('PBX_REPONDRE_A=%s%s'%(shop.base_url,http_callback_url)) if not payment_module.LIVE.value: args.append('PBX_PAYBOX=%s' % url) args.append('PBX_BACKUP1=%s' % url) args.append('PBX_BACKUP2=%s' % url) log.debug("Arguments : %s ", str(args)) # Finish form footer_start = "<br /><div class='wide acenter'><input style='font-size:10px;' type='SUBMIT' value='" footer_end = "' /></div> </FORM>" value = _('Pay') footer = '%s%s%s'%(footer_start,value,footer_end) # footer= "<br /><INPUT CLASS='button' style='height:22px;font-size:10px;' TYPE='SUBMIT' VALUE='Payer' /> </FORM>" formstr = mark_safe("%s %s" % (Popen(args, stdout=PIPE).communicate()[0], footer ) ) log.debug("form proposed by bin : %s", str(formstr)) # No support for subscription. ctx = RequestContext( request, {'order': order, 'default_view_tax': default_view_tax, 'post_url': url, 'account': account, 'site' : bksite, 'rank' : rank, 'currency_code': 'EUR', 'return_address': address, 'invoice': order.id, 'PAYMENT_LIVE' : gateway_live(payment_module), 'formstr':formstr }) return render_to_response(template, context_instance=ctx)
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, 'business': account, 'currency_code': payment_module.CURRENCY_CODE.value, 'return_address': address, 'invoice': order.id, 'pagseguro': pagsegurohtml, 'subscription': recurring, 'PAYMENT_LIVE' : gateway_live(payment_module) }) return render_to_response(template, context_instance=ctx)
def confirm_info(request): payment_module = config_get_group('PAYMENT_CONCARDIS') 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(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.')}) # Make sure the order has an ORDER_ID try: order_id = order.get_variable('ORDER_ID').value except AttributeError: order_id = _get_order_id() order.add_variable('ORDER_ID', order_id) template = lookup_template(payment_module, 'shop/checkout/concardis/confirm.html') if payment_module.LIVE.value: log.debug("live order on %s", payment_module.KEY.value) url = payment_module.POST_URL.value else: url = payment_module.POST_TEST_URL.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: # pylint: disable=bare-except cart = None try: contact = Contact.objects.from_request(request) except: # pylint: disable=bare-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') recurring = None passphrase = payment_module.SHA_IN_PASSPHRASE.value address_b = order.contact.billing_address # Add return URLs accept_url = 'https://{}{}'.format( settings.SITE_DOMAIN, reverse('CONCARDIS_satchmo_checkout-success'), ) params = OrderedDict(( ('ACCEPTURL', accept_url), ('AMOUNT', int(order.balance * 100)), # Amount without decimals ('CN', order.contact.first_name + ' ' + order.contact.last_name), ('CURRENCY', payment_module.CURRENCY_CODE.value), ('EMAIL', order.contact.email), ('OPERATION', 'SAL'), # Set payment to direct sale ('ORDERID', order_id), ('OWNERADDRESS', ' '.join([address_b.street1, address_b.street2])), ('OWNERCTY', address_b.country.iso2_code), ('OWNERTOWN', address_b.city), ('OWNERZIP', address_b.postal_code), ('PARAMVAR', settings.SHORT_NAME), # Used to identify site in callbacks ('PSPID', payment_module.PSPID.value), )) # Create a sha1 digest of the parameters params['SHASIGN'] = sha1_sign(params, passphrase) # Make sure params are sorted alphabetically params = OrderedDict(sorted(params.items(), key=lambda t: t[0])) return render( request, template, { 'order': order, 'post_url': url, 'default_view_tax': default_view_tax, 'return_address': address, 'subscription': recurring, 'PAYMENT_LIVE': gateway_live(payment_module), 'params': params, })
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)