[FIX] payment_stripe: fix ideal fiximp
Revision 29b3b67a16 introduced payment with iDeal but accidentaly introduced an issue where some payments did not go through (in fact, some cards could not be saved, preventing the payment to occur). This fix prevents this issue from happening by clearly differentiating between returns from the Checkout process and from the Elements process; in the case of a Checkout flow, the 'card' key is always present in the data dict but can be equal to None if a non-card payment method was used (e.g. iDeal) while in the case of an Elements (payment from Odoo) flow, the 'data' key is never present and the card information has to be downloaded using a get request to the Stripe API. opw-2253269 closes odoo/odoo#51269 X-original-commit: f0ba15cda070e968699cf77ac0ba58234dbdaf51 Signed-off-by: Damien Bouvy (dbo) <dbo@odoo.com>
This commit is contained in:
@@ -107,10 +107,14 @@ class PaymentAcquirerStripe(models.Model):
|
||||
|
||||
@api.model
|
||||
def stripe_s2s_form_process(self, data):
|
||||
if not data.get('card'):
|
||||
# can't save the token if it's not a card (e.g. iDEAL)
|
||||
if 'card' in data and not data.get('card'):
|
||||
# coming back from a checkout payment and iDeal (or another non-card pm)
|
||||
# can't save the token if it's not a card
|
||||
# note that in the case of a s2s payment, 'card' wont be
|
||||
# in the data dict because we need to fetch it from the stripe server
|
||||
_logger.info('unable to save card info from Stripe since the payment was not done with a card')
|
||||
return self.env['payment.token']
|
||||
last4 = data.get('card').get('last4')
|
||||
last4 = data.get('card', {}).get('last4')
|
||||
if not last4:
|
||||
# PM was created with a setup intent, need to get last4 digits through
|
||||
# yet another call -_-
|
||||
|
||||
Reference in New Issue
Block a user