Skip to content

Commit 36184f5

Browse files
authored
Merge pull request #1272 from trojikman/11.0-pos_alipay
commit is created by 👷‍♂️ Merge Bot: https://odoo-devops.readthedocs.io/en/latest/git/github-merge-bot.html
2 parents b8a751c + 2816b4f commit 36184f5

25 files changed

+1038
-0
lines changed

pos_alipay/README.rst

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
.. image:: https://img.shields.io/badge/license-MIT-blue.svg
2+
:target: https://opensource.org/licenses/MIT
3+
:alt: License: MIT
4+
5+
========================
6+
Alipay Payments in POS
7+
========================
8+
9+
The module implements following payment workflows
10+
11+
Barcode Payment
12+
---------------
13+
14+
* Cashier creates order and scan user's QR in user's Alipay mobile app
15+
16+
* scanning can be done via Mobile Phone camera (``pos_mobile`` module is recommended)
17+
* scanning can be done via usb scanner
18+
* scanning can be done via usb scanner attached to PosBox
19+
20+
* User's receives order information and authorise fund transferring
21+
* Cashier gets payment confirmation in POS
22+
23+
QR Code Payment
24+
---------------
25+
26+
* Cashier clicks a button to get one-time url and shows it to Buyer as a QR Code
27+
28+
* QR can be shown in POS
29+
* QR can be shown in Mobile POS (``pos_mobile`` module is recommended)
30+
* QR can be shown in Customer screen
31+
32+
* Buyer scans to finish the transaction.
33+
* Cashier gets payment confirmation in POS
34+
35+
Debugging
36+
=========
37+
38+
Scanning
39+
--------
40+
41+
If you don't have camera or scanner, you can executing following code in browser console to simulate scanning::
42+
43+
odoo.__DEBUG__.services['web.core'].bus.trigger('qr_scanned', '28763443825664394');
44+
45+
Customer Screen
46+
---------------
47+
48+
To emulate Customer screen do as following:
49+
50+
* run another odoo on a different port, say ``9069``, workers 1, extra *server wide modules*, i.e. use ``--workers=1 --load=web,hw_proxy,hw_posbox_homepage,hw_screen``
51+
* open page at your browser: http://localhost:9069/point_of_sale/display -- you must see message ``POSBox Client display``
52+
* at POS' Settings activate ``[x] PosBox``, activate ``[x] Customer Display`` and set **IP Address** to ``localhost:9069``
53+
* Now just open POS
54+
55+
Roadmap
56+
=======
57+
58+
* TODO: In sake of UX, we need to add ``alipay_order_id`` reference to ``account.bank.statement.line``
59+
60+
Credits
61+
=======
62+
63+
Contributors
64+
------------
65+
* `Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>`__
66+
67+
Sponsors
68+
--------
69+
* `IT-Projects LLC <https://it-projects.info>`__
70+
71+
Maintainers
72+
-----------
73+
* `IT-Projects LLC <https://it-projects.info>`__
74+
75+
To get a guaranteed support you are kindly requested to purchase the module at `odoo apps store <https://apps.odoo.com/apps/modules/11.0/pos_alipay/>`__.
76+
77+
Thank you for understanding!
78+
79+
`IT-Projects Team <https://www.it-projects.info/team>`__
80+
81+
Further information
82+
===================
83+
84+
Demo: http://runbot.it-projects.info/demo/pos_addons/11.0
85+
86+
HTML Description: https://apps.odoo.com/apps/modules/11.0/pos_payment_alipay/
87+
88+
Usage instructions: `<doc/index.rst>`_
89+
90+
Changelog: `<doc/changelog.rst>`_
91+
92+
Notifications on updates: `via Atom <https://github.com/it-projects-llc/pos-addons/commits/11.0/pos_alipay.atom>`_, `by Email <https://blogtrottr.com/?subscribe=https://github.com/it-projects-llc/pos-addons/commits/11.0/pos_alipay.atom>`_
93+
94+
Tested on Odoo 11.0 ee2b9fae3519c2494f34dacf15d0a3b5bd8fbd06

pos_alipay/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# License MIT (https://opensource.org/licenses/MIT).
2+
from . import models
3+
from . import wizard

pos_alipay/__manifest__.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
2+
# Copyright 2018 Dinar Gabbasov <https://it-projects.info/team/GabbasovDinar>
3+
# License MIT (https://opensource.org/licenses/MIT).
4+
{
5+
"name": """Alipay Payments in POS""",
6+
"summary": """Support payment by scanning user's QR""",
7+
"category": "Point of Sale",
8+
# "live_test_url": "",
9+
"images": ["images/pos_alipay.png"],
10+
"version": "11.0.1.0.0",
11+
"application": False,
12+
"author": "IT-Projects LLC, Kolushov Alexandr",
13+
"support": "[email protected]",
14+
"website": "https://it-projects.info/team/KolushovAlexandr",
15+
"license": "LGPL-3",
16+
# "price": 9.00,
17+
# "currency": "EUR",
18+
"depends": [
19+
"alipay",
20+
"pos_qr_scan",
21+
"pos_qr_show",
22+
"pos_qr_payments",
23+
"pos_longpolling",
24+
],
25+
"external_dependencies": {"python": [], "bin": []},
26+
"data": [
27+
"views/assets.xml",
28+
"wizard/pos_payment_views.xml",
29+
"security/alipay_security.xml",
30+
],
31+
"demo": [],
32+
"qweb": ["static/src/xml/pos.xml"],
33+
"auto_install": False,
34+
"installable": True,
35+
}

