Skip to content

Commit

Permalink
[Imp #5] 3DSv2 integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Théo DRAPPIER committed Dec 6, 2021
1 parent 90e52c3 commit c89ed14
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion odoo/addons/payment_paybox/models/inherited_payment_acquirer.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,47 @@ def paybox_get_authentication_key(self):
else:
return self.paybox_test_authentication_key

@api.model
def paybox_generate_shopping_cart_xml(self, reference):
tx = self.env['payment.transaction'].search([('reference', '=', reference)])
qty = 1
if tx.sale_order_id:
qty = tx.sale_order_id.cart_quantity
elif tx.account_invoice_id:
qty = int(sum(tx.account_invoice_id.mapped('invoice_line_ids.quantity')))
return '''
<?xml version="1.0" encoding="utf-8"?>
<shoppingcart>
<total>
<totalQuantity>%d</totalQuantity>
</total>
</shoppingcart>
''' % qty

@api.model
def paybox_generate_billing_xml(self, partner):
return '''
<?xml version="1.0" encoding="utf-8"?>
<Billing>
<Address>
<FirstName>%s</FirstName>
<LastName>%s</LastName>
<Address1>%s</Address1>
<Address2>%s</Address2>
<ZipCode>%s</ZipCode>
<City>%s</City>
<CountryCode>%s</CountryCode>
</Address>
</Billing>
''' % (
partner.firstname,
partner.lastname,
partner.street,
partner.street2,
partner.zip_id.name,
partner.city_id.name,
partner.country_id.code_iso_num
)

@api.multi
def paybox_form_generate_values(self, values):
Expand Down Expand Up @@ -125,7 +166,9 @@ def paybox_form_generate_values(self, values):
('PBX_REFUSE', urlparse.urljoin(base_url, '/payment/paybox/dpn?return_url=%s' % values.get('return_url'))),
('PBX_ANNULE', urlparse.urljoin(base_url, '/payment/paybox/dpn?return_url=%s' % values.get('return_url'))),
('PBX_ATTENTE', urlparse.urljoin(base_url, '/payment/paybox/dpn?return_url=%s' % values.get('return_url'))),
('PBX_REPONDRE_A', urlparse.urljoin(base_url, '/payment/paybox/ipn'))
('PBX_REPONDRE_A', urlparse.urljoin(base_url, '/payment/paybox/ipn')),
('PBX_SHOPPINGCART', self.paybox_generate_shopping_cart_xml(values.get('reference'))),
('PBX_BILLING', self.paybox_generate_billing_xml(values.get('partner')))
]

signature = self.paybox_generate_message_hmac(vals)
Expand Down

0 comments on commit c89ed14

Please sign in to comment.