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 alipay 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,
        user=None, # 可以指定user
        # reference_id='1' # 可选
    )
    return redirect('alipay_redirect', out_no=payment.out_no)

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.9.4.tar.gz (9.8 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-alipay2-0.9.4.tar.gz
Algorithm Hash digest
SHA256 8972c8c094877f961062657bfbc0f894c36543a512ffedfbf43207a4d9bb8b59
MD5 f99ec790941478c8cb0e12f54e3dd8f7
BLAKE2b-256 53f97dceb94d8dabf38913d36b51c6dc8394ba0eed42c1cd8a8e9d1ba6548d22

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