Coder Social home page Coder Social logo

foursmallleaves / django-wechat-pay Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mrhaoji/django-wechat-pay

0.0 1.0 0.0 14.36 MB

通过 Django, Django Rest Framework, wechatpy 实现微信小程序端的支付功能

Python 68.59% JavaScript 31.41%

django-wechat-pay's Introduction

django-wechat-pay

通过 Django, Django Rest Framework, wechatpy 实现微信小程序端的支付功能

简要指南

server 端

商户系统先调用该接口在微信支付服务后台生成预支付交易单,返回正确的预支付交易回话标识后再在APP里调起支付

克隆该项目到本地目录

cd django-wechat-pay/server/djangoWechat/
pip install -r requirements.txt
python3 manage.py runserver

配置支付参数

配置文件路径: django-wechat-pay/server/djangoWechat/djangoWechat/settings.py

# wechat config
WECHAT = {
        'APPID': 'appid',                                           # 小程序ID
        'APPSECRET': 'appsecret',			                        # 小程序SECRET
        'MCH_ID': 'mch_id',                                         # 商户号
        'TOTAL_FEE': '1',                                           # 总金额
        'SPBILL_CREATE_IP': '127.0.0.1',                            # 终端IP
        'NOTIFY_URL': 'http://127.0.0.1:8000/wxpayNotify',          # 通知地址
        'TRADE_TYPE': 'JSAPI',                                      # 交易类型
        'MERCHANT_KEY': 'merchant_key',                             # 商户KEY
        'BODY': '商品描述',                                           # 商品描述
}

接口地址

支付接口:http://127.0.0.1:8000/wxpay/
通知接口:http://127.0.0.1:8000/wxpayNotify

client 端

通过微信开发者工具新建项目,将 APPID 替换成你拥有权限的 APPID 进行测试及后续开发…

暂时只提供了基本的支付演示,server 端启动成功的前提下小程序载入编译后会立即调起支付接口,使用当前开发者的微信即可支付。

其他

该 demo 只做了简单的支付功能,现金红包、企业付款、订单查询、退款等有空再加上…

ONE MORE THING...

微信群

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.