Skip to content

Commit 9256af4

Browse files
committed
ODOO-236: initialize MultiSafepay Cloud POS integration module
1 parent b4930c0 commit 9256af4

43 files changed

Lines changed: 6667 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pos_multisafepay_cloud/README.rst

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
======================
2+
PoS MultiSafepay Cloud
3+
======================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:0c2c6e4fe462aeabeb139a3d2713ab2e013f8fa48a41fa40456ec1d9f534f4fd
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-%2Fmultisafepay-lightgray.png?logo=github
20+
:target: https://github.com//multisafepay/tree/18.0/pos_multisafepay_cloud
21+
:alt: /multisafepay
22+
23+
|badge1| |badge2| |badge3|
24+
25+
This module adds MultiSafepay Cloud POS payment terminal support to Odoo
26+
Point of Sale.
27+
28+
It lets Odoo create Cloud POS orders, track terminal status, process
29+
webhook or event-stream confirmations, and handle POS-side reversals and
30+
refunds through the backend MultiSafepay API.
31+
32+
The addon is intentionally independent from ``pos_multisafepay`` and
33+
keeps that addon as a reference only.
34+
35+
**Table of contents**
36+
37+
.. contents::
38+
:local:
39+
40+
Installation
41+
============
42+
43+
Install the Python dependencies in the same environment where Odoo runs:
44+
45+
::
46+
47+
pip install multisafepay requests
48+
49+
Then install the module from Odoo Apps after updating the apps list.
50+
51+
Configuration
52+
=============
53+
54+
1. Go to **Point of Sale > Configuration > Payment Methods**.
55+
2. Create or edit a POS payment method.
56+
3. Set **Use a Payment Terminal** to **MultiSafepay Cloud POS**.
57+
4. Configure the Cloud POS credentials and terminal settings:
58+
59+
- **MSP Cloud Terminal ID**
60+
- **MSP Cloud Terminal Group ID**
61+
- **MSP Cloud Terminal Group API Key**
62+
- **MSP Cloud Merchant Account API Key**
63+
- **MSP Cloud Environment**
64+
- **Confirmation Channel**
65+
66+
The default confirmation channel is **Webhook only** because webhook
67+
requests provide clearer HTTP and log traceability. **Socket only**
68+
refers to the backend MultiSafepay event stream; it does not disable the
69+
Odoo POS frontend websocket used by bus notifications.
70+
71+
Usage
72+
=====
73+
74+
1. Open an Odoo POS session that uses the configured payment method.
75+
2. Add products to the order and select **MultiSafepay Cloud POS** as
76+
payment method.
77+
3. Odoo creates a Cloud POS order and shows the terminal status in the
78+
POS.
79+
4. Complete, cancel, reverse, or refund the payment from the POS flow.
80+
81+
Real status polling and completed payment refunds require the merchant
82+
account API key. Without that key, the module can still create terminal
83+
orders with the terminal group credentials, but account-level status and
84+
refund calls are not available.
85+
86+
Known issues / Roadmap
87+
======================
88+
89+
- This addon is a proof of concept for the MultiSafepay Cloud POS order
90+
flow.
91+
- Cloud POS shopping-cart validation should only be enabled when the
92+
terminal payment always covers the full POS order amount.
93+
- Terminal-side tips are detected and warned about, but tips should be
94+
added in Odoo so the POS order, shopping cart and accounting stay
95+
aligned.
96+
97+
Bug Tracker
98+
===========
99+
100+
Bugs are tracked on `GitHub Issues <https://github.com//multisafepay/issues>`_.
101+
In case of trouble, please check there if your issue has already been reported.
102+
If you spotted it first, help us to smash it by providing a detailed and welcomed
103+
`feedback <https://github.com//multisafepay/issues/new?body=module:%20pos_multisafepay_cloud%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
104+
105+
Do not contact contributors directly about support or help with technical issues.
106+
107+
Credits
108+
=======
109+
110+
Authors
111+
-------
112+
113+
* MultiSafepay
114+
115+
Contributors
116+
------------
117+
118+
- MultiSafepay
119+
120+
Maintainers
121+
-----------
122+
123+
This module is part of the `/multisafepay <https://github.com//multisafepay/tree/18.0/pos_multisafepay_cloud>`_ project on GitHub.
124+
125+
You are welcome to contribute.

