Skip to content

Commit

Permalink
[FIX] payment_authorize: Handle cc_expiry autocomplete
Browse files Browse the repository at this point in the history
Issue
	- Save a credit card in chrome
	- Install "Ecommerce" module
	- Activate/Publish "Authorize.net" payment acquirer
	- Set the "Payment Flow" field to "Payment from Odoo"
	- Save and go to front end shop
	- Add any product to cart and go to checkout process
	- Chose Authorize.net as payment mode
	- Fill with autocompletition the credit card form

	Error message:
	"e.g. Your credit card details are wrong. Please verify."

Cause

	It will not validate the expiry date if it has 4 digits number
	as year.

Solution

	Handle year date with datetime library:
	it allows to set 2 or 4 digits number as year.

opw-2239065

closes #52037

X-original-commit: e99044a
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
  • Loading branch information
nboulif committed May 28, 2020
1 parent d659b89 commit fa525a5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion addons/payment_authorize/models/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ def authorize_s2s_form_validate(self, data):
if len(cc_expiry) != 2 or any(not i.isdigit() for i in cc_expiry):
return False
try:
if datetime.now().strftime('%y%m') > datetime.strptime('/'.join(cc_expiry), '%m/%y').strftime('%y%m'):
expiry_date = datetime.strptime('/'.join(cc_expiry), '%m/%{}'.format("y" if len(cc_expiry[1]) == 2 else "Y")).strftime('%y%m')
if datetime.now().strftime('%y%m') > expiry_date:
return False
except ValueError:
return False
Expand Down

0 comments on commit fa525a5

Please sign in to comment.