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