text
stringlengths 0
828
|
|---|
Bucuresti9Bucuresti2RO8CCVISAMC5GROSS5GROSS5GROSS4TRUE
|
Using this string and the MERCHANT_KEY, we compute the HMAC.
|
""""""
|
hashable_fields = ['MERCHANT', 'ORDER_REF', 'ORDER_DATE',
|
'ORDER_SHIPPING', 'PRICES_CURRENCY', 'DISCOUNT',
|
'DESTINATION_CITY', 'DESTINATION_STATE',
|
'DESTINATION_COUNTRY', 'PAY_METHOD',
|
'SELECTED_INSTALLMENTS_NO', 'TESTORDER']
|
result = text_type()
|
# We need this hack since payU is not consistent
|
# with the order of fields in hash string
|
suffix = text_type()
|
for field in self:
|
if field.name == 'ORDER_HASH':
|
continue
|
field_value = field.value()
|
if field.name in hashable_fields and field_value:
|
encoded_value = text_type('{length}{value}').format(
|
length=len(text_type(field_value).encode('utf-8')), value=field_value
|
)
|
if field.name == 'TESTORDER' or \
|
field.name == 'SELECTED_INSTALLMENTS_NO':
|
suffix += encoded_value
|
else:
|
result += encoded_value
|
if field.name == 'ORDER':
|
for detail in PAYU_ORDER_DETAILS:
|
if any([detail in order and order[detail]
|
for order in field_value]):
|
for order in field_value:
|
value = order.get(detail, '')
|
item = text_type('{length}{value}').format(
|
length=len(text_type(value).encode('utf-8')), value=value
|
)
|
if detail == 'PRICE_TYPE':
|
suffix += item
|
else:
|
result += item
|
result += suffix
|
result = result.encode('utf-8')
|
return hmac.new(PAYU_MERCHANT_KEY, result).hexdigest()"
|
629,"def _prepare_orders(self, orders):
|
""""""
|
Each order needs to have all it's details filled with default value,
|
or None, in case those are not already filled.
|
""""""
|
for detail in PAYU_ORDER_DETAILS:
|
if not any([detail in order for order in orders]):
|
for order in orders:
|
order[detail] = PAYU_ORDER_DETAILS_DEFAULTS.get(detail, None)
|
return orders"
|
630,"def staticfiles_url_fetcher(url):
|
""""""
|
Returns the file matching url.
|
This method will handle any URL resources that rendering HTML requires
|
(eg: images pointed my ``img`` tags, stylesheets, etc).
|
The default behaviour will fetch any http(s) files normally, and will
|
also attempt to resolve staticfiles internally (this should mostly
|
affect development scenarios, but also works if static files are served
|
under a relative url).
|
Returns a dictionary with two entries: ``string``, which is the
|
resources data as a string and ``mime_type``, which is the identified
|
mime type for the resource.
|
""""""
|
if url.startswith('/'):
|
base_url = staticfiles_storage.base_url
|
filename = url.replace(base_url, '', 1)
|
path = finders.find(filename)
|
if path:
|
# This should match most cases. Manifest static files with relative
|
# URLs will only be picked up in DEBUG mode here.
|
with open(path, 'rb') as f:
|
data = f.read()
|
else:
|
# This should just match things like Manifest static files with
|
# relative URLs. While this code path will expect `collectstatic`
|
# to have run, it should only be reached on if DEBUG = False.
|
# XXX: Only Django >= 2.0 supports using this as a context manager:
|
f = staticfiles_storage.open(filename)
|
data = f.read()
|
f.close()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.