### Requirements
````
pip install django
pip install djangorestframework
pip install payme-drf
pip install requests
# supported versions
python 3.5 +
django 2 +
djangorestframework 3.7 +
payme-drf 0.01 +
````
**settings.py**
```python
PAYME_SETTINGS = {
"KASSA_ID": "",
"SECRET_KEY": "",
"INTEGRATION_INTEND": "" # either web or mobile
}
INSTALLED_APPS = [
...
'rest_framework',
'payme',
...
]
```
```
python manage.py migrate
```
### Create payme user
```python
python manage.py create_payme_user
```
### view.py
```python
from payme.methods.merchant.validation_classes import BaseMerchantValidationClass
from payme.methods.merchant.views import BaseMerchantAPIView
class MerchantValidationClass(BaseMerchantValidationClass):
"""
MerchantValidationClass implements abstract methods from BaseMerchantValidationClass
to handle specific payment validation logic.
Exceptions Handled:
- OrderNotFoundException: Raised when the order is not found.
- InvalidAmountException: Raised when the transaction amount is invalid.
"""
def check_order(self, amount, account, **kwargs):
"""Validates the existence and correctness of the order."""
...
def successful_payment(self, params, *args, **kwargs):
"""Processes actions for a successful payment."""
...
def cancel_payment(self, params, *args, **kwargs):
"""Processes actions for canceling a payment."""
...
class PaymeMerchantAPIView(BaseMerchantAPIView):
"""
PaymeMerchantAPIView handles API requests for Payme merchant operations
by using the MerchantValidationClass to validate transactions.
"""
validation_class = MerchantValidationClass
```
### urls.py
```
from django.urls import path
urlpatterns = [
path('payme/', PaymeMerchantAPIView.as_view())
]
```
### create_initialization.py
https://help.paycom.uz/uz/initsializatsiya-platezhey/otpravka-cheka-po-metodu-get
You can pass multiple items to ac_params to customize the payment request.
```python
from payme.methods.merchant.helpers import PaymeHelper
from decimal import Decimal
helper = PaymeHelper()
ac_params = {"order_id": "12221"} # Here, your account parameters
url = helper.create_initialization(amount=Decimal(5000.00), ac_params=ac_params, return_url='https://example.com/success/')
print(url)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/islombeknv/payme-drf",
"name": "payme-drf",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.5",
"maintainer_email": null,
"keywords": null,
"author": "Islombek Normamatov",
"author_email": "islomjon2702@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/0a/e1/311821976f25cfae05e08533a08bf29bf96a1f201fc045026a141e52eeaf/payme_drf-1.0.0.tar.gz",
"platform": null,
"description": "### Requirements\r\n````\r\npip install django\r\npip install djangorestframework\r\npip install payme-drf \r\npip install requests\r\n\r\n# supported versions\r\npython 3.5 +\r\ndjango 2 +\r\ndjangorestframework 3.7 +\r\npayme-drf 0.01 +\r\n````\r\n\r\n**settings.py**\r\n\r\n```python\r\nPAYME_SETTINGS = {\r\n \"KASSA_ID\": \"\",\r\n \"SECRET_KEY\": \"\",\r\n \"INTEGRATION_INTEND\": \"\" # either web or mobile\r\n}\r\n\r\nINSTALLED_APPS = [\r\n ...\r\n 'rest_framework',\r\n 'payme',\r\n ...\r\n]\r\n```\r\n\r\n```\r\npython manage.py migrate\r\n```\r\n\r\n### Create payme user\r\n```python\r\npython manage.py create_payme_user\r\n```\r\n\r\n### view.py\r\n\r\n```python\r\nfrom payme.methods.merchant.validation_classes import BaseMerchantValidationClass\r\nfrom payme.methods.merchant.views import BaseMerchantAPIView\r\n\r\nclass MerchantValidationClass(BaseMerchantValidationClass):\r\n \"\"\"\r\n MerchantValidationClass implements abstract methods from BaseMerchantValidationClass\r\n to handle specific payment validation logic.\r\n\r\n Exceptions Handled:\r\n - OrderNotFoundException: Raised when the order is not found.\r\n - InvalidAmountException: Raised when the transaction amount is invalid.\r\n \"\"\"\r\n\r\n def check_order(self, amount, account, **kwargs):\r\n \"\"\"Validates the existence and correctness of the order.\"\"\"\r\n ...\r\n\r\n def successful_payment(self, params, *args, **kwargs):\r\n \"\"\"Processes actions for a successful payment.\"\"\"\r\n ...\r\n\r\n def cancel_payment(self, params, *args, **kwargs):\r\n \"\"\"Processes actions for canceling a payment.\"\"\"\r\n ...\r\n\r\n\r\nclass PaymeMerchantAPIView(BaseMerchantAPIView):\r\n \"\"\"\r\n PaymeMerchantAPIView handles API requests for Payme merchant operations\r\n by using the MerchantValidationClass to validate transactions.\r\n \"\"\"\r\n \r\n validation_class = MerchantValidationClass\r\n\r\n\r\n```\r\n\r\n### urls.py\r\n```\r\nfrom django.urls import path\r\n\r\nurlpatterns = [\r\n path('payme/', PaymeMerchantAPIView.as_view())\r\n]\r\n```\r\n\r\n### create_initialization.py\r\nhttps://help.paycom.uz/uz/initsializatsiya-platezhey/otpravka-cheka-po-metodu-get\r\n\r\nYou can pass multiple items to ac_params to customize the payment request.\r\n\r\n```python\r\nfrom payme.methods.merchant.helpers import PaymeHelper\r\nfrom decimal import Decimal\r\n\r\nhelper = PaymeHelper()\r\nac_params = {\"order_id\": \"12221\"} # Here, your account parameters\r\nurl = helper.create_initialization(amount=Decimal(5000.00), ac_params=ac_params, return_url='https://example.com/success/')\r\nprint(url)\r\n```\r\n",
"bugtrack_url": null,
"license": null,
"summary": "payme-drf",
"version": "1.0.0",
"project_urls": {
"Homepage": "https://github.com/islombeknv/payme-drf"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "08c281b019399c17a367e673469b767fc97da816a1ab935dae0051ef8e740f83",
"md5": "5473516debd76fdab34ca99e552c1d15",
"sha256": "dd1d7777147d9353e017d3899199380d5491a134dfda74cb4e921fdf8e536db5"
},
"downloads": -1,
"filename": "payme_drf-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5473516debd76fdab34ca99e552c1d15",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.5",
"size": 36336,
"upload_time": "2024-09-02T15:24:06",
"upload_time_iso_8601": "2024-09-02T15:24:06.152489Z",
"url": "https://files.pythonhosted.org/packages/08/c2/81b019399c17a367e673469b767fc97da816a1ab935dae0051ef8e740f83/payme_drf-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0ae1311821976f25cfae05e08533a08bf29bf96a1f201fc045026a141e52eeaf",
"md5": "97d22a8adae4b2aa17c81d6c57025be3",
"sha256": "46d7658948daeedbe5e3fc6e92cf8049786bcefa4d66f6ed71d5f1fdb35d8952"
},
"downloads": -1,
"filename": "payme_drf-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "97d22a8adae4b2aa17c81d6c57025be3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.5",
"size": 26082,
"upload_time": "2024-09-02T15:24:07",
"upload_time_iso_8601": "2024-09-02T15:24:07.749462Z",
"url": "https://files.pythonhosted.org/packages/0a/e1/311821976f25cfae05e08533a08bf29bf96a1f201fc045026a141e52eeaf/payme_drf-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-02 15:24:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "islombeknv",
"github_project": "payme-drf",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "payme-drf"
}