payme-pkg 2.6.7__py3-none-any.whl → 3.0.17__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of payme-pkg might be problematic. Click here for more details.

Files changed (64) hide show
  1. payme/__init__.py +1 -0
  2. payme/admin.py +12 -6
  3. payme/apps.py +0 -4
  4. payme/classes/cards.py +203 -0
  5. payme/classes/client.py +30 -0
  6. payme/classes/http.py +107 -0
  7. payme/classes/initializer.py +82 -0
  8. payme/classes/receipts.py +298 -0
  9. payme/const.py +12 -0
  10. payme/exceptions/__init__.py +5 -0
  11. payme/exceptions/general.py +275 -0
  12. payme/exceptions/webhook.py +125 -0
  13. payme/models.py +113 -46
  14. payme/types/response/__init__.py +4 -0
  15. payme/types/response/cards.py +110 -0
  16. payme/types/response/receipts.py +215 -0
  17. payme/types/response/webhook.py +136 -0
  18. payme/urls.py +2 -2
  19. payme/util.py +26 -0
  20. payme/views.py +287 -113
  21. payme_pkg-3.0.17.dist-info/METADATA +193 -0
  22. payme_pkg-3.0.17.dist-info/RECORD +29 -0
  23. payme_pkg-3.0.17.dist-info/top_level.txt +1 -0
  24. core/asgi.py +0 -16
  25. core/settings.py +0 -133
  26. core/urls.py +0 -25
  27. core/wsgi.py +0 -16
  28. my_app/admin.py +0 -3
  29. my_app/apps.py +0 -6
  30. my_app/models.py +0 -3
  31. my_app/tests.py +0 -3
  32. my_app/views.py +0 -16
  33. payme/cards/__init__.py +0 -1
  34. payme/cards/subscribe_cards.py +0 -166
  35. payme/decorators/__init__.py +0 -0
  36. payme/decorators/decorators.py +0 -34
  37. payme/errors/__init__.py +0 -0
  38. payme/errors/exceptions.py +0 -89
  39. payme/methods/__init__.py +0 -0
  40. payme/methods/cancel_transaction.py +0 -54
  41. payme/methods/check_perform_transaction.py +0 -26
  42. payme/methods/check_transaction.py +0 -43
  43. payme/methods/create_transaction.py +0 -68
  44. payme/methods/generate_link.py +0 -83
  45. payme/methods/get_statement.py +0 -65
  46. payme/methods/perform_transaction.py +0 -47
  47. payme/migrations/0001_initial.py +0 -48
  48. payme/receipts/__init__.py +0 -1
  49. payme/receipts/subscribe_receipts.py +0 -217
  50. payme/serializers.py +0 -86
  51. payme/utils/__init__.py +0 -0
  52. payme/utils/get_params.py +0 -24
  53. payme/utils/logging.py +0 -9
  54. payme/utils/make_aware_datetime.py +0 -21
  55. payme/utils/support.py +0 -8
  56. payme/utils/to_json.py +0 -13
  57. payme_pkg-2.6.7.dist-info/METADATA +0 -13
  58. payme_pkg-2.6.7.dist-info/RECORD +0 -48
  59. payme_pkg-2.6.7.dist-info/top_level.txt +0 -3
  60. {core → payme/classes}/__init__.py +0 -0
  61. {my_app → payme/types}/__init__.py +0 -0
  62. {my_app/migrations → payme/types/request}/__init__.py +0 -0
  63. {payme_pkg-2.6.7.dist-info → payme_pkg-3.0.17.dist-info}/LICENSE.txt +0 -0
  64. {payme_pkg-2.6.7.dist-info → payme_pkg-3.0.17.dist-info}/WHEEL +0 -0
