Some payments may be confirmed asynchronously, and we need to be aware of their status, even if they are not in a "checkout session complete" event. Relying on successful payment or setup intents instead manage more use cases. task-2733725 closes odoo/odoo#84150 Related: odoo/upgrade#3350 Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from collections import namedtuple
|
|
|
|
API_VERSION = '2019-05-16' # The API version of Stripe implemented in this module
|
|
|
|
# Stripe proxy URL
|
|
PROXY_URL = 'https://stripe.api.odoo.com/api/stripe/'
|
|
|
|
# Support payment method types
|
|
PMT = namedtuple('PaymentMethodType', ['name', 'countries', 'currencies', 'recurrence'])
|
|
PAYMENT_METHOD_TYPES = [
|
|
PMT('card', [], [], 'recurring'),
|
|
PMT('ideal', ['nl'], ['eur'], 'punctual'),
|
|
PMT('bancontact', ['be'], ['eur'], 'punctual'),
|
|
PMT('eps', ['at'], ['eur'], 'punctual'),
|
|
PMT('giropay', ['de'], ['eur'], 'punctual'),
|
|
PMT('p24', ['pl'], ['eur', 'pln'], 'punctual'),
|
|
]
|
|
|
|
# Mapping of transaction states to Stripe {Payment,Setup}Intent statuses.
|
|
# See https://stripe.com/docs/payments/intents#intent-statuses for the exhaustive list of status.
|
|
INTENT_STATUS_MAPPING = {
|
|
'draft': ('requires_payment_method', 'requires_confirmation', 'requires_action'),
|
|
'pending': ('processing',),
|
|
'authorized': ('requires_capture',),
|
|
'done': ('succeeded',),
|
|
'cancel': ('canceled',),
|
|
}
|
|
|
|
# Events which are handled by the webhook
|
|
HANDLED_WEBHOOK_EVENTS = [
|
|
'payment_intent.amount_capturable_updated',
|
|
'payment_intent.succeeded',
|
|
'setup_intent.succeeded',
|
|
]
|