Django Gate2Shop
How to install
Using pip:
$ pip install django-gate2shop
- Edit “settings.py”
add “g2s” to your “INSTALLED_APPS”
add following settings:
G2S_MERCHANT_ID = "123456"
G2S_SECRET_KEY = "YourSecretWord"
G2S_MERCHANT_SITE_ID = "1234567"
G2S_CURRENCY = 'USD'
Add to “urls.py” paths
urlpatterns = patterns('',
url(r'^g2s/g2s_form/$', 'g2s_form', name='g2s-form'),
url(r'^g2s/', include('g2s.urls')),
)
Create table in your database
$ python manage.py syncdb
$ python manage.py migrate
Create/render form
Create an instance of the form in your “views.py” and make render in your template
from g2s.forms import G2SForm
def g2s_form(request):
# this is what user wants to buy
items_list = [
{
'item_name': 'Test',
'item_amount': 1.11,
'item_quantity': 1,
},
]
# this data you can get from user profile or from custom user model
payment_details = {
'country': 'Russia',
'city': 'Moscow',
'address1': 'Moscow, Arbat',
'zip': '121099',
'first_name': 'Ivan',
'last_name': 'Ivanov',
'email': 'ivanov.ivan@yandex.ru',
'phone1': '+79031234567',
'total_amount': 1.11,
'user_token_id': 1,
'productId': 1,
}
form = G2SForm(items_list, initial=payment_details)
return render(request, "g2s/order.html", {"form": form})
In “order.html”:
{{ form.render }}
After payment G2S sends a signal to your server (DMN URL). The transaction will be saved in the database, then will be send a signal. You can use it to process your own actions (add amount to users account, etc..)
from django.forms.models import model_to_dict
from g2s.signals import g2s_payment_was_successful
from pprint import pprint
def transaction_result(sender, **kwargs):
if sender.Status == 'APPROVED':
pprint(model_to_dict(sender))
g2s_payment_was_successful.connect(
transaction_result, dispatch_uid="demo.models.transaction_result")
Demo installation:
$ pip install virtualenvwrapper
$ source /usr/local/bin/virtualenvwrapper.sh
$ mkvirtualenv django-gate2shop
$ git clone https://github.com/gotlium/django-gate2shop.git
$ cd django-gate2shop
$ python setup.py develop
$ cd demo
$ pip install -r requirements.txt
$ python manage.py syncdb --noinput && python manage.py migrate --noinput
$ python manage.py runserver >& /tmp/runserver.log &
$ xdg-open http://127.0.0.1:8000/g2s/
Full Gateway Specification available at: http://www.g2s.com/documentation/
Metadata
Release files for django-gate2shop 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-gate2shop-1.0.2.tar.gz | 14.7 kB | Without provenance | Details for django-gate2shop-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_gate2shop-1.0.2-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for django_gate2shop-1.0.2-py2.py3-none-any.whl |
Total release size: 28.0 kB
Release files / django-gate2shop-1.0.2.tar.gz
| Download URL | django-gate2shop-1.0.2.tar.gz |
|---|---|
| Size | 14.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aad8f7f48144f48689eb0b73fb973c467300b9e1b22146c382ea3242eb4d8623
|
|
BLAKE2b-256 checksum How to use checksums |
c32cc764860ddc3ada0a49251c3a32e5116d4e22955bf63ce7ee7ee5f84b1114
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django_gate2shop-1.0.2-py2.py3-none-any.whl
| Download URL | django_gate2shop-1.0.2-py2.py3-none-any.whl |
|---|---|
| Size | 13.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
057752fdb0c1fb047277daeae913a4ed7455025e29f7d87c54bb5922e5a6706d
|
|
BLAKE2b-256 checksum How to use checksums |
32fb09174ea8a3fae0ac8ca9575280dcc9a5ebf705cbf24cb662bda6bdb738ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-gate2shop 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.