alipay for django
Project description
==============
django-alipay2
==============
提供django下alipay直接支付接口
Quick start
-----------
1. Install::
pip install django_alipay2
2. Add "alipay" to your INSTALLED_APPS setting like this::
INSTALLED_APPS = [
...
'alipay',
]
3. [Optional] Include the polls URLconf in your project urls.py like this::
url(r'^alipay/', include('alipay.urls')),
4. Migrate::
python manage.py migrate
5. Add config 'ALIPAY' to settings.py like this::
ALIPAY = {
'sandbox': True, # use sandbox client if True
'pid': 'real alipay pid',
'key': 'real alipay key',
'seller': 'your_seller_email@domain.com',
'gateway': 'https://mapi.alipay.com/gateway.do?',
'SERVER_URL': 'http://my.server.com', # for alipay return and notify
}
6. Create alipay redirect::
import uuid
payment = AlipayPayment.objects.create(
out_no=uuid.uuid4(),
subject='充值',
body='1年365元',
amount_total=0.01,
# reference_id='1' # 可选
)
return redirect('alipay_redirect', pk=payment.pk)
7. [Optional] Run sample:
Add to urls.py::
from django.views.generic import TemplateView
from alipay.views import example_alipay_create_view
urlpatterns += [
url(r'^alipay$', TemplateView.as_view(template_name='alipay/samples.html')),
url(r'^alipay/sample/pay/create$', example_alipay_create_view, name='sample_pay_create'),
]
Run server::
python manage.py runserver # visit http://localhost:8000/alipay
django-alipay2
==============
提供django下alipay直接支付接口
Quick start
-----------
1. Install::
pip install django_alipay2
2. Add "alipay" to your INSTALLED_APPS setting like this::
INSTALLED_APPS = [
...
'alipay',
]
3. [Optional] Include the polls URLconf in your project urls.py like this::
url(r'^alipay/', include('alipay.urls')),
4. Migrate::
python manage.py migrate
5. Add config 'ALIPAY' to settings.py like this::
ALIPAY = {
'sandbox': True, # use sandbox client if True
'pid': 'real alipay pid',
'key': 'real alipay key',
'seller': 'your_seller_email@domain.com',
'gateway': 'https://mapi.alipay.com/gateway.do?',
'SERVER_URL': 'http://my.server.com', # for alipay return and notify
}
6. Create alipay redirect::
import uuid
payment = AlipayPayment.objects.create(
out_no=uuid.uuid4(),
subject='充值',
body='1年365元',
amount_total=0.01,
# reference_id='1' # 可选
)
return redirect('alipay_redirect', pk=payment.pk)
7. [Optional] Run sample:
Add to urls.py::
from django.views.generic import TemplateView
from alipay.views import example_alipay_create_view
urlpatterns += [
url(r'^alipay$', TemplateView.as_view(template_name='alipay/samples.html')),
url(r'^alipay/sample/pay/create$', example_alipay_create_view, name='sample_pay_create'),
]
Run server::
python manage.py runserver # visit http://localhost:8000/alipay
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-alipay2-0.4.0.tar.gz
(9.2 kB
view hashes)