Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master mollie #1

Draft
wants to merge 38 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
85ef8d2
[MOLLIE] init commit
pga-odoo Jul 14, 2021
c0d6b97
remove python depandacy
pga-odoo Jul 15, 2021
222e476
[WIP] add custom form
pga-odoo Jul 15, 2021
ca44d3d
WIP
pga-odoo Jul 18, 2021
b361132
WIP component
pga-odoo Jul 19, 2021
9dc8a25
WIP transection values
pga-odoo Jul 20, 2021
ca4bf45
WIP create payment via api
pga-odoo Jul 20, 2021
58ca368
WIP completed whole flow
pga-odoo Jul 21, 2021
f46ede9
WIP completed direct card payment
pga-odoo Jul 21, 2021
4bf7e81
WIP added payment fallback
pga-odoo Jul 21, 2021
fd4cf34
WIP added vouchers and webhook
pga-odoo Jul 21, 2021
ccc3ed0
vouchers improvements
pga-odoo Jul 22, 2021
a35941c
Ref
pga-odoo Jul 22, 2021
226c333
Ref
pga-odoo Jul 22, 2021
1f65586
Ref
pga-odoo Jul 22, 2021
85c9d65
Ref
pga-odoo Jul 22, 2021
8005a82
Ref
pga-odoo Jul 22, 2021
cc447b5
Ref
pga-odoo Jul 22, 2021
9f30b96
webhook comments
pga-odoo Jul 22, 2021
4bee2d7
remove keys from data
pga-odoo Jul 22, 2021
f3b0597
ref mollie.py
pga-odoo Jul 22, 2021
6496a9a
merge api methods
pga-odoo Jul 22, 2021
f8845ec
merge api methods
pga-odoo Jul 22, 2021
ef31e71
reg
pga-odoo Jul 22, 2021
6a060fd
ref
pga-odoo Jul 22, 2021
239d6ff
ref
pga-odoo Jul 22, 2021
ad2e773
ref
pga-odoo Jul 22, 2021
62dab24
ref
pga-odoo Jul 22, 2021
2e55290
ref
pga-odoo Jul 22, 2021
a42cf9b
ref
pga-odoo Jul 22, 2021
62b47a8
ref
pga-odoo Jul 22, 2021
957afba
ref
pga-odoo Jul 22, 2021
66edc6a
ref
pga-odoo Jul 22, 2021
eddc2f1
ref
pga-odoo Jul 22, 2021
0a62608
ref
pga-odoo Jul 22, 2021
fe5fe19
ref
pga-odoo Jul 22, 2021
22af1d5
css ref
pga-odoo Jul 22, 2021
5e6faeb
ref
pga-odoo Jul 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions addons/payment/controllers/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,13 @@ def _create_transaction(
_("The payment should either be direct, with redirection, or made by a token.")
)

# This will allow you to generate the create values for transaction based on data
# submitted from web (transaction route). This is helpful when payment processing
# needs some data that are generated from client side (e.g. short-term card token in mollie acquirer)
custom_create_values = custom_create_values or {}
custom_create_values.update(acquirer_sudo._get_custom_create_values(kwargs))

if invoice_id:
if custom_create_values is None:
custom_create_values = {}
custom_create_values['invoice_ids'] = [Command.set([int(invoice_id)])]

