1. 支付宝客户端支付流程。 官方支付流程文档:https://docs.open.alipay.com/59/103658/
2. 准备已有的 Flutter 项目安装插件 https://pub.dev/packages/sy_flutter_alipay
3. 服务器端调用支付宝 sdk 生成订单信息 1. 服务端sdk下载地址:https://docs.open.alipay.com/54/103419/
2. 本教程采用的php的sdk,看演示
4. 客户端调用服务器端接口生成订单签名 信息,调用支付插件完成支付
5. 服务器端异步回调更新订单信息 当支付成功后支付宝会异步给服务器 post 数据,服务器更新订单信息
6.Flutter 在 Xcode 上编译提示:Target ‘Runner‘: script phase “[CP] Embed Pods Frameworks”的解决方法
解决方法:https://www.cflutter.com/topic/5d09a1c73b57e317a4d0af08
import ‘package:flutter/material.dart‘;
import ‘package:sy_flutter_alipay/sy_flutter_alipay.dart‘;
import ‘package:dio/dio.dart‘;
class HomePage extends StatefulWidget { HomePage({Key key}) : super(key: key); _HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
_doPay() async{
var apiUrl=‘http://agent.itying.com/alipay/index.php‘; var myPayInfo =await Dio().get(apiUrl);
final payInfo =myPayInfo.data; print(payInfo);
var result = await SyFlutterAlipay.pay( payInfo,
// urlScheme: ‘你的 ios urlScheme‘, //前面配置的 urlScheme
// isSandbox: true //是否是沙箱环境,只对 android 有效 );
print(result); }
@override
Widget build(BuildContext context) {
return Center( child: Column(
mainAxisAlignment: MainAxisAlignment.center, children: [
SizedBox(height: 20), RaisedButton(
child: Text(‘支付宝支付‘),
onPressed: _doPay, ),
SizedBox(height: 20), ],
), );
} }