Skip to content

Commit

Permalink
new: "DOCDATA_CSS_ID" to fix Attribute 'id' must appear on element 'n…
Browse files Browse the repository at this point in the history
  • Loading branch information
jedie committed Jan 21, 2019
1 parent dbd560c commit eb1b960
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 14 deletions.
3 changes: 3 additions & 0 deletions oscar_docdata/appsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,6 @@
'0091': 'Friesland Bank',
'0161': 'van Lanschot Bankiers'
})

# CSS file selection in the payment menu
DOCDATA_CSS_ID = getattr(settings, 'DOCDATA_CSS_ID', 1)
75 changes: 61 additions & 14 deletions oscar_docdata/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,18 +260,20 @@ def merchant_name(self):
"""
return self.merchant._name

def create(self,
order_id,
total_gross_amount,
shopper,
bill_to,
description,
invoice=None,
receiptText=None,
includeCosts=False,
profile=appsettings.DOCDATA_PROFILE,
days_to_pay=appsettings.DOCDATA_DAYS_TO_PAY,
):
def create(
self,
order_id,
total_gross_amount,
shopper,
bill_to,
description,
invoice=None,
receiptText=None,
includeCosts=False,
profile=appsettings.DOCDATA_PROFILE,
days_to_pay=appsettings.DOCDATA_DAYS_TO_PAY,
css_id=appsettings.DOCDATA_CSS_ID,
):
"""
Create the payment in docdata.
Expand Down Expand Up @@ -309,7 +311,8 @@ def create(self,
# paymentPreferences.exhortation.period2 ?

# Menu preferences are empty. They are used for CSS file selection in the payment menu.
menuPreferences = self.client.factory.create('ns0:menuPreferences')
css = StyleSheetID(id=css_id)
menuPreferences = MenuPreferences(css)

# Execute create payment order request.
#
Expand All @@ -329,7 +332,7 @@ def create(self,
merchant=self.merchant,
merchantOrderReference=order_id,
paymentPreferences=paymentPreferences,
menuPreferences=menuPreferences,
menuPreferences=menuPreferences.to_xml(factory),
shopper=shopper.to_xml(factory),
totalGrossAmount=total_gross_amount.to_xml(factory),
billTo=bill_to.to_xml(factory),
Expand Down Expand Up @@ -851,6 +854,50 @@ def to_xml(self, factory):
return element


class StyleSheetID:
"""
The id of the CSS file that should be used in the payment menu.
<complexType name="menuPreferences">
<sequence>
<element name="css" minOccurs="0" maxOccurs="1">
<annotation>
<documentation>
The id of the CSS file that should be used in
the payment menu.
</documentation>
</annotation>
<complexType>
<attribute name="id" type="int" use="required"/>
</complexType>
</element>
</sequence>
</complexType>
"""

def __init__(self, id):
self.id = int(id)

def to_xml(self, factory):
node = factory.create("ns0:css")
node.id = id
return node

class MenuPreferences:
"""
CSS file selection in the payment menu
"""

def __init__(self, css):
assert isinstance(css, StyleSheetID)
self.css = css

def to_xml(self, factory):
node = factory.create("ns0:menuPreferences")
node.css = self.css.to_xml(factory)
return node


class Quantity(object):
"""
An quantity for Docdata
Expand Down

0 comments on commit eb1b960

Please sign in to comment.