def payment_text(self, payment): settings = get_shop_payment_settings() portal_state = self.context.restrictedTraverse('@@plone_portal_state') lang = portal_state.language() for entry in settings.payment_text: if entry['lang'] == lang and entry['payment'] == payment: return entry['text'] return u''
def payment_text(self, payment): settings = get_shop_payment_settings() portal_state = self.context.restrictedTraverse("@@plone_portal_state") lang = portal_state.language() for entry in settings.payment_text: if entry["lang"] == lang and entry["payment"] == payment: return entry["text"] return u""
def surcharge_vat(self, working_total): try: settings = get_shop_payment_settings() except KeyError: # happens GS profile application if registry entries not present # yet return Decimal('0') surcharge_net = self.surcharge_net(working_total) vat_percentage = (Decimal(str((settings.surcharge_vat))) if settings.surcharge_vat else Decimal('0')) return (surcharge_net / Decimal(100)) * vat_percentage
def percent_surcharge(self): try: settings = get_shop_payment_settings() except KeyError: # happens GS profile application if registry entries not present # yet return Decimal('0') surcharge = settings.percent_surcharge if surcharge: return format_amount(Decimal(str(surcharge))) else: return ''
def surcharge_net(self, working_total): try: settings = get_shop_payment_settings() except KeyError: # happens GS profile application if registry entries not present # yet return Decimal('0') fixed = (Decimal(str(settings.fixed_surcharge)) if settings.fixed_surcharge else Decimal('0')) percent = (Decimal(str(settings.percent_surcharge)) if settings.percent_surcharge else Decimal('0')) return (working_total * percent) / Decimal('100') + fixed
def skip_payment(self, uid): settings = get_shop_payment_settings() order_data = OrderData(self.context, uid=uid) # order total is 0, skip if not Decimal(str(order_data.total)).quantize(Decimal("1.000")): return True # if payment should be skipped if order contains reservations and # order contains reservations, skip if settings.skip_payment_if_order_contains_reservations: if order_data.state in (STATE_RESERVED, STATE_MIXED): return True return False
def skip_payment(self, uid): settings = get_shop_payment_settings() order_data = OrderData(self.context, uid=uid) # order total is 0, skip if not Decimal(str(order_data.total)).quantize(Decimal('1.000')): return True # if payment should be skipped if order contains reservations and # order contains reservations, skip if settings.skip_payment_if_order_contains_reservations: if order_data.state in (STATE_RESERVED, STATE_MIXED): return True return False
def costs(self): try: settings = get_shop_payment_settings() except KeyError: # happens GS profile application if registry entries not present # yet return Decimal('0') costs = settings.cash_on_delivery_costs if costs: costs = Decimal(str(costs)) else: costs = Decimal('0') return format_amount(costs)
def payment_method_surchargeable(self): settings = get_shop_payment_settings() return settings.surchargeable_payment_methods
def default(self): settings = get_shop_payment_settings() return settings.payment_method
def available(self): settings = get_shop_payment_settings() return settings.available_payment_methods