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:

    # account below is for sandbox
    ALIPAY = {
        'pid': '2088101122136241',
        'key': '760bdzec6y9goq7ctyx96ezkz78287de',
        'seller_email': 'overseas_kgtest@163.com',
        'gateway': 'https://openapi.alipaydev.com/gateway.do?',
        'server_url': 'http://localhost:8000'
    
        # RSA specified
        'rsa_public_raw_key': '',
        'sign_type': 'RSA',
    }
    
    # you may add an 'api_provider' to support multiple seller
    ALIPAY = {
        'api_provider': 'some_package.sub_package.get_alipay_alipay'  # input:seller_email, output:AlipayAPI
    }
  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
        seller_email='your_seller_email@domain.com',
        # 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.15.1.tar.gz (14.9 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: django-alipay2-0.15.1.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

File hashes

Hashes for django-alipay2-0.15.1.tar.gz
Algorithm Hash digest
SHA256 24d607006d9d64731e540972fc43ddf8087d62ee0d60ba14f5c3fad91d694583
MD5 76a17e6240f0273ea73159081e63b868
BLAKE2b-256 6561636801a41dc37672bd3ff77b73c2169830bdd43cf7f08936e21e7c838153

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