From bf2e541c27b613e17b5303d580a70c250d94b3ee Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Thu, 29 Mar 2018 17:17:11 +0200 Subject: [PATCH] [FIX] payment_stripe: partner info is not mandatory Before this commit, when accessing the payment page with arbitrary amount (/website_payment/pay?reference=Testinvoice&amount=150.0¤cy_id=6&country_id=) A traceback was thrown because the keys concerning the partner were not present in the dictionary that prepares the values for the form that we send to Stripe Considering that those info are not mandatory for stripe (although not very good practice -- the more info the better to verify an identity) we ignore them if not present After this commit, the public route works fine OPW 1832164 closes #23948 --- addons/payment_stripe/models/payment.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/addons/payment_stripe/models/payment.py b/addons/payment_stripe/models/payment.py index 72c797e6c7f..72c02fc5aed 100644 --- a/addons/payment_stripe/models/payment.py +++ b/addons/payment_stripe/models/payment.py @@ -40,16 +40,16 @@ class PaymentAcquirerStripe(models.Model): stripe_tx_values = dict(tx_values) temp_stripe_tx_values = { 'company': self.company_id.name, - 'amount': tx_values.get('amount'), - 'currency': tx_values.get('currency') and tx_values.get('currency').name or '', - 'currency_id': tx_values.get('currency') and tx_values.get('currency').id or '', - 'address_line1': tx_values['partner_address'], - 'address_city': tx_values['partner_city'], - 'address_country': tx_values['partner_country'] and tx_values['partner_country'].name or '', - 'email': tx_values['partner_email'], - 'address_zip': tx_values['partner_zip'], - 'name': tx_values['partner_name'], - 'phone': tx_values['partner_phone'], + 'amount': tx_values['amount'], # Mandatory + 'currency': tx_values['currency'].name, # Mandatory anyway + 'currency_id': tx_values['currency'].id, # same here + 'address_line1': tx_values.get('partner_address'), # Any info of the partner is not mandatory + 'address_city': tx_values.get('partner_city'), + 'address_country': tx_values.get('partner_country') and tx_values.get('partner_country').name or '', + 'email': tx_values.get('partner_email'), + 'address_zip': tx_values.get('partner_zip'), + 'name': tx_values.get('partner_name'), + 'phone': tx_values.get('partner_phone'), } temp_stripe_tx_values['returndata'] = stripe_tx_values.pop('return_url', '')