Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,38 @@ This method takes some parameters, the explanation of them is the following:
- '02': online payment: the user is presented a list of online bank platforms to complete the payment

- **test_environment**: (default: False) a boolean to use the testing environment of the Payment Service.

- **extra**: (default: {}): a dict to override default values of the payment service configuration. Currently supported values are the following:
- 'message1': format: {'eu': 'XX', 'es': 'XX'}: basque and spanish texts to override the footer value of the payment document in PDF format

- 'message2': format: {'eu': 'XX', 'es': 'XX'}: basque and spanish texts to override the first legal text of the payment document in PDF format

- 'message3': format: {'eu': 'XX', 'es': 'XX'}: basque and spanish texts to override the second legal text of the payment document in PDF format

- 'message4': format: {'eu': 'XX', 'es': 'XX'}: basque and spanish texts to override the header text of the payment document in PDF format

- 'message_payment_title': format: {'eu': 'XX', 'es': 'XX'}: basque and spanish text to override the name of the payment .

- 'message_payment_description': format: {'eu': 'XX', 'es': 'XX'}: basque and spanish text to show the concept of the payment.

- 'citizen_name': text to show citizen's citizen_name in the payment document.

- 'citizen_surname_1': text to show citizen's citizen_surname_1 in the payment document.

- 'citizen_surname_2': text to show citizen's citizen_surname_2 in the payment document.

- 'citizen_nif': text to show citizen's citizen_nif in the payment document.

- 'citizen_address': text to show citizen's citizen_address in the payment document.

- 'citizen_postal_code': text to show citizen's citizen_postal_code in the payment document.

- 'citizen_territory': text to show citizen's citizen_territory in the payment document.

- 'citizen_country': text to show citizen's citizen_country in the payment document.

- 'citizen_phone': text to show citizen's citizen_phone in the payment document.

- 'citizen_email': text to show citizen's citizen_email in the payment document.


33 changes: 20 additions & 13 deletions pymipago/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .constants import MESSAGE_3_TEMPLATE
from .constants import MESSAGE_4_TEMPLATE
from .constants import MESSAGE_PAYMENT_TITLE
from .constants import MESSAGE_PAYMENT_DESCRIPTION
from .constants import PRESENTATION_XML
from .constants import PROTOCOL_DATA_XML
from .exceptions import InvalidCPRValue
Expand Down Expand Up @@ -69,42 +70,48 @@ def make_payment_request(
sender, reference_number, payment_identification, quantity)



# Message overrides

message_1 = ''
if 'message_1' in extra:
message_1 = MESSAGE_1_TEMPLATE.format(
es=extra.get('message_1').get('es'),
eu=extra.get('message_1').get('eu'),
es=extra.get('message_1').get('es', ''),
eu=extra.get('message_1').get('eu', ''),
)

message_2 = ''
if 'message_2' in extra:
message_2 = MESSAGE_2_TEMPLATE.format(
es=extra.get('message_2').get('es'),
eu=extra.get('message_2').get('eu'),
es=extra.get('message_2').get('es', ''),
eu=extra.get('message_2').get('eu', ''),
)

message_3 = ''
if 'message_3' in extra:
message_3 = MESSAGE_3_TEMPLATE.format(
es=extra.get('message_3').get('es'),
eu=extra.get('message_3').get('eu'),
es=extra.get('message_3').get('es', ''),
eu=extra.get('message_3').get('eu', ''),
)

message_4 = ''
if 'message_4' in extra:
message_4 = MESSAGE_4_TEMPLATE.format(
es=extra.get('message_4').get('es'),
eu=extra.get('message_4').get('eu'),
es=extra.get('message_4').get('es', ''),
eu=extra.get('message_4').get('eu', ''),
)

message_payment_title = ''
if 'message_payment_title' in extra:
message_payment_title = MESSAGE_PAYMENT_TITLE.format(
es=extra.get('message_payment_title').get('es'),
eu=extra.get('message_payment_title').get('eu'),
es=extra.get('message_payment_title').get('es', ''),
eu=extra.get('message_payment_title').get('eu', ''),
)

mipago_payment_description = ''
if 'mipago_payment_description' in extra:
mipago_payment_description = MESSAGE_PAYMENT_DESCRIPTION.format(
es=extra.get('mipago_payment_description').get('es', ''),
eu=extra.get('mipago_payment_description').get('eu', ''),
)

initialization_xml = INITIALIZATION_XML.format(
Expand All @@ -123,18 +130,18 @@ def make_payment_request(
message_3=message_3,
message_4=message_4,
message_payment_title=message_payment_title,
mipago_payment_description=mipago_payment_description,
citizen_name=extra.get('citizen_name', ''),
citizen_surname_1=extra.get('citizen_surname_1', ''),
citizen_surname_2=extra.get('citizen_surname_2', ''),
citizen_city=extra.get('citizen_city', ''),
citizen_nif=extra.get('citizen_nif', ''),
citizen_address=extra.get('citizen_address', ''),
citizen_postal_code=extra.get('citizen_postal_code', ''),
citizen_territory=extra.get('citizen_territory', ''),
citizen_country=extra.get('citizen_country', ''),
citizen_phone=extra.get('citizen_phone', ''),
citizen_email=extra.get('citizen_email', ''),
mipago_payment_description_es=extra.get('mipago_payment_description_es', ''),
mipago_payment_description_eu=extra.get('mipago_payment_description_eu', ''),
)

response = requests.post(
Expand Down
18 changes: 11 additions & 7 deletions pymipago/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
<primerApellido>{citizen_surname_1}</primerApellido>
<segundoApellido>{citizen_surname_2}</segundoApellido>
<razonSocial>{citizen_name}</razonSocial>
<dniNif>{citizen_name}</dniNif>
<calle>{citizen_nif}</calle>
<municipio>{citizen_address}</municipio>
<dniNif>{citizen_nif}</dniNif>
<calle>{citizen_address}</calle>
<municipio>{citizen_city}</municipio>
<codigoPostal>{citizen_postal_code}</codigoPostal>
<territorio>{citizen_territory}</territorio>
<pais>{citizen_country}</pais>
Expand All @@ -63,10 +63,7 @@
<conceptoPeticion>
<numeroLinea>1</numeroLinea>
<baseImponible>0</baseImponible>
<descripcion>
<eu>{mipago_payment_description_eu}</eu>
<es>{mipago_payment_description_es}</es>
</descripcion>
{mipago_payment_description}
<unidades>1</unidades>
<tieneIVARepercutido>false</tieneIVARepercutido>
<IVARepercutido>false</IVARepercutido>
Expand Down Expand Up @@ -118,11 +115,18 @@
</urls>
</protocolData>
'''

MESSAGE_PAYMENT_TITLE = '''<descripcion>
<eu>{eu}</eu>
<es>{es}</es>
</descripcion>'''

MESSAGE_PAYMENT_DESCRIPTION = '''<descripcion>
<eu>{eu}</eu>
<es>{es}</es>
</descripcion>'''


MESSAGE_1_TEMPLATE = """<mensaje id="1">
<texto>
<eu>{eu}</eu>
Expand Down