Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
810 Vistas

Hello, I am as of now trying to make a module that introduce a new Payment Provider, and so I took inspiration from module that are already in Odoo like Stripe or Adyen.

However, as I am trying to make the inline form work, I have a hard time understanding this bit of code : 

def _adyen_get_inline_form_values(self, pm_code, amount=None, currency=None):
""" Return a serialized JSON of the required values to render the inline form.

Note: `self.ensure_one()`

:param str pm_code: The code of the payment method whose inline form to render.
:param float amount: The transaction amount.
:param res.currency currency: The transaction currency.
:return: The JSON serial of the required values to render the inline form.
:rtype: str
"""
self.ensure_one()

inline_form_values = {
'client_key': self.adyen_client_key,
'adyen_pm_code': const.PAYMENT_METHODS_MAPPING.get(pm_code, pm_code),
'formatted_amount': self._adyen_get_formatted_amount(amount, currency),
}
return json.dumps(inline_form_values)

No, I understand what it does. My problem is to know what the required values are. Do they change between providers? Where do I find them?



Avatar
Descartar
Autor Mejor respuesta

Thank you Christoph, it helps a lot.

Avatar
Descartar
Mejor respuesta

Yes, these arguments vary from provider to provider, see for example this regex search for files having _.*_get_inline_form_values


Now, for Ayden for example, going up the stream, the method in question is called from within template (payment_adyen.method_form) inherited from payment.method_form. This template in return is called within payment.form which provides the following comments:

<!-- Form customization parameters:
            - mode: The operation mode of the form: `payment` or `validation`; default: `payment`.
            - allow_token_selection: Whether tokens can be selected for payment or assignation (through the `assign_token_route` parameter); default: `True`.
            - allow_token_deletion: Whether tokens can be deleted (archived); default: `False`.
            - default_token_id: The id of the token that should be pre-selected; default: `None`.
            - show_tokenize_input_mapping: For each provider, whether the tokenization checkbox is shown; used only in `payment` mode.
            - display_submit_button: Whether the submit button is displayed; default: `True`.
            - submit_button_label: The label of the submit button; default: 'Pay'/'Save'.
        -->
        <!-- Payment context:
            - reference_prefix: The custom prefix to compute the full transaction reference.
            - amount: The amount to pay.
            - currency: The currency of the payment, as a `res.currency` record.
            - partner_id: The id of the partner on behalf of whom the payment should be made.
            - providers_sudo: The compatible providers, as a sudoed `payment.provider` recordset.
            - payment_methods_sudo: The compatible payment methods, as a sudoed `payment.method`recordset.
            - tokens_sudo: The available payment tokens, as a sudoed `payment.token` recordset.
            - transaction_route: The route to call to create the transaction.
            - assign_token_route: The route to call to assign a new or existing token to a record.
            - landing_route: The route the user is redirected to after payment.
            - access_token: The access token used to authenticate the partner.
        -->


You may want to check out the module payment_custom as well.

What exactly you want or need to do depends on the payment provider you're trying to integrate.

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
sept 24
2250
2
feb 24
2457
2
feb 24
1925
3
feb 25
4735
1
abr 24
1189