zru-django


Namezru-django JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/zrupay/zru-django
SummaryZRU Django Bindings
upload_time2024-07-11 18:10:32
maintainerNone
docs_urlNone
authorZRU
requires_pythonNone
licenseBSD
keywords zru payments
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ZRU Django


# Overview

ZRU Django provides integration access to the ZRU API through django framework.

# Requirements

* [Django][django]
* [ZRU Python][zru-python]

# Installation

Install using `pip`...

```bash
pip install zru-django
```

Add `'zru_django'` to your `INSTALLED_APPS` setting.

```python
INSTALLED_APPS = (
    ...
    'zru_django',
    ...
)
```

Set the `ZRU_CONFIG` variable in settings.py using the following format:
```python
ZRU_CONFIG = {
    'PUBLIC_KEY': '<your_public-key>',
    'SECRET_KEY': '<your_secret-key>',
    'CHECK_SIGNATURE_ON_NOTIFICATION': True,
}
```

You can get these values on the [ZRU Panel][zru-developers-key].

This project is implemented with most versions in mind. For modern (and most) versions of Django, you should use:

```python
from django.urls import path, include
urlpatterns = [
    ...
    path("zru/", include('zru_django.urls')),
    ...
]
```

For older versions (django<2.0), you should use the `url` function instead of the `path` one.
 
Note: If you are using an older version of this library, you should set both 'PUBLIC_KEY' and 'PRIVATE_KEY' (set on the Django Admin page) on the settings.py file.

# Migration Guide for Versions Prior to 1.x.x

If you are migrating from a version prior to 1.x.x, you will need to update your import statements to reflect the change from django_mc2p to zru_django. Here is a guide to help you make these changes.

### Updating Import Statements

For any imports that used the django_mc2p module, replace django_mc2p with zru_django.

#### Example:

Before:
```python
from django_mc2p import MC2PClient
```
After:
```python
from zru_django import ZRUClient
```

### Updating Client class

Replace MC2PClient with ZRUClient.

#### Example

Before:

```python
client = MC2PClient(...)
```
After:

```python
client = ZRUClient(...)
```

## Steps to Update Your Code

1.  Search and Replace: Use your IDE or a text editor to search for django_mc2p and replace it with zru_django.
2.  Verify Imports: Ensure all import statements now reference zru_django.
3.  Run Tests: Run your test suite to verify that your code is functioning correctly with the updated imports.

### Summary

By following these steps, you can successfully migrate your project from versions prior to 1.x.x, ensuring compatibility with the new zru_django module naming convention.

# Quick Example

### Basic transaction

```python
# Sending user to pay
from zru_django import ZRUClient

zru = ZRUClient()
transaction = zru.Transaction({
    "currency": "EUR",
    "order_id": "order id",
    "products": [{
        "amount": 1,
        "product": {
            "name": "Product",
            "price": 50
        }
    }],
    "notify_url": "https://www.example.com" + reverse('zru-notify'),
    "return_url": "https://www.example.com/your-return-url/",
    "cancel_return": "https://www.example.com/your-cancel-url/"
})
transaction.save()
transaction.pay_url # Send user to this url to pay
transaction.iframe_url # Show an iframe with this url

# After user pay a notification will be sent to notify_url
from zru_django.signals import notification_received

def check_payment(sender, **kwargs):
    notification_data = sender
    if notification_data.is_transaction and notification_data.is_status_done:
        transaction_id = notification_data.id
        sale_id = notification_data.sale_id
        order_id = notification_data.order_id
        # Use transaction_id, sale_id and order_id to check all the data and confirm the payment in your system
notification_received.connect(check_payment)
```

### Basic subscription

```python
# Sending user to pay a subscription
from zru_django import ZRUClient

zru = ZRUClient()
subscription = zru.Subscription({
    "currency": "EUR",
    "order_id": "order id",
    "plan": {
        "name": "Plan",
        "price": 5,
        "duration": 1,
        "unit": "M",
        "recurring": true
    },
    "notify_url": "https://www.example.com" + reverse('zru-notify'),
    "return_url": "https://www.example.com/your-return-url/",
    "cancel_return": "https://www.example.com/your-cancel-url/"
})
subscription.save()
subscription.pay_url # Send user to this url to pay
subscription.iframe_url # Show an iframe with this url

# After user pay a notification will be sent to notify_url
from zru_django.signals import notification_received

def check_payment(sender, **kwargs):
    notification_data = sender
    if notification_data.is_subscription and notification_data.is_status_done:
        subscription_id = notification_data.id
        sale_id = notification_data.sale_id
        order_id = notification_data.order_id
        # Use subscription_id, sale_id and order_id to check all the data and confirm the payment in your system
notification_received.connect(check_payment)
```

