A Django app for integrating Globee Payments
Project description
# django-globee
[![PyPI version](https://badge.fury.io/py/django-globee.svg)](https://badge.fury.io/py/django-globee)
django-globee is a Django app to integrate GloBee Payments.
Quick start
-----------
1. Add "globee" to your INSTALLED_APPS setting like this:
```python
INSTALLED_APPS = [
...
'globee',
]
```
2. Include the globee URLconf in your project urls.py like this:
```python
path('globee/', include('globee.urls')),
```
3. Include your globee key and test or live env in your project settings.py
```python
GLOBEE_AUTH_KEY = "YOUR GLOBEE X-AUTH-KEY"
GLOBEE_TEST_MODE = True # or False
```
4. Run `python manage.py migrate` to create the globee models.
## example
### create GloBee payment
```python
from random import randint
from django.http import HttpResponseRedirect
from django.urls.base import reverse
from globee.core import GlobeePayment
def my_payment_view(request):
custom_payment_id = 'Your-custom-payment-id-%s' % randint(1, 9999999)
payment_data = {
'total': 10.50,
'currency': 'USD',
'custom_payment_id': custom_payment_id,
'customer': {
'name': request.user.username,
'email': request.user.email
},
'success_url': request.build_absolute_uri(reverse('your-success-url')),
'cancel_url': request.build_absolute_uri(reverse('your-cancel-url')),
'ipn_url': request.build_absolute_uri(reverse('globee-ipn')),
}
payment = GlobeePayment(data=payment_data)
# check required fields for globee payments
if payment.check_required_fields():
# create payment request
if payment.create_request():
# redirect to globee payment page
return HttpResponseRedirect(payment.redirect_url)
```
### get GloBee ipn signal
```python
from django.dispatch import receiver
from globee.models import PAYMENT_STATUS_GLOBEE_CONFIRMED
from globee.signals import globee_valid_ipn
@receiver(globee_valid_ipn)
def crypto_payment_ipn(sender, **kwargs):
payment = sender
# check if payment is confirmed or use any other payment status
if payment.payment_status == PAYMENT_STATUS_GLOBEE_CONFIRMED:
# get some payment infos
amount = payment.total # payment amount
currency = payment.currency # payment currency
payment_id = payment.payment_id # payment id from GloBee
custom_payment_id = payment.custom_payment_id # your custom payment id
customer_email = payment.customer_email # customer email
# Do more stuff
```
[![PyPI version](https://badge.fury.io/py/django-globee.svg)](https://badge.fury.io/py/django-globee)
django-globee is a Django app to integrate GloBee Payments.
Quick start
-----------
1. Add "globee" to your INSTALLED_APPS setting like this:
```python
INSTALLED_APPS = [
...
'globee',
]
```
2. Include the globee URLconf in your project urls.py like this:
```python
path('globee/', include('globee.urls')),
```
3. Include your globee key and test or live env in your project settings.py
```python
GLOBEE_AUTH_KEY = "YOUR GLOBEE X-AUTH-KEY"
GLOBEE_TEST_MODE = True # or False
```
4. Run `python manage.py migrate` to create the globee models.
## example
### create GloBee payment
```python
from random import randint
from django.http import HttpResponseRedirect
from django.urls.base import reverse
from globee.core import GlobeePayment
def my_payment_view(request):
custom_payment_id = 'Your-custom-payment-id-%s' % randint(1, 9999999)
payment_data = {
'total': 10.50,
'currency': 'USD',
'custom_payment_id': custom_payment_id,
'customer': {
'name': request.user.username,
'email': request.user.email
},
'success_url': request.build_absolute_uri(reverse('your-success-url')),
'cancel_url': request.build_absolute_uri(reverse('your-cancel-url')),
'ipn_url': request.build_absolute_uri(reverse('globee-ipn')),
}
payment = GlobeePayment(data=payment_data)
# check required fields for globee payments
if payment.check_required_fields():
# create payment request
if payment.create_request():
# redirect to globee payment page
return HttpResponseRedirect(payment.redirect_url)
```
### get GloBee ipn signal
```python
from django.dispatch import receiver
from globee.models import PAYMENT_STATUS_GLOBEE_CONFIRMED
from globee.signals import globee_valid_ipn
@receiver(globee_valid_ipn)
def crypto_payment_ipn(sender, **kwargs):
payment = sender
# check if payment is confirmed or use any other payment status
if payment.payment_status == PAYMENT_STATUS_GLOBEE_CONFIRMED:
# get some payment infos
amount = payment.total # payment amount
currency = payment.currency # payment currency
payment_id = payment.payment_id # payment id from GloBee
custom_payment_id = payment.custom_payment_id # your custom payment id
customer_email = payment.customer_email # customer email
# Do more stuff
```
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-globee-1.0.0.tar.gz
(6.4 kB
view details)
Built Distribution
File details
Details for the file django-globee-1.0.0.tar.gz
.
File metadata
- Download URL: django-globee-1.0.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c19058c141034b46ca0e38725b4454997e5a2b898ff4ce1f85bb721f9e1e60e5 |
|
MD5 | d9db4d45241aef0ec35d3a14af7a0f28 |
|
BLAKE2b-256 | af64b5767b0f60fc4b0cc45cf08d3250b495711f8172b995ba34fba1f348a919 |
Provenance
File details
Details for the file django_globee-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: django_globee-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31d4f258680698319dea1824cf7482789714dd1dafd5c0ba60d8a39aa4532685 |
|
MD5 | fc970cd62638a8186b6b05877f6731cb |
|
BLAKE2b-256 | f249d1bf23d3a1aa356e5b61153bf9504675fe6f1ad7ee9ddcd16d5c393bcd3b |