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

11.0 qr payments2 #1181

Open
wants to merge 330 commits into
base: 11.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
330 commits
Select commit Hold shift + click to select a range
757256a
:bomb: fix afeter refactoring
Jul 12, 2018
a6132e3
:bath: add logs and remove useless imports
Jul 12, 2018
825f420
Merge pull request #483 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 12, 2018
743e48e
Merge remote-tracking branch 'pos-addons/11.0' into pos-addons-11.0-p…
Jul 16, 2018
7df0e43
Merge pull request #485 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 16, 2018
714a2e7
:bomb: debug micropayments
Jul 16, 2018
9169c05
:bomb: show popup on wechat error in native payments
Jul 16, 2018
3e3e00f
:bomb: debugging create_qr
Jul 16, 2018
06bb9d0
:fire_engine: add basic security rules
Jul 16, 2018
d6f6876
:bomb: futher debugging + use quantity 1 always
Jul 16, 2018
171aeba
:shield: disable non-ready module
Jul 16, 2018
7c65e37
:bomb: debugging Native payments in UI
Jul 16, 2018
e7d0023
:green_heart:
Jul 16, 2018
3c62924
:fire_engine: add wechatpy to requirements
Jul 16, 2018
f79be7d
:fire_engine: no header in csv file
Jul 16, 2018
d3a81a0
:fire_engine: sandbox was always true
Jul 16, 2018
d284217
:fire_engine: passing tests after refactoring
Jul 16, 2018
5246e53
:sos: payment_wechat is not finished, so mark as non installable
Jul 16, 2018
b185975
Merge pull request #484 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 16, 2018
ff14e17
:fire: test_JSAPI_payment
Jul 12, 2018
3562276
:fire: update test_JSAPI_payment
Jul 12, 2018
af85042
:fire_engine: test_JSAPI_payment
Jul 12, 2018
1a3ea93
:fire: fix test_JSAPI_payment
Jul 12, 2018
ea103f3
:bath: ref code
Jul 16, 2018
029814e
:rose: add logs
Jul 16, 2018
0b37bb4
:fire_engine: test_JSAPI_payment
Jul 16, 2018
a8cc9e5
:fire_engine: test_JSAPI_payment
Jul 16, 2018
ef0adbc
:fire_engine: test_wechat_order
Jul 16, 2018
dbecebe
[MINFIX] test_JSAPI_payment
Jul 17, 2018
c488261
[MINFIX] fix test_JSAPI_payment
Jul 17, 2018
379613e
[MINFIX] use the openid for identify the user
Jul 17, 2018
495a9ab
:green_heart: fix lints errors
Jul 17, 2018
e5cf67d
:bath: refactoring code
Jul 17, 2018
c6cc699
:bomb: use ir.sequence for out_trade_no
Jul 17, 2018
8e80456
Merge pull request #486 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 17, 2018
660809f
:fire_engine: use order.name for out_trade_no
Jul 17, 2018
8ef990c
:fire_engine: result_raw is for response from wechat server
Jul 17, 2018
8e1a503
Merge pull request #487 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 17, 2018
13443d4
:bomb: methods must be public and non csrf
Jul 17, 2018
ad3d331
Merge pull request #488 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 17, 2018
4225036
:bomb: type cannot be json for API
Jul 17, 2018
fa72590
:bomb: result must be in xml
Jul 17, 2018
8eb3c5e
Merge pull request #489 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 17, 2018
1232ab8
:bomb: sudo() must be used for API
Jul 17, 2018
90fc941
Merge pull request #490 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 17, 2018
1887291
:rose: better logs without full secret information
Jul 17, 2018
aa58a49
:bomb: wechat callback receives xml
Jul 17, 2018
4d1812b
Merge pull request #491 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 17, 2018
2ca3d7c
[MINFIX] tests
Jul 18, 2018
b3b6a76
[MINFIX] test_JSAPI_payment
Jul 18, 2018
d782a78
Merge pull request #492 from GabbasovDinar/pos-addons-11.0-pos-qr-pay…
Jul 18, 2018
97a3f7b
:bomb: pos_id was not saved in wechat.order
Jul 18, 2018
bcc2d57
:fire_engine: fix logging + don't call _send_pos_notification
Jul 18, 2018
ac382c1
Merge pull request #493 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 18, 2018
d78db4e
[MINFIX] use mini programm appid and secret
Jul 18, 2018
2ee447c
:rose: add logs
Jul 18, 2018
457ab1a
Merge pull request #494 from GabbasovDinar/pos-addons-11.0-pos-qr-pay…
Jul 18, 2018
138f997
:bomb: order_ref was not saved + small fixes
Jul 18, 2018
2f18256
Merge pull request #495 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 18, 2018
f05a864
:bomb: journal_id was not used
Jul 18, 2018
57639f6
Merge pull request #496 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 18, 2018
f7ddc0a
:fire: basic refund api
Jul 19, 2018
2bcf4ab
:memo: draft copy-pasted code
Jul 19, 2018
fd2440d
:fire_engine: basic refund api
Jul 19, 2018
80c2182
:fire: pos refund
Jul 19, 2018
67673a6
:ambulance: compatibility with pos_wechat
Jul 19, 2018
c4d4b98
:bomb: temporarly disable test
Jul 19, 2018
4f9cde4
:rose: make QR bigger and show in center
Jul 20, 2018
0c4bc79
:fire: activate test_refund
Jul 20, 2018
2cb7e8b
:fire_engine: test_JSAPI_payment didn't work with local_sandbox
Jul 20, 2018
71846a3
:fire_engine: tests didn't work with local_sandbox
Jul 20, 2018
da45a79
:fire_engine: test_refund
Jul 20, 2018
db27e9f
:tv: payment wizard views
Jul 20, 2018
f473a68
Merge pull request #497 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 20, 2018
c5b1fef
:bomb: certificate support
Jul 20, 2018
bb13e65
Merge pull request #499 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 20, 2018
3318dbc
:bomb: refund works
Jul 20, 2018
478121b
:memo: documenation and todos
Jul 22, 2018
dc342bc
:bomb: allow pay by different methods
Jul 23, 2018
73f86ee
:bomb: refunds for micropayments
Jul 23, 2018
5f8f872
Merge pull request #500 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 23, 2018
67ea818
:bomb: better way to check payment status
Jul 23, 2018
436ab9b
:bomb: send out_trade_no on micropay to allow refund
Jul 23, 2018
2acb1c8
:tv:
Jul 23, 2018
303bf77
:bomb: filter related wechat record on refund
Jul 23, 2018
0b0f9ad
:lock: read access for employee
Jul 23, 2018
97e94c2
:green_heart:
Jul 23, 2018
2bc42ec
Merge pull request #501 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 23, 2018
78885d4
:fire_engine: authenticate user on server
Jul 19, 2018
10a3bdc
:fire: fix test_JSAPI_payment
Jul 19, 2018
3eb7196
:bomb: add groups
Jul 19, 2018
25b3958
:fire_engine: controller
Jul 19, 2018
14eb764
:fire: test_authenticate_miniprogram_user
Jul 23, 2018
23c1a3b
:memo: update documentation
Jul 23, 2018
68ad871
:green_heart: fix lint error
Jul 23, 2018
8e974c1
:memo: update README
Jul 23, 2018
811fb22
:memo: fix readme
Jul 23, 2018
bd60f66
:memo: fix README
Jul 23, 2018
03bbe96
:green_heart: fix lint errors
Jul 23, 2018
3cc8851
:memo: README
Jul 23, 2018
8e5d459
Merge pull request #498 from GabbasovDinar/pos-addons-11.0-pos-qr-pay…
Jul 23, 2018
cd02f70
:bomb: create journal on opening session
Jul 23, 2018
4ff76a8
:fire: init_pos_wechat_journals must be called
Jul 23, 2018
b7aebea
:fire: test didn't work without local_sandbox arg
Jul 23, 2018
af35c35
:green_heart:
Jul 24, 2018
97d3a7c
Merge pull request #502 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 24, 2018
2e8aa19
:bath: refactoring code
Jul 24, 2018
85c3f3c
:fire: fix test_authenticate_miniprogram_user
Jul 24, 2018
30b4f23
:memo: update documentation about mini-program parameters
Jul 24, 2018
4bed181
:memo: fix code formating in README
Jul 24, 2018
b8adca7
:memo: about multi database
Jul 24, 2018
93234ea
:memo: clean up doc
Jul 24, 2018
c3299da
:green_heart:
Jul 24, 2018
67d98bc
Merge pull request #503 from GabbasovDinar/pos-addons-11.0-pos-qr-pay…
Jul 24, 2018
04581cb
:fire_engine: fix issues with multi-cursors (#504)
Jul 24, 2018
d3eb89a
:bomb: show QR in customer display!
Jul 24, 2018
1d2ee3b
Merge pull request #505 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 24, 2018
6cb9234
:rose: renaming and cleanup
Jul 25, 2018
509ec7a
:memo: module template
Jul 25, 2018
5cd2860
:lock: access to products for group_miniprogram_user
Jul 24, 2018
c64a1a3
:lock: remove old rules
Jul 24, 2018
c07fc89
:memo: module template
Jul 25, 2018
6730871
:lock: move rules to wechat module
Jul 25, 2018
987f014
:memo: add copyright
Jul 25, 2018
19970d8
:bomb: refactorig split code in different modules
Jul 25, 2018
ef98608
:bomb: save user image, show error message if openid or session key i…
Jul 25, 2018
a778ebe
:bomb: refactoring pos_wechat: use code from dependcies
Jul 25, 2018
91faadf
:bath:
Jul 25, 2018
b33a43b
:green_heart:
Jul 25, 2018
4ab15d5
:bomb: dockerfile refactoring
Jul 25, 2018
30b1c33
:fire: more time is needed on week computers
Jul 25, 2018
14fd213
:fire_engine: wrong module name
Jul 25, 2018
7acb5a2
Merge pull request #508 from GabbasovDinar/pos-addons-11.0-pos-qr-pay…
Jul 25, 2018
8fb7db9
:bomb: debug micropay
Jul 25, 2018
42e8032
:bomb: debug native payment
Jul 25, 2018
2e8e66c
:fire_engine: wrongly set model_id
Jul 26, 2018
270cea3
Merge remote-tracking branch 'upstream/pos-addons-11.0-pos-qr-payment…
Jul 26, 2018
edfd40e
:fire: check response status for "/wechat/miniprogram/authenticate"
Jul 26, 2018
827f878
:fire_engine: order is not available when pos_restaurant is installed
Jul 26, 2018
3ca4475
:tv: add wechat field to journal view
Jul 26, 2018
ded8fcc
:bomb: remove unused imports
Jul 26, 2018
47ffd7c
:fire_engine: pizdez
Jul 26, 2018
34ae628
:bomb: sub_app_id
Jul 26, 2018
31edd1b
Merge pull request #506 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 26, 2018
e73ec0f
:lock: rename parameters
Jul 26, 2018
9ead034
:bomb: use mini program pay
Jul 26, 2018
af3745d
Merge pull request #510 from GabbasovDinar/pos-addons-11.0-pos-qr-pay…
Jul 27, 2018
138cc1e
:lock: use sudo for get ir.config_parameters
Jul 27, 2018
5276893
:bomb: move sudo() method to the ir.config_parameter
Jul 27, 2018
e03a379
Merge pull request #511 from GabbasovDinar/pos-addons-11.0-pos-qr-pay…
Jul 27, 2018
2428b6a
:bomb: use sudo() method to get url
Jul 27, 2018
e5e8be5
Merge pull request #512 from GabbasovDinar/pos-addons-11.0-pos-qr-pay…
Jul 27, 2018
7f3d170
:bomb: use sub_openid for JSAPI payment from mini-program
Jul 27, 2018
7122a27
:memo: renamed copy of wechat to be used as a template for alipay
Jul 27, 2018
59fda81
:bath: clean up wechat docs
Jul 27, 2018
5b2f687
:bomb: update dev dockerfile
Jul 27, 2018
d8e5cb8
:rose: doc cleanup
Jul 27, 2018
c8445e7
:bath: move lib to static/lib
Jul 27, 2018
24c809d
:bomb: use sub_api_key for Payment object
Jul 27, 2018
1ec64b1
:memo: cleanup of copy-pasted code
Jul 27, 2018
5115e79
:memo: module template: remove micropay
Jul 27, 2018
494aca1
:bomb: don't use miniprogram_app_key
Jul 27, 2018
4a3b42b
:bath: remove old code
Jul 27, 2018
d164db9
:bomb: fix field name
Jul 28, 2018
a00455d
:fire_engine: fix installation problems
Jul 27, 2018
7fb55b9
Merge pull request #513 from GabbasovDinar/pos-addons-11.0-pos-qr-pay…
Jul 28, 2018
a1d1cf1
:fire: don't use test
Jul 28, 2018
6881f28
Merge pull request #516 from GabbasovDinar/pos-addons-11.0-pos-qr-pay…
Jul 28, 2018
f81e4ee
:bath: better spelling
Jul 28, 2018
a02de51
:fire: addapting tests for alipay
Jul 28, 2018
7149784
:fire: test_alipay_object
Jul 28, 2018
9e9a95b
:tv: rename views
Jul 28, 2018
92dc0ca
:bomb: pass test_alipay_object + rename tests + deactivate not ready …
Jul 28, 2018
1677901
:bath: doc clean up
Jul 28, 2018
3ce3158
:lock: add new access
Jul 28, 2018
0dd3a0f
:fire_engine: test_scan
Jul 28, 2018
df2ff50
:fire_engine: test_refund
Jul 28, 2018
2ea9575
:green_heart:
Jul 28, 2018
41459ca
:bomb: adapt code checking for alipay
Jul 28, 2018
d3d1376
Merge pull request #517 from GabbasovDinar/pos-addons-11.0-pos-qr-pay…
Jul 28, 2018
764f441
:green_heart:
Jul 28, 2018
23dabc6
:fire: add python-alipay-sdk to requirements
Jul 28, 2018
b9085a8
:green_heart:
Jul 28, 2018
34b6acf
Merge remote-tracking branch 'upstream/pos-addons-11.0-pos-qr-payment…
Jul 28, 2018
9e3df9c
:fire_engine: wrong filename
Jul 29, 2018
427a115
:bath: move shared code to pos_qr_payments
Jul 29, 2018
4a700c9
:bath: remove unused file
Jul 29, 2018
f2a694a
:bath: better explanation + use example auth_code for alipay
Jul 29, 2018
974acf6
:bath: move tools to common module that doesn' depend on POS
Jul 29, 2018
cfe38b2
:fire: test_scan
Jul 29, 2018
f0c47a0
:bath: remove commented code
Jul 29, 2018
21016dd
:fire_engine: test_scan (POS)
Jul 29, 2018
7f9757b
:bomb: ref: move qr container to pos_qr_show module
Jul 29, 2018
fae0707
:bath: doc cleanup
Jul 29, 2018
f7757b1
:bomb: debug qr show payment for alipya
Jul 29, 2018
23703a4
:green_heart:
Jul 29, 2018
1d04e56
:fire_engine: there is no alipay.scan model
Jul 29, 2018
46d1d23
:green_heart:
Jul 29, 2018
12a1099
:fire: update tests to new api
Jul 29, 2018
6f20a7f
Merge pull request #515 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 29, 2018
428043b
:memo: wechat_miniprogram new module
Jul 29, 2018
ea6fade
:memo: pos_wechat_miniprogram new module
Jul 29, 2018
d927859
:bomb: move to seperate module pos_wechat_miniprogram
Jul 29, 2018
60a70a8
:bomb: move code to seperate module wechat_miniprogram
Jul 29, 2018
1d221a2
:green_heart:
Jul 29, 2018
78739bb
:bomb: refund fields didn't work: fix + refactoring
Jul 29, 2018
29f2c0e
:memo: update README
Jul 29, 2018
dfea28f
:memo: update readme
Jul 29, 2018
60dac10
:green_heart:
Jul 29, 2018
56ccb13
Merge branch 'pos-addons-11.0-pos-qr-payments-new6' of github.com:Gab…
Jul 29, 2018
fba083e
Merge pull request #519 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 29, 2018
32b6e04
:green_heart:
Jul 29, 2018
2e725f8
:bomb: fix missing dependency
Jul 29, 2018
f37a229
Merge pull request #520 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 29, 2018
9fac6dc
Merge branch 'pos-addons-11.0-pos-qr-payments' of https://github.com/…
Jul 29, 2018
789ad9d
:bomb: wrong value assignment
Jul 29, 2018
5577337
Merge pull request #521 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 29, 2018
35d4803
:bomb: onchange didn't work on changing journal
Jul 29, 2018
44c9acf
Merge pull request #522 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Jul 29, 2018
d04d902
:book: docs
Aug 9, 2018
ec26a26
Merge branch 'pos-addons-11.0-pos-qr-payments' of https://github.com/…
Aug 10, 2018
376be8f
:memo: update docs
Aug 10, 2018
d3fd080
:bomb: fox search of country
Aug 10, 2018
8be31c7
:fire: depends
Aug 10, 2018
b1e5474
:fire: depends
Aug 10, 2018
9f9a8b8
:fire_engine: fix test_JSAPI_payment
Aug 10, 2018
74cd52a
:fire_engine: add patcher
Aug 10, 2018
7e47436
Merge pull request #518 from GabbasovDinar/pos-addons-11.0-pos-qr-pay…
Aug 10, 2018
039edde
Merge pull request #535 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Aug 10, 2018
dea5559
:tada: wechat modules
Aug 10, 2018
b95b5de
:shield: requirements.txt file: wechat and alipay modules
Aug 10, 2018
b42dde9
:book: docs cleanup
Aug 10, 2018
544d4f0
:shield: ignore lib folder on houndy checks
Aug 10, 2018
5df8a51
:rainbow: lints
Aug 10, 2018
35075ee
Merge remote-tracking branch 'pos-addons-yelizariev/11.0-wechat' into…
Aug 10, 2018
f22ca35
Merge pull request #536 from yelizariev/pos-addons-11.0-pos-qr-paymen…
Aug 10, 2018
4a56866
:memo: plan of new module - Tencent Cloud SMS API (it-projects-llc/ad…
Aug 22, 2018
9654465
Merge branch 'pos-addons-11.0-pos-qr-payments' into pos-addons-11.0-p…
Sep 21, 2018
5ec891a
Pos addons 11.0 pos qr payments upd2 (it-projects-llc/addons-dev#563)
ilmir-k Sep 21, 2018
af65995
:book: module presentation added
Sep 16, 2019
2757b33
:cherries: draft version for alipay and pos_alipay
Sep 17, 2019
a91218d
:cherries: instruction improvment
Sep 26, 2019
008013e
:cherries: instructions' drafts
Sep 28, 2019
cb24c13
Merge pull request #729 from Mirgalimova/pos-addons-11.0-pos-qr-payme…
Sep 30, 2019
b44710f
:book: image for qcloud_sms added
Oct 27, 2019
41926cc
:cherries: image for wechat_miniprogram added
Oct 27, 2019
706e829
:cherries: image for pos_wechat added
Oct 27, 2019
26c0fee
:cherries: long name for manifest filed fixed
Oct 15, 2019
a027ed9
11.0 pos_wechat_miniprogram renaming (it-projects-llc/addons-dev#748)
Nov 1, 2019
4001964
Merge branch 'pos-addons-11.0-pos-qr-payments' of github.com:it-proje…
KolushovAlexandr Dec 6, 2019
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
76 changes: 76 additions & 0 deletions alipay/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
============
Alipay API
============

Basic tools to integrate Odoo and Alipay.

.. contents::
:local:

Payment methods
===============

Barcode Payment
---------------
The merchant **scans** the QR code generated in buyer's Alipay Wallet, to charge the buyer and complete the payment.

QR Code Payment
---------------

The merchant generates the QR code and **shows** to a buyer. The buyer will scan the QR code with Alipay Wallet and complete the payment process.

Sound Wave Payment
------------------

The merchant processes the sound wave generated by Alipay Wallet, which identifies the buyer’s Alipay account, then charges the buyer and complete the payment.

Alipay Documentation & tools
============================

Sandbox & Debugging
-------------------

TODO

Payments
--------

* https://docs.open.alipay.com/140
* https://docs.open.alipay.com/api_1/

Debugging
=========

Local Debug
-----------

To debug UI, create *System Parameter* ``alipay.local_sandbox`` with value ``1``. All requests to alipay will return fake result without making a request.

Credits
=======

Contributors
------------
* `Ivan Yelizariev <https://it-projects.info/team/yelizariev>`__
* `Dinar Gabbasov <https://it-projects.info/team/GabbasovDinar>`__

Sponsors
--------
* `Sinomate <http://sinomate.net/>`__

Maintainers
-----------
* `IT-Projects LLC <https://it-projects.info>`__

Further information
===================

Demo: http://runbot.it-projects.info/demo/misc-addons/11.0

HTML Description: https://apps.odoo.com/apps/modules/11.0/alipay/

Usage instructions: `<doc/index.rst>`_

Changelog: `<doc/changelog.rst>`_

Tested on Odoo 11.0 ee2b9fae3519c2494f34dacf15d0a3b5bd8fbd06
3 changes: 3 additions & 0 deletions alipay/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from . import models
from . import controllers
42 changes: 42 additions & 0 deletions alipay/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2018 Dinar Gabbasov <https://it-projects.info/team/GabbasovDinar>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
{
"name": """Alipay API""",
"summary": """Technical module to integrate odoo with Alipay""",
"category": "Hidden",
# "live_test_url": "",
"images": ['images/alipay.png'],
"version": "11.0.1.0.0",
"application": False,

"author": "IT-Projects LLC, Ivan Yelizariev",
"support": "[email protected]",
"website": "https://it-projects.info/team/yelizariev",
"license": "LGPL-3",
# "price": 9.00,
# "currency": "EUR",

"depends": [
'product',
'account',
'qr_payments',
],
"external_dependencies": {"python": [
'alipay',
], "bin": []},
"data": [
"views/account_menuitem.xml",
"views/alipay_order_views.xml",
"views/alipay_refund_views.xml",
"views/account_journal_views.xml",
"data/ir_sequence_data.xml",
"data/module_data.xml",
"security/alipay_security.xml",
"security/ir.model.access.csv",
],
"qweb": [],

"auto_install": False,
"installable": True,
}
2 changes: 2 additions & 0 deletions alipay/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from . import alipay_controllers
109 changes: 109 additions & 0 deletions alipay/controllers/alipay_controllers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2018 Dinar Gabbasov <https://it-projects.info/team/GabbasovDinar>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from lxml import etree
import logging
import base64
from odoo.exceptions import UserError

from odoo import http, _
from odoo.http import request
import requests

_logger = logging.getLogger(__name__)
ALIPAY_NOTIFY_URL = '/alipay/callback'


class AlipayController(http.Controller):

@http.route(ALIPAY_NOTIFY_URL, methods=['POST'], auth='public', type='http', csrf=False)
def alipay_callback(self):
xml_raw = request.httprequest.get_data().decode(request.httprequest.charset)
_logger.debug('/alipay/callback request data: %s\nheaders %s: ', xml_raw, request.httprequest.headers)

# convert xml to object
xml = etree.fromstring(xml_raw)
data = {}
for child in xml:
data[child.tag] = child.text

res = request.env['alipay.order'].sudo().on_notification(data)

if res is not False:
return """<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>"""
else:
return """<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[Signature failure]]></return_msg></xml>"""

@http.route('/alipay/miniprogram/authenticate', type='json', auth='public', csrf=False)
def authenticate(self, code, user_info, test_cr=False):
"""
:param code: After the user is permitted to log in on the Alipay mini-program, the callback content will
bring the code (five-minute validity period). The developer needs to send the code to the backend
of their server and use code in exchange for the session_key api.
The code is exchanged for the openid and session_key.
:param user_info: User information object, does not contain sensitive information such as openid
:return session_info: All information about session such as session_id, uid, etc.
"""
_logger.debug('/alipay/miniprogram/authenticate request: code - %s, user_info - %s', code, user_info)
openid, session_key = self.get_openid(code)
_logger.debug('Authenticate on Alipay server: openid - %s, session_key - %s', openid, session_key)

if not openid or not session_key:
raise UserError(_('Unable to get data from Alipay server : openid - %s, session_key - %s') % (openid, session_key))

User = request.env['res.users'].sudo()
user = User.search([('openid', '=', openid)])
if user:
user.write({
'alipay_session_key': session_key,
})
else:
country = request.env['res.country'].search([('name', 'ilike', '%'+user_info.get('country')+'%')])
name = user_info.get('nickName')
login = "alipay_%s" % openid
city = user_info.get('city')

user = User.create({
'company_id': request.env.ref("base.main_company").id,
'name': name,
'image': base64.b64encode(requests.get(user_info.get('avatarUrl')).content) if user_info.get('avatarUrl') else None,
'openid': openid,
'alipay_session_key': session_key,
'login': login,
'country_id': country.id if country else None,
'city': city,
'groups_id': [(4, request.env.ref('alipay.group_miniprogram_user').id)]
})

if test_cr is False:
# A new cursor is used to authenticate the user and it cannot see the
# latest changes of current transaction.
# Therefore we need to make the commit.

# In test mode, one special cursor is used for all transactions.
# So we don't need to make the commit. More over commit() shall not be used,
# because otherwise test changes are not rollbacked at the end of test
request.env.cr.commit()

request.session.authenticate(request.db, user.login, user.alipay_session_key)
_logger.debug('Current user login: %s, id: %s', request.env.user.login, request.env.user.id)
session_info = request.env['ir.http'].session_info()
return session_info

def get_openid(self, code):
"""Get openid

:param code: After the user is permitted to log in on the Alipay mini-program, the callback content will
bring the code (five-minute validity period). The developer needs to send the code to the backend
of their server and use code in exchange for the session_key api.
The code is exchanged for the openid and session_key.
:return openid: The Alipay user's unique ID
"""
url = request.env['ir.config_parameter'].sudo().get_openid_url(code)
response = requests.get(url)
response.raise_for_status()
value = response.json()
_logger.debug('get_openid function return parameters: %s', value)
openid = value.get('openid')
session_key = value.get('session_key')
return openid, session_key
20 changes: 20 additions & 0 deletions alipay/data/ir_sequence_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). -->
<odoo noupdate="1">
<record id="seq_alipay_order" model="ir.sequence">
<field name="name">Alipay Order</field>
<field name="code">alipay.order</field>
<field name="prefix">WO-</field>
<field name="padding">3</field>
<field name="company_id" eval="False" />
</record>

<record id="seq_alipay_refund" model="ir.sequence">
<field name="name">Alipay Refund</field>
<field name="code">alipay.refund</field>
<field name="prefix">WR-</field>
<field name="padding">3</field>
<field name="company_id" eval="False" />
</record>
</odoo>
8 changes: 8 additions & 0 deletions alipay/data/module_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record model="ir.module.category" id="module_category_miniprogram_management">
<field name="name">Mini-program</field>
<field name="description">Helps you manage your Alipay and main operations: create orders, payment, etc...</field>
<field name="sequence">60</field>
</record>
</odoo>
4 changes: 4 additions & 0 deletions alipay/doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
`1.0.0`
-------

- Init version
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

63 changes: 63 additions & 0 deletions alipay/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
============
Alipay API
============

.. contents::
:local:

Installation
============

* Install `alipay library<https://github.com/fzlee/alipay>`__::

pip install python-alipay-sdk

# to update existing installation use
pip install -U python-alipay-sdk

* Be sure that your server available for requests from outside world (i.e. it shall not be avaialble in local network only)

Alipay APP
==========

TODO

Configuration
=============

Credentials
-----------

* `Activate Developer Mode <https://odoo-development.readthedocs.io/en/latest/odoo/usage/debug-mode.html>`__
* Open menu ``[[ Settings ]] >> Parameters >> System Parameters``
* Create following parameters

* ``alipay.app_id``
* ``alipay.app_auth_code`` -- optional. Only for ISV (Third-party Service Provider)
* ``alipay.app_private_key_file`` -- path to file
* ``alipay.alipay_public_key_string`` -- content of public key file. Starts with ``-----BEGIN PUBLIC KEY-----``
* ``alipay.app_auth_code``
* ``alipay.app_auth_token``
* ``alipay.notify_url`` -- optional. Use it if doesn't work automatiically. The url must be ``http(s)://YOUR_HOST/alipay/callback``.


Internal Numbers
----------------

If you get error ``invalid out_trade_no``, it means that you use the same
credentials in new database and odoo sends Alipay Order IDs that were previously
used in another system. To resolve this do as following:

* Go to ``[[ Settings ]] >> Technical >> Sequence & Identifiers >> Sequences``
* Find record *Alipay Order* or *Alipay Refund**, depending on which request has the problem
* Change either **Prefix**, **Suffix** or **Next Number**
* If you get the error again, try to increase **Next Number**

Alipay tracking
---------------
Alipay records (Orders, Refunds, etc.) can be found at ``[[ Invoicing ]] >> Configuration >> Alipay``. If you don't have that menu, you need to configure ``Show Full Accounting Features`` for your user first:

* `Activate Developer Mode <https://odoo-development.readthedocs.io/en/latest/odoo/usage/debug-mode.html>`__
* Open menu ``[[ Settings ]] >> Users & Companies >> Users``
* Open user you need
* Activate ``Show Full Accounting Features``
Binary file added alipay/images/alipay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions alipay/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from . import alipay_order
from . import alipay_refund
from . import ir_config_parameter
from . import account_journal
from . import res_users
12 changes: 12 additions & 0 deletions alipay/models/account_journal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from odoo import models, fields


class Journal(models.Model):
_inherit = 'account.journal'

alipay = fields.Selection([
('scan', 'Scanning customer\'s QR'),
('show', 'Showing QR to customer'),
], string='Alipay Payment', help='Register for Alipay payment')
Loading