def mapRUID_URL(self, unique_ruid, portal): ruid_url = {} for uid in unique_ruid: url = uuidToURL(uid) if url is not None: ruid_url[uid] = url return ruid_url
def replace_uuid(match): value = match.group() uuid = match.group(3) if not uuid: return value item = uuidToObject(uuid) if not item: return value return u'"{0}"'.format(uuidToURL(uuid))
def __call__(self): if self.uuid is None: raise KeyError("No UUID given in sub-path. Use .../@@redirect-to-uuid/<uuid>") url = uuidToURL(self.uuid) if url is None: raise NotFound(self, self.uuid) self.request.response.redirect(url) return u""
def __call__(self): if self.uuid is None: raise KeyError("No UUID given in sub-path. Use .../@@redirect-to-uuid/<uuid>") url = uuidToURL(self.uuid) if url is None: raise NotFound(self, self.uuid) self.request.response.redirect(url) return u''
def test_uuidToURL(self): from plone.uuid.interfaces import IUUID from plone.app.uuid.utils import uuidToURL portal = self.layer['portal'] setRoles(portal, TEST_USER_ID, ['Manager']) portal.invokeFactory('Document', 'd1') portal.invokeFactory('Document', 'd2') d1 = portal['d1'] uuid = IUUID(d1) self.assertEqual(d1.absolute_url(), uuidToURL(uuid))
def listing(self): # XXX: discount ret = list() for booking in self.order_data.bookings: ret.append({ 'title': booking.attrs['title'], 'url': uuidToURL(booking.attrs['buyable_uid']), 'count': booking.attrs['buyable_count'], 'net': ascur(booking.attrs.get('net', 0.0)), 'discount_net': ascur(float(booking.attrs['discount_net'])), 'vat': booking.attrs.get('vat', 0.0), 'exported': booking.attrs['exported'], 'comment': booking.attrs['buyable_comment'], 'quantity_unit': booking.attrs.get('quantity_unit'), 'currency': booking.attrs.get('currency'), }) return ret
def __call__(self): url = uuidToURL(self.uuid) if not url: # BBB for kupu hook = getattr(self.context, 'kupu_resolveuid_hook', None) if hook: obj = hook(uuid) if not obj: raise NotFound("The link you followed is broken") url = obj.absolute_url() if not url: raise NotFound("The link you followed is broken") if self.subpath: url = '/'.join([url] + self.subpath) if self.request.QUERY_STRING: url += '?' + self.request.QUERY_STRING self.request.response.redirect(url, status=301) return ''
def __call__(self, **kw): uid = self.request['uid'] base_url = self.context.absolute_url() registry = getUtility(IRegistry) settings = registry.forInterface(IKlarnaPaymentSettings) data = IPaymentData(self.context).data(uid) #amount = data['amount'] #description = data['description'] #ordernumber = data['ordernumber'] currency = data['currency'] #get items for klarna order_data = OrderData(self.context, uid) order = dict(order_data.order.attrs) # Merchant ID eid = settings.klarna_eid # Shared Secret shared_secret = settings.klarna_secret #other settings from control panel terms_uri = settings.klarna_terms_uri checkout_uri = settings.klarna_checkout_uri confirmation_uri = settings.klarna_confirmation_uri push_uri = settings.klarna_push_uri #Add the cart items cart = list() for booking in order_data.bookings: cart.append({ 'quantity': int(booking.attrs['buyable_count']), 'reference': uuidToURL(booking.attrs['buyable_uid']), 'name': booking.attrs['title'], 'unit_price': int((booking.attrs.get('net', 0.0)*100)+(booking.attrs.get('net', 0.0)*booking.attrs.get('vat', 0.0))), 'discount_rate': int((booking.attrs['discount_net'])*100), 'tax_rate': int(booking.attrs.get('vat', 0.0)*100), }) create_data = {} create_data["cart"] = {"items": []} for item in cart: create_data["cart"]["items"].append(item) #Configure the checkout order #import pdb; pdb.set_trace() create_data['purchase_country'] = 'NO' create_data['purchase_currency'] = currency create_data['locale'] = 'nb-no' create_data['shipping_address'] = { 'email' : order['personal_data.email'], 'postal_code' : order['billing_address.zip'], } create_data['merchant'] = { 'id' : eid, 'terms_uri' : terms_uri, 'checkout_uri' : checkout_uri, 'confirmation_uri' : confirmation_uri, 'push_uri' : push_uri, } # Create a checkout order klarnacheckout.Order.base_uri = \ 'https://checkout.testdrive.klarna.com/checkout/orders' klarnacheckout.Order.content_type = \ 'application/vnd.klarna.checkout.aggregated-order-v2+json' connector = klarnacheckout.create_connector(shared_secret) order = klarnacheckout.Order(connector) order.create(create_data) # Render the checkout snippet order.fetch() # Store location of checkout session #session["klarna_checkout"] = order.location # Display checkout return "<div>%s</div>" % (order["gui"]["snippet"])
def resolve_buyable_url(context, booking): return uuidToURL(booking.attrs['buyable_uid'])