reference = request.env['payment.transaction']._compute_reference(
Expand Down
16 changes: 16 additions & 0 deletions addons/payment/data/payment_acquirer_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -364,4 +364,20 @@
</field>
</record>

<record id="payment_acquirer_mollie" model="payment.acquirer">
<field name="name">Mollie</field>
<field name="image_128" type="base64" file="payment_mollie/static/src/img/mollie_icon.png"/>
<field name="module_id" ref="base.module_payment_mollie"/>
<field name="description" type="html">
<p>
A payment gateway from Mollie to accept online payments.
</p>
<ul class="list-inline">
<li class="list-inline-item"><i class="fa fa-check"/>Online Payment</li>
<li class="list-inline-item"><i class="fa fa-check"/>Payment Status Tracking</li>
<li class="list-inline-item"><i class="fa fa-check"/>Embedded Credit Card Form</li>
</ul>
</field>
</record>

</odoo>
17 changes: 17 additions & 0 deletions addons/payment/models/payment_acquirer.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,3 +407,20 @@ def _get_redirect_form_view(self, is_validation=False):
"""
self.ensure_one()
return self.redirect_form_view_id

def _get_custom_create_values(self, values):
""" Compute acquirer-specific values for `create` method.

Override this method if you wants transaction record to have custom values
passed from the web page.

Note: you should use `_get_custom_create_values` of transecion if you wants
custom values based on transaction values. This method is used to proccess
data submitted from web(transaction route)

:param dict values: Extra values submitted from the web page
:return: The dict of acquirer-specific create values
:rtype: dict
"""
self.ensure_one()
return dict()
5 changes: 5 additions & 0 deletions addons/payment_mollie/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from . import controllers
from . import models
28 changes: 28 additions & 0 deletions addons/payment_mollie/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

{
'name': 'Mollie Payment Acquirer',
'version': '1.0',
'category': 'Accounting/Payment Acquirers',
'summary': 'Payment Acquirer: Mollie Implementation',
'description': """Mollie Payment Acquirer""",

'author': 'Mollie',
'website': 'http://www.mollie.com',

'depends': ['payment'],
'data': [
'views/payment_views.xml',
'views/template.xml',
'data/payment_acquirer_data.xml',
'security/ir.model.access.csv',
],
'application': True,
'assets': {
'web.assets_frontend': [
'payment_mollie/static/src/js/payment_form.js',
'payment_mollie/static/src/scss/payment_form.scss',
]
}
}
4 changes: 4 additions & 0 deletions addons/payment_mollie/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from . import main
36 changes: 36 additions & 0 deletions addons/payment_mollie/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

import logging
import pprint

from odoo import http
from odoo.http import request, Response

_logger = logging.getLogger(__name__)


class MollieController(http.Controller):
_return_url = "/payment/mollie/return"
_notify_url = "/payment/mollie/notify"

@http.route(_return_url, type='http', auth='public', methods=['GET', 'POST'], csrf=False, sitemap=False)
def mollie_return(self, **data):
if data:
_logger.info("Received Mollie return data:\n%s", pprint.pformat(data))
request.env['payment.transaction'].sudo()._handle_feedback_data('mollie', data)
return request.redirect('/payment/status')

@http.route(_notify_url, type='http', auth='public', methods=['GET', 'POST'], csrf=False, sitemap=False)
def mollie_notify(self, **data):
if data:
_logger.info("Received Mollie notify data:\n%s", pprint.pformat(data))
request.env['payment.transaction'].sudo()._handle_feedback_data('mollie', data)
transaction = request.env["payment.transaction"].sudo().self.search([('reference', '=', data.get('ref')), ('provider', '=', 'mollie')])

# Responding 200 as we do not want webhook call again
if transaction.state in ['done', 'cancel', 'error']:
return Response("OK", status=200)

# Mollie will call webhook again if we respind other then 200
return Response("Not Confirmed", status=418)
17 changes: 17 additions & 0 deletions addons/payment_mollie/data/payment_acquirer_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="1">

<record id="payment.payment_acquirer_mollie" model="payment.acquirer">
<field name="provider">mollie</field>
<field name="support_authorization">False</field>
<field name="support_fees_computation">False</field>
<field name="support_tokenization">False</field>
</record>

<record id="payment_method_mollie" model="account.payment.method">
<field name="name">Mollie</field>
<field name="code">mollie</field>
<field name="payment_type">inbound</field>
</record>

</odoo>
7 changes: 7 additions & 0 deletions addons/payment_mollie/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from . import account_payment_method
from . import mollie
from . import payment_acquirer
from . import payment_transaction
14 changes: 14 additions & 0 deletions addons/payment_mollie/models/account_payment_method.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import api, models


class AccountPaymentMethod(models.Model):
_inherit = 'account.payment.method'

@api.model
def _get_payment_method_information(self):
res = super()._get_payment_method_information()
res['mollie'] = {'mode': 'unique', 'domain': [('type', '=', 'bank')]}
return res
61 changes: 61 additions & 0 deletions addons/payment_mollie/models/mollie.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo.osv import expression
from odoo import fields, models


class MolliePaymentMethod(models.Model):
_name = 'mollie.payment.method'
_description = 'Mollie payment method'
_order = "sequence, id"

name = fields.Char(translate=True)
sequence = fields.Integer()
acquirer_id = fields.Many2one('payment.acquirer', string='Acquirer') # This will be always mollie
method_code = fields.Char(string="Method code")
payment_icon_ids = fields.Many2many('payment.icon', string='Supported Payment Icons')
active = fields.Boolean(default=True)
active_on_shop = fields.Boolean(string="Enabled on shop", default=True)
country_ids = fields.Many2many('res.country', string='Country Availability')
mollie_voucher_ids = fields.One2many('mollie.voucher.line', 'method_id', string='Mollie Voucher Config')

# Hidden fields that are used for filtering methods
supports_order_api = fields.Boolean(string="Supports Order API")
supports_payment_api = fields.Boolean(string="Supports Payment API")
payment_issuer_ids = fields.Many2many('mollie.payment.method.issuer', string='Issuers')


class MolliePaymentIssuers(models.Model):
_name = 'mollie.payment.method.issuer'
_description = 'Mollie payment method issuers'
_order = "sequence, id"

name = fields.Char(translate=True)
sequence = fields.Integer()
acquirer_id = fields.Many2one('mollie.payment.method', string='Acquirer')
payment_icon_ids = fields.Many2many('payment.icon', string='Supported Payment Icons')
issuers_code = fields.Char()
active = fields.Boolean(default=True)


class MollieVoucherLines(models.Model):
_name = 'mollie.voucher.line'
_description = 'Mollie voucher method'

method_id = fields.Many2one('mollie.payment.method', string='Mollie Method')
category_ids = fields.Many2many('product.category', string='Product Categories')
product_ids = fields.Many2many('product.template', string='Products')
mollie_voucher_category = fields.Selection([('meal', 'Meal'), ('eco', 'Eco'), ('gift', 'Gift')], required=True)


class ProductTemplate(models.Model):
_inherit = 'product.template'

def _get_mollie_voucher_category(self):
domain = [('product_ids', 'in', self.ids)]
categories = self.mapped('categ_id')
if categories:
domain = expression.OR([domain, [('category_ids', 'parent_of', categories.ids)]])
voucher_line = self.env['mollie.voucher.line'].search(domain, limit=1)
return voucher_line and voucher_line.mollie_voucher_category or False
Loading