@@ -0,0 +1,193 @@
1
+ Metadata-Version: 2.1
2
+ Name: payme-pkg
3
+ Version: 3.0.17
4
+ Home-page: https://github.com/Muhammadali-Akbarov/payme-pkg
5
+ Author: Muhammadali Akbarov
6
+ Author-email: muhammadali17abc@gmail.com
7
+ License: MIT
8
+ Keywords: paymeuz paycomuz payme-merchant merchant-api subscribe-api payme-pkg payme-api
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE.txt
11
+ Requires-Dist: requests (==2.*)
12
+ Requires-Dist: djangorestframework (==3.*)
13
+ Requires-Dist: dataclasses (==0.*) ; python_version < "3.7"
14
+
15
+ <h1 align="center">Payme Software Development Kit</h1>
16
+
17
+ <p align="center">
18
+ <a href="https://t.me/+lO97J78xBj45MzBi">
19
+ <img src="https://img.shields.io/badge/Support%20Group-blue?logo=telegram&logoColor=white" alt="Support Group on Telegram"/>
20
+ </a>
21
+ </p>
22
+
23
+ <p align="center">
24
+ <a href="https://docs.pay-tech.uz"><img src="https://img.shields.io/static/v1?message=Documentation&logo=gitbook&logoColor=ffffff&label=%20&labelColor=5c5c5c&color=3F89A1"></a>
25
+ <a href="https://github.com/PayTechUz/payme-pkg"><img src="https://img.shields.io/badge/Open_Source-❤️-FDA599?"/></a>
26
+ <a href="https://github.com/PayTechUz/payme-pkg/issues">
27
+ <img src="https://img.shields.io/github/issues/PayTechUz/payme-pkg" />
28
+ </a>
29
+ <a href="https://pepy.tech/project/payme-pkg">
30
+ <img src="https://static.pepy.tech/badge/payme-pkg" alt="PyPI - Downloads" />
31
+ </a>
32
+ </p>
33
+
34
+ <p align="center">Welcome to payme-pkg, the open source payme SDK for Python.</p>
35
+
36
+ <p align="center">You can use it for test and production mode. Join our community and ask everything you need.</p>
37
+
38
+ <a href="https://docs.pay-tech.uz">
39
+ <p align="center">Visit the full documentation for Merchant and Subscribe API</p>
40
+ </a>
41
+
42
+ <a href="https://youtu.be/xxiIggu_RNk?si=Idpg8omFvFDCYtcm" target="_blank">
43
+ <p align="center">
44
+ <img style="width: 60%;" src="https://i.postimg.cc/WbD32bHC/payme-pkg-demo-m4a.gif" alt="Payme PKG Demo">
45
+ </p>
46
+ </a>
47
+
48
+ <p align="center">
49
+ <a href="https://youtu.be/7q7-c72tHpc?si=Sr0EAmEawWAFRk1m" target="_blank">
50
+ <img src="https://img.shields.io/badge/Watch%20Demo-red?logo=youtube&logoColor=white&style=for-the-badge"
51
+ alt="Watch the YouTube Demo"
52
+ style="width: 150px; height: 30px; border-radius: 7px;" />
53
+ </a>
54
+ </p>
55
+
56
+
57
+ ## Installation
58
+
59
+ ```shell
60
+ pip install payme-pkg
61
+ ```
62
+
63
+ ## Installation to Django
64
+
65
+ Add `'payme'` in to your settings.py
66
+
67
+ ```python
68
+ INSTALLED_APPS = [
69
+ ...
70
+ 'payme',
71
+ ...
72
+ ]
73
+ ```
74
+
75
+ Add `'payme'` credentials inside to settings.py
76
+
77
+ One time payment (Однаразовый платеж) configuration settings.py
78
+
79
+ Example project: https://github.com/PayTechUz/shop-backend
80
+ ```python
81
+ PAYME_ID = "your-payme-id"
82
+ PAYME_KEY = "your-payme-key"
83
+ PAYME_ACCOUNT_FIELD = "order_id"
84
+ PAYME_AMOUNT_FIELD = "total_amount"
85
+ PAYME_ACCOUNT_MODEL = "orders.models.Orders"
86
+ PAYME_ONE_TIME_PAYMENT = True
87
+ ```
88
+
89
+ Multi payment (Накопительный) configuration settings.py
90
+
91
+ Example project: Coming soon
92
+ ```python
93
+ PAYME_ID = "your-payme-id"
94
+ PAYME_KEY = "your-payme-key"
95
+ PAYME_ACCOUNT_FIELD = "id"
96
+ PAYME_ACCOUNT_MODEL = "clients.models.Client"
97
+ PAYME_ONE_TIME_PAYMENT = False
98
+ ```
99
+
100
+ Create a new View that about handling call backs
101
+ ```python
102
+ from payme.views import PaymeWebHookAPIView
103
+
104
+
105
+ class PaymeCallBackAPIView(PaymeWebHookAPIView):
106
+ def handle_created_payment(self, params, result, *args, **kwargs):
107
+ """
108
+ Handle the successful payment. You can override this method
109
+ """
110
+ print(f"Transaction created for this params: {params} and cr_result: {result}")
111
+
112
+ def handle_successfully_payment(self, params, result, *args, **kwargs):
113
+ """
114
+ Handle the successful payment. You can override this method
115
+ """
116
+ print(f"Transaction successfully performed for this params: {params} and performed_result: {result}")
117
+
118
+ def handle_cancelled_payment(self, params, result, *args, **kwargs):
119
+ """
120
+ Handle the cancelled payment. You can override this method
121
+ """
122
+ print(f"Transaction cancelled for this params: {params} and cancelled_result: {result}")
123
+ ```
124
+
125
+ Add a `payme` path to core of urlpatterns:
126
+
127
+ ```python
128
+ from django.urls import path
129
+ from django.urls import include
130
+
131
+ from your_app.views import PaymeCallBackAPIView
132
+
133
+ urlpatterns = [
134
+ ...
135
+ path("payment/update/", PaymeCallBackAPIView.as_view()),
136
+ ...
137
+ ]
138
+ ```
139
+
140
+ Run migrations
141
+ ```shell
142
+ python3 manage.py makemigrations && python manage.py migrate
143
+ ```
144
+ 🎉 Congratulations you have been integrated merchant api methods with django, keep reading docs. After successfull migrations check your admin panel and see results what happened.
145
+
146
+ ## Generate Pay Link
147
+
148
+ Example to generate link:
149
+
150
+ - Input
151
+
152
+ ```python
153
+ from payme import Payme
154
+
155
+ payme = Payme(payme_id="your-payme-id")
156
+ pay_link = payme.initializer.generate_pay_link(id=123456, amount=5000, return_url="https://example.com")
157
+ print(pay_link)
158
+ ```
159
+
160
+ - Output
161
+
162
+ ```
163
+ https://checkout.paycom.uz/bT15b3VyLXBheW1lLWlkO2FjLmlkPTEyMzQ1NjthPTUwMDAwMDtjPWh0dHBzOi8vZXhhbXBsZS5jb20=
164
+ ```
165
+
166
+
167
+ ## Generate Fallback Link
168
+
169
+
170
+ Example to generate fallback link:
171
+
172
+ - Input
173
+
174
+ The ID in the fallback is different from the merchant ID. You can get the ID from the Payme team.
175
+ ```python
176
+ from payme import Payme
177
+
178
+ payme = Payme(payme_id="your-payme-id", fallback_id="your-fallback-id")
179
+
180
+ form_fields = {
181
+ "driver_id": 12345,
182
+ "amount": 1000
183
+ }
184
+
185
+ fallback_link = payme.initializer.generate_fallback_link(form_fields) # form field is optional
186
+ print(fallback_link)
187
+ ```
188
+
189
+ - Output
190
+
191
+ ```
192
+ https://payme.uz/fallback/merchant/?id=examplelinkgenerated&driver_id=12345&amount=1000
193
+ ```
@@ -0,0 +1,29 @@
1
+ payme/__init__.py,sha256=dzLIyA9kQl0sO6z9nHkZDTjkfiI1BepdifKtJbjX2Cw,46
2
+ payme/admin.py,sha256=67uHZiZe2w2s0TE23PS2v-V3xXRaha6o9acjVmNIQbM,470
3
+ payme/apps.py,sha256=HHCY4zUNKPcjz25z0MahZcks0lsAxTGPS0Ml3U4DhZc,142
4
+ payme/const.py,sha256=azndfKR53fe7mDfGW82Q-kwWdMu3x4S1upKc4gkYdlA,214
5
+ payme/models.py,sha256=mT6sIeDOs-pKZ_b8Y9oafHBv5GruioJkpTqTGZ8AulA,4360
6
+ payme/urls.py,sha256=_oUOwxW1Suc5TUmnj--lySYbotRg4yTDkDLJU20CGjE,145
7
+ payme/util.py,sha256=UFb4cEnaufS_hh9C_0z079CSgJGivYjIgOl2iAFrBMs,625
8
+ payme/views.py,sha256=A5_GxSFS1Hif2W1LAGP5YfnGazdaaqLXgFLEy2z0A7k,11928
9
+ payme/classes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ payme/classes/cards.py,sha256=dr3SQdKAhfQmECtwHYW2nmx8wXaNYQFkg5uQU9z8vs4,7624
11
+ payme/classes/client.py,sha256=_eMcSTiwMdwIe0aeccVav-43Uq7ORdH7idOuSTPjpcg,837
12
+ payme/classes/http.py,sha256=KoEbjbeNCUCeCo2R36FH3SfDlyrZTU9OjiSmRA-dVms,3411
13
+ payme/classes/initializer.py,sha256=FvzKp068JfSzHwcQ_w-eXYTomV5ggz7_p5zYBkAtBI4,2326
14
+ payme/classes/receipts.py,sha256=KU4qyGHWZpWW88SjmmTD_N2Tz8pWOCvBbOPnw5tcS3Y,10094
15
+ payme/exceptions/__init__.py,sha256=HoBFnDA3eW_xWZiFlonJK4vhBDTsuik91tvgzXTy8KA,94
16
+ payme/exceptions/general.py,sha256=quy9TRv0HCUjP5EfplHyoLXuAGbrRnPveHeQZmBlHa8,7655
17
+ payme/exceptions/webhook.py,sha256=f0J-fmCW_wpgsTmjGAOtyoZjIOoFpbQwkh_7cZUZkv0,3046
18
+ payme/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
+ payme/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
+ payme/types/request/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
+ payme/types/response/__init__.py,sha256=GAj5pjZ9oIO67T6YMiPd1fhTIvGrPfTv96tykfeChQc,81
22
+ payme/types/response/cards.py,sha256=ilXFDUOPNabVsrQN1KWEzDiL6cDxdVvCbfEl6jCzGpU,1997
23
+ payme/types/response/receipts.py,sha256=TlZeJyymRVHIorg0kbUaogy6MZxN1oq2jHGVRUnlY5A,4070
24
+ payme/types/response/webhook.py,sha256=Br6Gr_-h7sCmOc3ag7H5yBryB8j-bm2mrt39Cy_Fy2E,2918
25
+ payme_pkg-3.0.17.dist-info/LICENSE.txt,sha256=75dBVYmbzWUhwtaB1MSZfj-M-PGaMmeT9UVPli2-ZJ0,1086
26
+ payme_pkg-3.0.17.dist-info/METADATA,sha256=dwjIyS9BH5OHbiivwBoOwZ90OTJwWt0hBMsr5QmwvuU,5534
27
+ payme_pkg-3.0.17.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
28
+ payme_pkg-3.0.17.dist-info/top_level.txt,sha256=8mN-hGAa38pWbhrKHFs9CZywPCdidhMuwPKwuFJa0qw,6
29
+ payme_pkg-3.0.17.dist-info/RECORD,,
@@ -0,0 +1 @@
1
+ payme
core/asgi.py DELETED
@@ -1,16 +0,0 @@
1
- """
2
- ASGI config for core project.
3
-
4
- It exposes the ASGI callable as a module-level variable named ``application``.
5
-
6
- For more information on this file, see
7
- https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/
8
- """
9
-
10
- import os
11
-
12
- from django.core.asgi import get_asgi_application
13
-
14
- os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
15
-
16
- application = get_asgi_application()
core/settings.py DELETED
@@ -1,133 +0,0 @@
1
- """
2
- Django settings for core project.
3
-
4
- Generated by 'django-admin startproject' using Django 4.1.
5
-
6
- For more information on this file, see
7
- https://docs.djangoproject.com/en/4.1/topics/settings/
8
-
9
- For the full list of settings and their values, see
10
- https://docs.djangoproject.com/en/4.1/ref/settings/
11
- """
12
-
13
- from pathlib import Path
14
-
15
- # Build paths inside the project like this: BASE_DIR / 'subdir'.
16
- BASE_DIR = Path(__file__).resolve().parent.parent
17
-
18
-
19
- # Quick-start development settings - unsuitable for production
20
- # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
21
-
22
- # SECURITY WARNING: keep the secret key used in production secret!
23
- SECRET_KEY = 'django-insecure-kc)e&w47x5n@)dgep=ffbkr1th2xjpx4n-8=heu6%%z4p4r8u&'
24
-
25
- # SECURITY WARNING: don't run with debug turned on in production!
26
- DEBUG = True
27
-
28
- ALLOWED_HOSTS = ['*']
29
-
30
-
31
- # Application definition
32
-
33
- INSTALLED_APPS = [
34
- 'django.contrib.admin',
35
- 'django.contrib.auth',
36
- 'django.contrib.contenttypes',
37
- 'django.contrib.sessions',
38
- 'django.contrib.messages',
39
- 'django.contrib.staticfiles',
40
- 'payme',
41
- 'my_app'
42
- ]
43
-
44
- MIDDLEWARE = [
45
- 'django.middleware.security.SecurityMiddleware',
46
- 'django.contrib.sessions.middleware.SessionMiddleware',
47
- 'django.middleware.common.CommonMiddleware',
48
- 'django.middleware.csrf.CsrfViewMiddleware',
49
- 'django.contrib.auth.middleware.AuthenticationMiddleware',
50
- 'django.contrib.messages.middleware.MessageMiddleware',
51
- 'django.middleware.clickjacking.XFrameOptionsMiddleware',
52
- ]
53
-
54
- ROOT_URLCONF = 'core.urls'
55
-
56
- TEMPLATES = [
57
- {
58
- 'BACKEND': 'django.template.backends.django.DjangoTemplates',
59
- 'DIRS': [],
60
- 'APP_DIRS': True,
61
- 'OPTIONS': {
62
- 'context_processors': [
63
- 'django.template.context_processors.debug',
64
- 'django.template.context_processors.request',
65
- 'django.contrib.auth.context_processors.auth',
66
- 'django.contrib.messages.context_processors.messages',
67
- ],
68
- },
69
- },
70
- ]
71
-
72
- WSGI_APPLICATION = 'core.wsgi.application'
73
-
74
-
75
- # Database
76
- # https://docs.djangoproject.com/en/4.1/ref/settings/#databases
77
-
78
- DATABASES = {
79
- 'default': {
80
- 'ENGINE': 'django.db.backends.sqlite3',
81
- 'NAME': BASE_DIR / 'db.sqlite3',
82
- }
83
- }
84
-
85
-
86
- # Password validation
87
- # https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
88
-
89
- AUTH_PASSWORD_VALIDATORS = [
90
- {
91
- 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
92
- },
93
- {
94
- 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
95
- },
96
- {
97
- 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
98
- },
99
- {
100
- 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
101
- },
102
- ]
103
-
104
- PAYME: dict = {
105
- 'PAYME_ID': '64245b936420371977b5c755',
106
- 'PAYME_KEY': 'yHI3RA1RN&H5f0Svcrx@vq9muNsmHUo49dTv',
107
- 'PAYME_URL': 'https://checkout.test.paycom.uz',
108
- 'PAYME_CALL_BACK_URL': 'https://internal-monitor-greatly.ngrok-free.app/payment/merchant', # merchant api callback url
109
- 'PAYME_MIN_AMOUNT': 1, # integer field
110
- 'PAYME_ACCOUNT': 'order_id',
111
- }
112
-
113
- # Internationalization
114
- # https://docs.djangoproject.com/en/4.1/topics/i18n/
115
-
116
- LANGUAGE_CODE = 'en-us'
117
-
118
- TIME_ZONE = 'UTC'
119
-
120
- USE_I18N = True
121
-
122
- USE_TZ = True
123
-
124
-
125
- # Static files (CSS, JavaScript, Images)
126
- # https://docs.djangoproject.com/en/4.1/howto/static-files/
127
-
128
- STATIC_URL = 'static/'
129
-
130
- # Default primary key field type
131
- # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
132
-
133
- DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
core/urls.py DELETED
@@ -1,25 +0,0 @@
1
- """core URL Configuration
2
-
3
- The `urlpatterns` list routes URLs to views. For more information please see:
4
- https://docs.djangoproject.com/en/4.1/topics/http/urls/
5
- Examples:
6
- Function views
7
- 1. Add an import: from my_app import views
8
- 2. Add a URL to urlpatterns: path('', views.home, name='home')
9
- Class-based views
10
- 1. Add an import: from other_app.views import Home
11
- 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12
- Including another URLconf
13
- 1. Import the include() function: from django.urls import include, path
14
- 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15
- """
16
- from django.contrib import admin
17
- from django.urls import path
18
-
19
- from my_app.views import PaymeCallBackAPIView
20
-
21
-
22
- urlpatterns = [
23
- path('admin/', admin.site.urls),
24
- path("payments/merchant/", PaymeCallBackAPIView.as_view()),
25
- ]
core/wsgi.py DELETED
@@ -1,16 +0,0 @@
1
- """
2
- WSGI config for core project.
3
-
4
- It exposes the WSGI callable as a module-level variable named ``application``.
5
-
6
- For more information on this file, see
7
- https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/
8
- """
9
-
10
- import os
11
-
12
- from django.core.wsgi import get_wsgi_application
13
-
14
- os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
15
-
16
- application = get_wsgi_application()
my_app/admin.py DELETED
@@ -1,3 +0,0 @@
1
- from django.contrib import admin
2
-
3
- # Register your models here.
my_app/apps.py DELETED
@@ -1,6 +0,0 @@
1
- from django.apps import AppConfig
2
-
3
-
4
- class MyAppConfig(AppConfig):
5
- default_auto_field = 'django.db.models.BigAutoField'
6
- name = 'my_app'
my_app/models.py DELETED
@@ -1,3 +0,0 @@
1
- from django.db import models
2
-
3
- # Create your models here.
my_app/tests.py DELETED
@@ -1,3 +0,0 @@
1
- from django.test import TestCase
2
-
3
- # Create your tests here.
my_app/views.py DELETED
@@ -1,16 +0,0 @@
1
- # Create your views here.
2
- from payme.views import MerchantAPIView
3
-
4
-
5
- class PaymeCallBackAPIView(MerchantAPIView):
6
- """
7
- the cancel transition.
8
- """
9
- def create_transaction(self, order_id, action) -> None:
10
- print(f"create_transaction for order_id: {order_id}, response: {action}") # noqa
11
-
12
- def perform_transaction(self, order_id, action) -> None:
13
- print(f"perform_transaction for order_id: {order_id}, response: {action}") # noqa
14
-
15
- def cancel_transaction(self, order_id, action) -> None:
16
- print(f"cancel_transaction for order_id: {order_id}, response: {action}") # noqa
payme/cards/__init__.py DELETED
@@ -1 +0,0 @@
1
- from . import subscribe_cards
@@ -1,166 +0,0 @@
1
- from ..decorators.decorators import payme_request
2
- from ..utils.to_json import to_json
3
-
4
-
5
- class PaymeSubscribeCards:
6
- """
7
- The PaymeSubscribeCards class includes
8
- all paycom methods which are belongs to cards.
9
-
10
- Parameters
11
- ----------
12
- base_url: str — The base url of the paycom api
13
- paycom_id: str — The paycom_id uses to identify
14
- timeout: int — How many seconds to wait for the server to send data
15
-
16
- Full method documentation
17
- -------------------------
18
- https://developer.help.paycom.uz/metody-subscribe-api/
19
- """
20
- def __init__(
21
- self,
22
- base_url: str,
23
- paycom_id: str,
24
- timeout=5
25
- ) -> "PaymeSubscribeCards":
26
- self.base_url: str = base_url
27
- self.timeout: int = timeout
28
- self.headers: dict = {
29
- "X-Auth": paycom_id,
30
- }
31
- self.__methods: dict = {
32
- "cards_check": "cards.check",
33
- "cards_create": "cards.create",
34
- "cards_remove": "cards.remove",
35
- "cards_verify": "cards.verify",
36
- "cards_get_verify_code": "cards.get_verify_code",
37
- }
38
-
39
- @payme_request
40
- def __request(self, data) -> dict:
41
- """
42
- Use this private method to request.
43
- On success,response will be OK with format JSON.
44
-
45
- Parameters
46
- ----------
47
- data: dict — Includes request data.
48
-
49
- Returns dictionary Payme Response
50
- ---------------------------------
51
- """
52
- return data
53
-
54
- def cards_create(self, number: str, expire: str, save: bool = True) -> dict:
55
- """
56
- Use this method to create a new card's token.
57
-
58
- Parameters
59
- ----------
60
- number: str — The card number maximum length 18 char
61
- expire: str — The card expiration string maximum length 5 char
62
- save: bool \
63
- Type of token. Optional parameter
64
- The option is enabled or disabled depending on the application's business logic
65
- If the flag is true, the token can be used for further payments
66
- if the flag is false the token can only be used once
67
- The one-time token is deleted after payment
68
-
69
- Full method documentation
70
- -------------------------
71
- https://developer.help.paycom.uz/metody-subscribe-api/cards.create
72
- """
73
- data: dict = {
74
- "method": self.__methods.get("cards_create"),
75
- "params": {
76
- "card": {
77
- "number": number,
78
- "expire": expire,
79
- },
80
- "save": save,
81
- }
82
- }
83
- return self.__request(to_json(**data))
84
-
85
- def card_get_verify_code(self, token: str) -> dict:
86
- """
87
- Use this method to get the verification code.
88
-
89
- Parameters
90
- ----------
91
- token: str — The card's non-active token
92
-
93
- Full method documentation
94
- -------------------------
95
- https://developer.help.paycom.uz/metody-subscribe-api/cards.get_verify_code
96
- """
97
- data: dict = {
98
- "method": self.__methods.get('cards_get_verify_code'),
99
- "params": {
100
- "token": token,
101
- }
102
- }
103
- return self.__request(to_json(**data))
104
-
105
- def cards_verify(self, verify_code: str, token: str) -> dict:
106
- """
107
- Verification of the card using the code sent via SMS.
108
-
109
- Parameters
110
- ----------
111
- verify_code: str — Code for verification
112
- token: str — The card's non-active token
113
-
114
- Full method documentation
115
- -------------------------
116
- https://developer.help.paycom.uz/metody-subscribe-api/cards.verify
117
- """
118
- data: dict = {
119
- "method": self.__methods.get("cards_verify"),
120
- "params": {
121
- "token": token,
122
- "code": verify_code
123
- }
124
- }
125
- return self.__request(to_json(**data))
126
-
127
- def cards_check(self, token: str) -> dict:
128
- """
129
- Checking the card token active or non-active.
130
-
131
- Parameters
132
- ----------
133
- token: str — The card's non-active token
134
-
135
- Full method documentation
136
- -------------------------
137
- https://developer.help.paycom.uz/metody-subscribe-api/cards.check
138
- """
139
- data: dict = {
140
- "method": self.__methods.get("cards_check"),
141
- "params": {
142
- "token": token,
143
- }
144
- }
145
-
146
- return self.__request(to_json(**data))
147
-
148
- def cards_remove(self, token: str) -> dict:
149
- """
150
- Delete card's token on success returns success.
151
-
152
- Parameters
153
- ----------
154
- token: str — The card's non-active token
155
-
156
- Full method documentation
157
- -------------------------
158
- https://developer.help.paycom.uz/metody-subscribe-api/cards.remove
159
- """
160
- data: dict = {
161
- "method": self.__methods.get("cards_remove"),
162
- "params": {
163
- "token": token,
164
- }
165
- }
166
- return self.__request(to_json(**data))
File without changes
@@ -1,34 +0,0 @@
1
- import functools
2
-
3
- from requests import request
4
- from requests.exceptions import Timeout
5
- from requests.exceptions import RequestException
6
-
7
- from ..utils.logging import logger
8
-
9
- from ..errors.exceptions import PaymeTimeoutException
10
-
11
-
12
- def payme_request(func):
13
- """
14
- Payme request decorator.
15
- """
16
- @functools.wraps(func)
17
- def wrapper(self, data):
18
- response = None
19
- req_data = {
20
- "method": "POST",
21
- "url": self.base_url,
22
- "data": data,
23
- "headers": self.headers,
24
- "timeout": self.timeout,
25
- }
26
- try:
27
- response = request(**req_data)
28
- response.raise_for_status()
29
- except (Timeout, RequestException) as error:
30
- logger.info("Payme request has been failed as error: %s", error)
31
- raise PaymeTimeoutException() from error
32
- return response.json()
33
-
34
- return wrapper
payme/errors/__init__.py DELETED
File without changes