zoukankan      html  css  js  c++  java
  • Flutter 微信支付实现流程 、微信支付后 台 PHP 代码分析、以及在 Ios 中实现微信 支付

    Flutter 微信支付流程

    1、官方流程图: https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_3 2、简单流程:

    1. 调用后台 api 接口生成签名字段
    2. 调用支付插件传入签名字段完成支付 3. 支付完成以后处理回调

    Ios 中实现微信支付  sy_flutter_wechat

     

    import 'dart:convert';
    import 'package:flutter/material.dart';
    import 'package:sy_flutter_wechat/sy_flutter_wechat.dart'; import 'package:dio/dio.dart';
    void main() => runApp(MyApp());
    class MyApp extends StatelessWidget {
    // This widget is the root of your application. @override
    Widget build(BuildContext context) {
    return MaterialApp( title: 'Flutter Demo', theme: ThemeData(
    // This is the theme of your application.
    //
    // Try running your application with "flutter run". You'll see
    the
    try
    invoke
    // application has a blue toolbar. Then, without quitting the app, // changing the primarySwatch below to Colors.green and then
    // "hot reload" (press "r" in the console where you ran "flutter run",
    // or simply save your changes to "hot reload" in a Flutter IDE).
    // Notice that the counter didn't reset back to zero; the application
    // is not restarted.
    primarySwatch: Colors.blue, ),
    home: HomePage(), );
    } }
    class HomePage extends StatefulWidget {
    HomePage({Key key}) : super(key: key);
    _HomePageState createState() => _HomePageState(); }
    class _HomePageState extends State<HomePage> {
    @override
    void initState() {
    super.initState();
    _register();
    }
    _register() async {
    bool result = await SyFlutterWechat.register('wx5881fa2638a2ca60'); print(result);
    }
    _weixinPay() async{
    var apiUrl='http://agent.itying.com/wxpay/'; var myPayInfo =await Dio().get(apiUrl);
    Map myInfo =json.decode(myPayInfo.data); print(myInfo);
    var payInfo={ "appid":myInfo["appid"].toString(),

    "partnerid":myInfo["partnerid"].toString(), "prepayid":myInfo["prepayid"].toString(), "package":myInfo["package"].toString(), "noncestr":myInfo["noncestr"].toString(), "timestamp":myInfo["timestamp"].toString(), "sign":myInfo["sign"].toString(),
    };
    SyPayResult payResult = await SyFlutterWechat.pay(
    SyPayInfo.fromJson(payInfo)); print(payResult);
    }
    @override
    Widget build(BuildContext context) {
    return Scaffold(
    appBar: AppBar(
    title: Text("微信"), ),
    body: Center(
    child: Column(
    mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
    RaisedButton(
    child: Text('分享文字'), onPressed: () async {
    bool res = await SyFlutterWechat.shareText('hello
    shareType: SyShareType.session); print('分享文字:' + res.toString());
    }, ),
    RaisedButton(
    child: Text('分享图片'), onPressed: () async {
    bool res = await SyFlutterWechat.shareImage(
    'https://avatars0.githubusercontent.com/u/10024776', shareType: SyShareType.timeline); print('分享图片:' + res.toString());
    }, ),
    world',


    RaisedButton(
    child: Text('分享网页'), onPressed: () async {
    bool res = await SyFlutterWechat.shareWebPage( '标题',
    '描述',
    'https://avatars0.githubusercontent.com/u/10024776', 'http://www.example.com',
    shareType: SyShareType.session); print('分享网页:' + res.toString());
    }, ),
    RaisedButton(
    child: Text('支付'), onPressed: _weixinPay,
    ), ],
    ), ),
    ); }
    }
     
  • 相关阅读:
    关于Maya Viewport 2.0 API 开发的介绍视频
    春节大假
    Some tips about the life cycle of Maya thread pool
    Can I compile and run Dx11Shader for Maya 2015 on my side?
    How to get current deformed vertex positions in MoBu?
    想加入全球首届的 欧特克云加速计划吗?
    三本毕业(非科班),四次阿里巴巴面试,终拿 offer(大厂面经)
    mac、window版编辑器 webstorm 2016... 永久破解方法。
    node 搭载本地代理,处理web本地开发跨域问题
    js 一维数组,转成嵌套数组
  • 原文地址:https://www.cnblogs.com/zhaofeis/p/12761396.html
Copyright © 2011-2022 走看看