Skip to main content

alipay for django

Project description

提供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:

    python manage.py runserver # visit http://localhost:8000/alipay (if you did step 3)

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-alipay2-0.3.0.tar.gz (8.9 kB view details)

Uploaded Source

File details

Details for the file django-alipay2-0.3.0.tar.gz.

File metadata

File hashes

Hashes for django-alipay2-0.3.0.tar.gz
Algorithm Hash digest
SHA256 c0df622a11a67ed1579001f2c91a0f6c48b38938df7459dfac2ee93fba506bab
MD5 d236dbfd712b0eff79c538dd41552ea4
BLAKE2b-256 b678edbc1b6b06629bd8b6344c8e6c825d1832064b5a1b2594f530ca5d119d7e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page