### Basic authorization

```python
# Sending user to pay an authorization
from zru_django import ZRUClient

zru = ZRUClient()
authorization = zru.Authorization({
    "currency": "EUR",
    "order_id": "order id",
    "notify_url": "https://www.example.com" + reverse('zru-notify'),
    "return_url": "https://www.example.com/your-return-url/",
    "cancel_return": "https://www.example.com/your-cancel-url/"
})
authorization.save()
authorization.pay_url # Send user to this url to pay
authorization.iframe_url # Show an iframe with this url

# After user pay a notification will be sent to notify_url
from zru_django.signals import notification_received

def check_payment(sender, **kwargs):
    notification_data = sender
    if notification_data.is_authorization and notification_data.is_status_done:
        authorization_id = notification_data.id
        sale_id = notification_data.sale_id
        order_id = notification_data.order_id
        # Use authorization_id, sale_id and order_id to check all the data and confirm the payment in your system
notification_received.connect(check_payment)
```

[django]: https://www.djangoproject.com/
[zru-python]: https://github.com/zrupay/zru-python
[zru-developers-key]: https://panel.zrupay.com/config/developers/keys

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/zrupay/zru-django",
    "name": "zru-django",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "zru, payments",
    "author": "ZRU",
    "author_email": "support@zrupay.com",
    "download_url": "https://files.pythonhosted.org/packages/a9/e1/f2f266bd4d1cab7ba7bd75517b673fb05322d96c541aaa315f4106261eff/zru_django-1.0.0.tar.gz",
    "platform": null,
    "description": "# ZRU Django\n\n\n# Overview\n\nZRU Django provides integration access to the ZRU API through django framework.\n\n# Requirements\n\n* [Django][django]\n* [ZRU Python][zru-python]\n\n# Installation\n\nInstall using `pip`...\n\n```bash\npip install zru-django\n```\n\nAdd `'zru_django'` to your `INSTALLED_APPS` setting.\n\n```python\nINSTALLED_APPS = (\n    ...\n    'zru_django',\n    ...\n)\n```\n\nSet the `ZRU_CONFIG` variable in settings.py using the following format:\n```python\nZRU_CONFIG = {\n    'PUBLIC_KEY': '<your_public-key>',\n    'SECRET_KEY': '<your_secret-key>',\n    'CHECK_SIGNATURE_ON_NOTIFICATION': True,\n}\n```\n\nYou can get these values on the [ZRU Panel][zru-developers-key].\n\nThis project is implemented with most versions in mind. For modern (and most) versions of Django, you should use:\n\n```python\nfrom django.urls import path, include\nurlpatterns = [\n    ...\n    path(\"zru/\", include('zru_django.urls')),\n    ...\n]\n```\n\nFor older versions (django<2.0), you should use the `url` function instead of the `path` one.\n \nNote: If you are using an older version of this library, you should set both 'PUBLIC_KEY' and 'PRIVATE_KEY' (set on the Django Admin page) on the settings.py file.\n\n# Migration Guide for Versions Prior to 1.x.x\n\nIf you are migrating from a version prior to 1.x.x, you will need to update your import statements to reflect the change from django_mc2p to zru_django. Here is a guide to help you make these changes.\n\n### Updating Import Statements\n\nFor any imports that used the django_mc2p module, replace django_mc2p with zru_django.\n\n#### Example:\n\nBefore:\n```python\nfrom django_mc2p import MC2PClient\n```\nAfter:\n```python\nfrom zru_django import ZRUClient\n```\n\n### Updating Client class\n\nReplace MC2PClient with ZRUClient.\n\n#### Example\n\nBefore:\n\n```python\nclient = MC2PClient(...)\n```\nAfter:\n\n```python\nclient = ZRUClient(...)\n```\n\n## Steps to Update Your Code\n\n1.  Search and Replace: Use your IDE or a text editor to search for django_mc2p and replace it with zru_django.\n2.  Verify Imports: Ensure all import statements now reference zru_django.\n3.  Run Tests: Run your test suite to verify that your code is functioning correctly with the updated imports.\n\n### Summary\n\nBy following these steps, you can successfully migrate your project from versions prior to 1.x.x, ensuring compatibility with the new zru_django module naming convention.\n\n# Quick Example\n\n### Basic transaction\n\n```python\n# Sending user to pay\nfrom zru_django import ZRUClient\n\nzru = ZRUClient()\ntransaction = zru.Transaction({\n    \"currency\": \"EUR\",\n    \"order_id\": \"order id\",\n    \"products\": [{\n        \"amount\": 1,\n        \"product\": {\n            \"name\": \"Product\",\n            \"price\": 50\n        }\n    }],\n    \"notify_url\": \"https://www.example.com\" + reverse('zru-notify'),\n    \"return_url\": \"https://www.example.com/your-return-url/\",\n    \"cancel_return\": \"https://www.example.com/your-cancel-url/\"\n})\ntransaction.save()\ntransaction.pay_url # Send user to this url to pay\ntransaction.iframe_url # Show an iframe with this url\n\n# After user pay a notification will be sent to notify_url\nfrom zru_django.signals import notification_received\n\ndef check_payment(sender, **kwargs):\n    notification_data = sender\n    if notification_data.is_transaction and notification_data.is_status_done:\n        transaction_id = notification_data.id\n        sale_id = notification_data.sale_id\n        order_id = notification_data.order_id\n        # Use transaction_id, sale_id and order_id to check all the data and confirm the payment in your system\nnotification_received.connect(check_payment)\n```\n\n### Basic subscription\n\n```python\n# Sending user to pay a subscription\nfrom zru_django import ZRUClient\n\nzru = ZRUClient()\nsubscription = zru.Subscription({\n    \"currency\": \"EUR\",\n    \"order_id\": \"order id\",\n    \"plan\": {\n        \"name\": \"Plan\",\n        \"price\": 5,\n        \"duration\": 1,\n        \"unit\": \"M\",\n        \"recurring\": true\n    },\n    \"notify_url\": \"https://www.example.com\" + reverse('zru-notify'),\n    \"return_url\": \"https://www.example.com/your-return-url/\",\n    \"cancel_return\": \"https://www.example.com/your-cancel-url/\"\n})\nsubscription.save()\nsubscription.pay_url # Send user to this url to pay\nsubscription.iframe_url # Show an iframe with this url\n\n# After user pay a notification will be sent to notify_url\nfrom zru_django.signals import notification_received\n\ndef check_payment(sender, **kwargs):\n    notification_data = sender\n    if notification_data.is_subscription and notification_data.is_status_done:\n        subscription_id = notification_data.id\n        sale_id = notification_data.sale_id\n        order_id = notification_data.order_id\n        # Use subscription_id, sale_id and order_id to check all the data and confirm the payment in your system\nnotification_received.connect(check_payment)\n```\n\n### Basic authorization\n\n```python\n# Sending user to pay an authorization\nfrom zru_django import ZRUClient\n\nzru = ZRUClient()\nauthorization = zru.Authorization({\n    \"currency\": \"EUR\",\n    \"order_id\": \"order id\",\n    \"notify_url\": \"https://www.example.com\" + reverse('zru-notify'),\n    \"return_url\": \"https://www.example.com/your-return-url/\",\n    \"cancel_return\": \"https://www.example.com/your-cancel-url/\"\n})\nauthorization.save()\nauthorization.pay_url # Send user to this url to pay\nauthorization.iframe_url # Show an iframe with this url\n\n# After user pay a notification will be sent to notify_url\nfrom zru_django.signals import notification_received\n\ndef check_payment(sender, **kwargs):\n    notification_data = sender\n    if notification_data.is_authorization and notification_data.is_status_done:\n        authorization_id = notification_data.id\n        sale_id = notification_data.sale_id\n        order_id = notification_data.order_id\n        # Use authorization_id, sale_id and order_id to check all the data and confirm the payment in your system\nnotification_received.connect(check_payment)\n```\n\n[django]: https://www.djangoproject.com/\n[zru-python]: https://github.com/zrupay/zru-python\n[zru-developers-key]: https://panel.zrupay.com/config/developers/keys\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "ZRU Django Bindings",
    "version": "1.0.0",
    "project_urls": {
        "Download": "https://github.com/zrupay/zru-django/archive/v1.0.0.tar.gz",
        "Homepage": "https://github.com/zrupay/zru-django"
    },
    "split_keywords": [
        "zru",
        " payments"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a9e1f2f266bd4d1cab7ba7bd75517b673fb05322d96c541aaa315f4106261eff",
                "md5": "3c84a12c2395d85f00bfff6a2076fb0a",
                "sha256": "e5dc33a7fc8b1e4e5bc3046085b6325ad0e15c9cf6959b46d05b4bbb6ff51fea"
            },
            "downloads": -1,
            "filename": "zru_django-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "3c84a12c2395d85f00bfff6a2076fb0a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5633,
            "upload_time": "2024-07-11T18:10:32",
            "upload_time_iso_8601": "2024-07-11T18:10:32.278139Z",
            "url": "https://files.pythonhosted.org/packages/a9/e1/f2f266bd4d1cab7ba7bd75517b673fb05322d96c541aaa315f4106261eff/zru_django-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-11 18:10:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "zrupay",
    "github_project": "zru-django",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "zru-django"
}
        
ZRU
Elapsed time: 0.60929s