[FIX] payment_alipay: format Alipay API parameter total_fee correctly

Steps to reproduce:
* setup Alipay in test mode (note that Alipay's test node only support
  one currency: the USD)
* create an invoice. Make sure the invoice's total has decimal places
* generate a payment link for that invoice
* go to the generated link
* select Alipay as the payment method and click pay.

You should be met with an INVALID_PARAMETER message.

Cause:
Alipay's doc states that the parameter 'total_fee' can only have two
decimal places. Currently, this requirement is not always respected

opw-2996278

closes odoo/odoo#102088

X-original-commit: 2e6e338e8c4e042a671814673c6f3d0e4e4f50dc
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
This commit is contained in:
Nshimiyimana Séna
2022-10-04 17:01:41 +02:00
committed by Antoine Vandevenne (anv)
parent b54ab3dbf0
commit d99c9ca124
2 changed files with 2 additions and 2 deletions
@@ -44,7 +44,7 @@ class PaymentTransaction(models.Model):
'partner': self.provider_id.alipay_merchant_partner_id,
'return_url': urls.url_join(base_url, AlipayController._return_url),
'subject': self.reference,
'total_fee': total_fee,
'total_fee': f'{total_fee:.2f}',
}
if self.provider_id.alipay_payment_method == 'standard_checkout':
# https://global.alipay.com/docs/ac/global/create_forex_trade
+1 -1
View File
@@ -118,7 +118,7 @@ class AlipayTest(AlipayCommon, PaymentHttpCommon):
processing_values = tx._get_processing_values()
redirect_form_data = self._extract_values_from_html_form(processing_values['redirect_form_html'])
self.assertEqual(redirect_form_data['inputs']['total_fee'], str(total_fee))
self.assertEqual(redirect_form_data['inputs']['total_fee'], f'{total_fee:.2f}')
def test_21_standard_checkout_feedback(self):
self.alipay.alipay_payment_method = 'standard_checkout'