pos_alipay/doc/changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
`1.0.0`
2+
-------
3+
4+
- Init version

pos_alipay/doc/index.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
========================
2+
Alipay Payments in POS
3+
========================
4+
5+
Follow instructions of `Alipay API <https://apps.odoo.com/apps/modules/11.0/alipay/>`__ module.
6+
7+
Installation
8+
============
9+
10+
* `Install <https://odoo-development.readthedocs.io/en/latest/odoo/usage/install-module.html>`__ this module in a usual way
11+
12+
Configuration
13+
=============
14+
15+
Alipay Journals
16+
---------------
17+
18+
Alipay Journals are created automatically on first opening POS session.
19+
20+
* In demo installation: they are availabe in POS immediatly
21+
* In non-demo installation: add Journals to **Payment Methods** in *Point of
22+
Sale*'s Settings, then close existing session if any and open again
23+
24+
Usage
25+
=====
26+
27+
Scanning customer's QR
28+
----------------------
29+
30+
* Start POS
31+
* Create some Order
32+
* Click ``[Scan QR Code]`` or use QR Scanner device attached to PosBox or the device you use (computer, tablet, phone)
33+
* Ask customer to prepare QR in Alipay app
34+
* Scan the QR
35+
* Wait until customer authorise the payment in his Alipay app
36+
* RESULT: Payment is proceeded. Use your Alipay Seller control panel to see balance update.
37+
38+
Refunds
39+
-------
40+
41+
* Make Refund Order via backend as usual:
42+
43+
* Go to ``[[ Point of Sale ]] >> Orders >> Orders``
44+
* Open product to be refuned
45+
* Click button ``[Return Products]``
46+
47+
* In Refund Order click ``[Payment]``
48+
* In **Payment Mode** specify a Alipay journal
49+
* Specify **Alipay Order to refund**

pos_alipay/images/pos_alipay.png

25.3 KB
Loading

pos_alipay/models/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
2+
from . import alipay_pos
3+
from . import alipay_order
4+
from . import pos_config

pos_alipay/models/alipay_order.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
2+
# License MIT (https://opensource.org/licenses/MIT).
3+
import json
4+
5+
from odoo import api, models
6+
7+
from odoo.addons.qr_payments.tools import odoo_async_call
8+
9+
10+
class AlipayOrder(models.Model):
11+
_inherit = ["alipay.order", "alipay.pos"]
12+
_name = "alipay.order"
13+
14+
@api.multi
15+
def _prepare_message(self):
16+
self.ensure_one()
17+
result_json = json.loads(self.result_raw)
18+
msg = {
19+
"event": "payment_result",
20+
"code": result_json["code"],
21+
"order_ref": self.order_ref,
22+
"total_amount": self.total_amount,
23+
"journal_id": self.journal_id.id,
24+
}
25+
return msg
26+
27+
def on_notification(self, data):
28+
order = super(AlipayOrder, self).on_notification(data)
29+
if order and order.pos_id:
30+
order._send_pos_notification()
31+
return order
32+
33+
@api.model
34+
def create_qr(self, lines, **kwargs):
35+
pos_id = kwargs.get("pos_id")
36+
if pos_id:
37+
if "create_vals" not in kwargs:
38+
kwargs["create_vals"] = {}
39+
kwargs["create_vals"]["pos_id"] = pos_id
40+
return super(AlipayOrder, self).create_qr(lines, **kwargs)
41+
42+
@api.model
43+
def _prepare_pos_create_from_qr(self, **kwargs):
44+
create_vals = {
45+
"pos_id": kwargs["pos_id"],
46+
}
47+
kwargs.update(create_vals=create_vals)
48+
args = ()
49+
return args, kwargs
50+
51+
@api.model
52+
def pos_create_from_qr_sync(self, **kwargs):
53+
args, kwargs = self._prepare_pos_create_from_qr(**kwargs)
54+
record = self._create_from_qr(*args, **kwargs)
55+
return record._prepare_message()
56+
57+
@api.model
58+
def pos_create_from_qr(self, **kwargs):
59+
"""Async method. Result is sent via longpolling"""
60+
args, kwargs = self._prepare_pos_create_from_qr(**kwargs)
61+
odoo_async_call(
62+
self._create_from_qr,
63+
args,
64+
kwargs,
65+
callback=self._send_pos_notification_callback,
66+
)
67+
return "ok"
68+
69+
@api.model
70+
def _send_pos_notification_callback(self, record):
71+
record._send_pos_notification()

pos_alipay/models/alipay_pos.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
2+
# License MIT (https://opensource.org/licenses/MIT).
3+
from odoo import api, fields, models
4+
5+
CHANNEL_ALIPAY = "alipay"
6+
7+
8+
class AlipayPos(models.AbstractModel):
9+
_name = "alipay.pos"
10+
11+
pos_id = fields.Many2one("pos.config")
12+
13+
@api.multi
14+
def _send_pos_notification(self):
15+
self.ensure_one()
16+
msg = self._prepare_message()
17+
assert self.pos_id, "The record has empty value of pos_id field"
18+
return self.env["pos.config"]._send_to_channel_by_id(
19+
self._cr.dbname, self.pos_id.id, CHANNEL_ALIPAY, msg,
20+
)

0 commit comments

Comments
 (0)