alipay_me 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 41

alipay_me #

pub package GitHub GitHub stars

Alipay plug-in. Support payment and authorized login. Support Android and iOS. Android supports local computational signatures.

Usage #

To use this plugin, add alipay_me as a dependency in your pubspec.yaml file.

ROADMAP #

  • [x] 发起支付
  • [x] 授权登录
  • [x] 本地计算签名(仅Android)
  • [x] 沙盒模式(仅Android)

Supported Platforms

  • Android
  • IOS

Examples #

  • Examples App - Demonstrates how to use the alipay_me plugin.
import 'package:alipay_me/alipay_me.dart';

  // 初始化
  initAlipay() async {
    final String tid = "tid_${DateTime.now().millisecondsSinceEpoch}";
    await AlipayMe.init(
        appId: "2019010362782013",
        pid: "2088012716890635",
        rsa2Private: RSAPrivate,
        targetId: tid
    );
  }
  
  // 发起支付
  var o = await AlipayMe.pay(apyInfo,
      urlScheme: "alisdkdemo",  // 这里的URL Schemes中输入的alisdkdemo,为测试demo,实际商户的app中要填写独立的scheme
      isSandbox: _isSandbox,
   );

  //授权申请
  await AlipayMe.auth(
        urlScheme: "alisdkdemo", // 这里的URL Schemes中输入的alisdkdemo,为测试demo,实际商户的app中要填写独立的scheme
        isSandbox: _isSandbox,
        authInfo: data,
      );
  

License MIT #

Copyright (c) 2019

1.0.0 #

  • TODO: Describe initial release.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:io';

import 'package:flutter/services.dart';
import 'package:alipay_me/alipay_me.dart';

import 'sign.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Page(),
    );
  }


}

class Page extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _PageState();
  }
}

class _PageState extends State<Page> {
  String msg = "";
  bool _isSandbox = false;
  String version;

  @override
  void initState() {
    super.initState();
    AlipayMe.getVersion().then((v) {
      setState(() {
        version = v;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        title: const Text('支付宝插件示例'),
      ),
      body: Padding(padding: const EdgeInsets.all(16.0), child: ListView(
        primary: true,
        children: <Widget>[
          Text("开发包版本号:${version ?? ""}"),
          SizedBox(height: 8.0),
          Row(
            children: <Widget>[
              Checkbox(value: _isSandbox, onChanged: (v) {
                setState(() {
                  _isSandbox = v;
                });
              }),
              Text("沙盒模式")
            ],
          ),
          SizedBox(height: 32.0),
          OutlineButton(child: Text("支付"), onPressed: () {
            doPay(context);
          }),
          OutlineButton(child: Text("授权登录"), onPressed: () {
            doOauth(context);
          }),
          SizedBox(height: 32.0),
          OutlineButton(child: Text("测试Sign"), onPressed: () {
            testSign();
          }),
          SizedBox(height: 32.0),
          Text(msg ?? "", style: TextStyle(fontSize: 10.0, color: Colors.blue)),
        ],
      )),
    );
  }

  doPay(BuildContext context) async {
    showDialog<void>(context: context, builder: (context) {
      TextEditingController edtPayInfo = new TextEditingController();
      return AlertDialog(
        title: Text("支付宝付款"),
        content: Container(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              Text("请输入服务器返回的payInfo:"),
              TextField(
                controller: edtPayInfo,
                maxLines: 2,
              )
            ],
          ),
        ),
        actions: <Widget>[
          FlatButton(
            child: Text("取消"),
            onPressed: () {
              Navigator.pop(context);
            },
          ),
          FlatButton(
            child: Text("确定"),
            onPressed: () {
              Navigator.pop(context);
              doPayExec(edtPayInfo.text);
            },
          )
        ],
      );
    });
  }

  doPayExec(String apyInfo) async {
    print("apyInfo: $apyInfo");
    await initAlipay();

    var o = await AlipayMe.pay(apyInfo,
      urlScheme: "alisdkdemo",  // 这里的URL Schemes中输入的alisdkdemo,为测试demo,实际商户的app中要填写独立的scheme
      isSandbox: _isSandbox,
    );
    setState(() {
      msg = "$o";
    });
  }

  doOauth(BuildContext context) async {
    await initAlipay();
    String data;
    if (Platform.isIOS) {
      data = "Server AuthInfo";  // ioS平台只支持服务器返回
    }
    var o = await AlipayMe.auth(
      urlScheme: "alisdkdemo", // 这里的URL Schemes中输入的alisdkdemo,为测试demo,实际商户的app中要填写独立的scheme
      isSandbox: _isSandbox,
      authInfo: data,
    );
    setState(() {
      msg = "$o";
    });
  }

  initAlipay() async {
    final String tid = "tid_${DateTime.now().millisecondsSinceEpoch}";
    await AlipayMe.init(
        appId: "2019010362782013",
        pid: "2088012716890635",
        rsa2Private: RSAPrivate,
        targetId: tid
    );
  }

  void testSign() async {
    Map<String, String> map = new Map<String, String>();
    map["appId"] = "2013081700024223";
    map["pid"] = "2088102123816631";
    map["apiname"] = "com.alipay.account.auth";
    map["app_name"] = "mc";
    map["product_id"] = "APP_FAST_LOGIN";
    map["auth_type"] = "AUTHACCOUNT";
    map["test"] = "中文fdsafdsafdas";

    Sign.getSignFormMap(map, RSAPrivate, true).then((v) {
      setState(() {
        msg = v;
      });
      print(v);
    });
  }

  final String RSAPrivate = '''
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC1GnINzLscYTX6
LRMXMDTbuLSBtzxE69s2Acv2WdbKiIf8dSzt3wXy/Kev7FXhHNxCOuF6aSTR/RrO
q2/FQ96tWh/99a9WoIoIpyHbODxlOslxg8tsiuoqs2bIrktq2wrOrb9D+RoeOlZ/
hAGKwRDGo+0LNbxrsaygeShZpCffjFqQpZnjdZPEB+XggxxoQ2MnZoIg7qu0krN8
SqCpLrpx206vd1WIqrGbzpG5WQWXOocwGxzMlADxL5dbeGEdHhSKBV2U5gjjCSXV
0acCo42mjXNryc/u+vIrdh31yxeh4YDBwmbsc8lg0Bl25uiLBSxP61z1p4L/RzZv
bE5O5uHXAgMBAAECggEBAKYbQW0i0KOxDd8OpKnqDzFQck9fjynv4jng4ABuWjGd
lIybtL/ghQZfcjZLYGF/JQ6iDtlFwv3PVl0kpPmbzIvXU+yNAWtFCBXzpXv6UnrO
tqElLtm5eBn+PlHme0ng6kKy3fEscyYyf8+pdfic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L8mnAJW8X/J6mpiCkivQ==''';

}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  alipay_me: ^1.0.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:alipay_me/alipay_me.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
55
Overall:
Weighted score of the above. [more]
41
Learn more about scoring.

We analyzed this package on Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.9+1
  • Flutter: 1.17.3

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:alipay_me/alipay_me.dart]

Package does not support Flutter platform macos

Because of import path [package:alipay_me/alipay_me.dart]

Package does not support Flutter platform web

Because of import path [package:alipay_me/alipay_me.dart]

Package does not support Flutter platform windows

Because of import path [package:alipay_me/alipay_me.dart]

Package not compatible with SDK dart

because of import path [alipay_me]

Health suggestions

Format lib/alipay_me.dart.

Run flutter format to format lib/alipay_me.dart.

Maintenance suggestions

Package is getting outdated. (-45.48 points)

The package was last published 75 weeks ago.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.0
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8