pos_multisafepay_cloud/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright (c) MultiSafepay, Inc. All rights reserved.
2+
# This file is licensed under the GNU Affero General Public License (AGPL) version 3.0.
3+
# See the LICENSE.md file for more information.
4+
# See the DISCLAIMER.md file for disclaimer details
5+
6+
from . import controllers
7+
from . import models
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "PoS MultiSafepay Cloud",
3+
"summary": "PoC for MultiSafepay Cloud POS payments in Odoo POS",
4+
"author": "MultiSafepay",
5+
"website": "https://github.com/multisafepay",
6+
"license": "AGPL-3",
7+
"category": "Point of Sale",
8+
"version": "19.0.1.0.0",
9+
"application": True,
10+
"depends": [
11+
"point_of_sale",
12+
],
13+
"external_dependencies": {"python": ["multisafepay", "requests"]},
14+
"data": [
15+
"security/ir.model.access.csv",
16+
"views/pos_payment_method_views.xml",
17+
"views/pos_multisafepay_cloud_payment_views.xml",
18+
],
19+
"assets": {
20+
"point_of_sale._assets_pos": [
21+
"pos_multisafepay_cloud/static/src/app/**/*",
22+
],
23+
},
24+
"installable": True,
25+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright (c) MultiSafepay, Inc. All rights reserved.
2+
# This file is licensed under the GNU Affero General Public License (AGPL) version 3.0.
3+
# See the LICENSE.md file for more information.
4+
# See the DISCLAIMER.md file for disclaimer details
5+
6+
from . import main
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Copyright (c) MultiSafepay, Inc. All rights reserved.
2+
# This file is licensed under the GNU Affero General Public License (AGPL) version 3.0.
3+
# See the LICENSE.md file for more information.
4+
# See the DISCLAIMER.md file for disclaimer details
5+
6+
import json
7+
import logging
8+
9+
from odoo import http
10+
from odoo.http import request
11+
12+
from odoo.addons.pos_multisafepay_cloud.helpers.notification_payload import (
13+
_NotificationPayload,
14+
)
15+
16+
_logger = logging.getLogger(__name__)
17+
18+
19+
class PosMultiSafepayCloudController(http.Controller):
20+
@http.route(
21+
[
22+
"/pos_multisafepay_cloud/notification",
23+
],
24+
type="http",
25+
methods=["POST", "GET"],
26+
auth="public",
27+
csrf=False,
28+
)
29+
def notification(self, **kwargs):
30+
"""Handle MultiSafepay Cloud POS notifications.
31+
32+
Accepts both GET status callbacks and POST webhook payloads, delegates the
33+
functional validation to the tracking model and returns an HTTP response for
34+
MultiSafepay.
35+
36+
:param kwargs: Query-string or form parameters received by the route.
37+
:return: HTTP response consumed by MultiSafepay.
38+
"""
39+
raw_body = request.httprequest.get_data(as_text=True)
40+
method = request.httprequest.method
41+
payload = _NotificationPayload.get_from_request(
42+
raw_body,
43+
kwargs,
44+
method=method,
45+
json_payload=request.httprequest.get_json(silent=True),
46+
)
47+
log_payload = _NotificationPayload.sanitize_log_payload(payload)
48+
log_query = _NotificationPayload.sanitize_log_payload(kwargs)
49+
notification = (
50+
request.env["pos.multisafepay.cloud.payment"]
51+
.sudo()
52+
.process_notification(
53+
payload,
54+
raw_body=raw_body,
55+
auth_header=request.httprequest.headers.get("Auth", ""),
56+
method=method,
57+
)
58+
)
59+
60+
if notification.get("status_code"):
61+
_logger.warning(
62+
"MSP Cloud POS notification rejected: method=%s query=%s payload=%s status=%s state=%s order_id=%s detail=%s",
63+
method,
64+
log_query,
65+
log_payload,
66+
notification.get("status"),
67+
notification.get("state"),
68+
notification.get("order_id"),
69+
notification.get("detail"),
70+
)
71+
return request.make_response(
72+
notification.get("detail") or "Notification rejected",
73+
status=notification.get("status_code") or 400,
74+
)
75+
76+
_logger.info(
77+
"MSP Cloud POS notification processed: method=%s query=%s payload=%s status=%s state=%s order_id=%s transaction_id=%s",
78+
method,
79+
log_query,
80+
log_payload,
81+
notification.get("status"),
82+
notification.get("state"),
83+
notification.get("order_id"),
84+
notification.get("transaction_id"),
85+
)
86+
return request.make_response("OK", status=200)
87+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright (c) MultiSafepay, Inc. All rights reserved.
2+
# This file is licensed under the GNU Affero General Public License (AGPL) version 3.0.
3+
# See the LICENSE.md file for more information.
4+
# See the DISCLAIMER.md file for disclaimer details

0 commit comments

Comments
 (0)