[WIP] iap: adapt the charge to trail system.

We added the possibility to provide the dbuuid of the client when trying
to authorize a transaction. This will allow to automatically credit the
client accounts that can beneficiate from free trial credits. This
improvement will ease the life of the client as they will not have to go
to iap.odoo.com to charge their account.
This commit is contained in:
Rémi Rahir
2018-09-21 13:48:56 +02:00
parent 092870270e
commit a0b7802a5e
+3 -1
View File
@@ -78,7 +78,7 @@ class IapTransaction(object):
self.credit = None
@contextlib.contextmanager
def charge(env, key, account_token, credit, description=None, credit_template=None):
def charge(env, key, account_token, credit, dbuuid=False, description=None, credit_template=None):
"""
Account charge context manager: takes a hold for ``credit``
amount before executing the body, then captures it if there
@@ -103,6 +103,8 @@ def charge(env, key, account_token, credit, description=None, credit_template=No
'key': key,
'description': description,
}
if dbuuid:
params.update({'dbuuid': dbuuid})
try:
transaction_token = jsonrpc(endpoint + '/iap/1/authorize', params=params)
except InsufficientCreditError as e: