提交 dbf51fdb authored 作者: yueweilu's avatar yueweilu

支付宝 支付逻辑

上级 457e4088
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
18D185D62B6745D100561CC8 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 18D185D52B6745D100561CC8 /* StoreKit.framework */; };
297D4B521D4A45CEFC018F23 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D9746A3A42B49971E109B58 /* libPods-Runner.a */; }; 297D4B521D4A45CEFC018F23 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D9746A3A42B49971E109B58 /* libPods-Runner.a */; };
331C80F4294D02FB00263BE5 /* RunnerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 331C80F3294D02FB00263BE5 /* RunnerTests.m */; }; 331C80F4294D02FB00263BE5 /* RunnerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 331C80F3294D02FB00263BE5 /* RunnerTests.m */; };
389E384DCE26FA37EA2BA4FF /* libPods-RunnerTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E360DC6E27A1D286B37E030A /* libPods-RunnerTests.a */; }; 389E384DCE26FA37EA2BA4FF /* libPods-RunnerTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E360DC6E27A1D286B37E030A /* libPods-RunnerTests.a */; };
...@@ -45,6 +46,8 @@ ...@@ -45,6 +46,8 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
18D185D52B6745D100561CC8 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };
18D185D72B674B4300561CC8 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
1D32EB398235AD2BE8600068 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; }; 1D32EB398235AD2BE8600068 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
331C80F1294D02FB00263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 331C80F1294D02FB00263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
331C80F3294D02FB00263BE5 /* RunnerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RunnerTests.m; sourceTree = "<group>"; }; 331C80F3294D02FB00263BE5 /* RunnerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RunnerTests.m; sourceTree = "<group>"; };
...@@ -83,6 +86,7 @@ ...@@ -83,6 +86,7 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
297D4B521D4A45CEFC018F23 /* libPods-Runner.a in Frameworks */, 297D4B521D4A45CEFC018F23 /* libPods-Runner.a in Frameworks */,
18D185D62B6745D100561CC8 /* StoreKit.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -132,6 +136,7 @@ ...@@ -132,6 +136,7 @@
97C146F01CF9000F007C117D /* Runner */ = { 97C146F01CF9000F007C117D /* Runner */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
18D185D72B674B4300561CC8 /* Runner.entitlements */,
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */, 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */,
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */, 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */,
97C146FA1CF9000F007C117D /* Main.storyboard */, 97C146FA1CF9000F007C117D /* Main.storyboard */,
...@@ -169,6 +174,7 @@ ...@@ -169,6 +174,7 @@
DEAEA83548321DAC7AAEFA5B /* Frameworks */ = { DEAEA83548321DAC7AAEFA5B /* Frameworks */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
18D185D52B6745D100561CC8 /* StoreKit.framework */,
7D9746A3A42B49971E109B58 /* libPods-Runner.a */, 7D9746A3A42B49971E109B58 /* libPods-Runner.a */,
E360DC6E27A1D286B37E030A /* libPods-RunnerTests.a */, E360DC6E27A1D286B37E030A /* libPods-RunnerTests.a */,
); );
...@@ -476,6 +482,7 @@ ...@@ -476,6 +482,7 @@
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = MYN43C5WGE; DEVELOPMENT_TEAM = MYN43C5WGE;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
...@@ -644,6 +651,7 @@ ...@@ -644,6 +651,7 @@
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = MYN43C5WGE; DEVELOPMENT_TEAM = MYN43C5WGE;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
...@@ -665,6 +673,7 @@ ...@@ -665,6 +673,7 @@
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = MYN43C5WGE; DEVELOPMENT_TEAM = MYN43C5WGE;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
......
...@@ -22,6 +22,19 @@ ...@@ -22,6 +22,19 @@
<string>$(FLUTTER_BUILD_NAME)</string> <string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>alipay</string>
<key>CFBundleURLSchemes</key>
<array>
<string>zijingbook</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string> <string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.associated-domains</key>
<array/>
</dict>
</plist>
...@@ -163,29 +163,6 @@ abstract class CommonAPI { ...@@ -163,29 +163,6 @@ abstract class CommonAPI {
return result.data['filesUrl']; return result.data['filesUrl'];
} }
/// 11、创建订单
///
static Future <PayOrderModel> createOrder({
required String bookIdsList,
required String totalPrice,
required String couponRecId,
required String integral,
required String type
}) async {
final result = await HttpService.to.post(
'/v1/orders/Orders/createOrders',
params: {
'book_ids_list':bookIdsList,
'total_price':totalPrice,
'coupon_rec_id':couponRecId,
'integral':integral,
'type':type,
},
);
if (result.data is! Map) return PayOrderModel();
return PayOrderModel.fromJson(result.data);
}
} }
\ No newline at end of file
...@@ -109,5 +109,45 @@ abstract class ShopAPI { ...@@ -109,5 +109,45 @@ abstract class ShopAPI {
return CouponNumModel.fromJson(result.data); return CouponNumModel.fromJson(result.data);
} }
/// 8、创建订单
///
static Future <PayOrderModel> createOrder({
required String bookIdsList,
required String totalPrice,
required String couponRecId,
required String integral,
required String type
}) async {
final result = await HttpService.to.post(
'/v1/orders/Orders/createOrders',
params: {
'book_ids_list':bookIdsList,
'total_price':totalPrice,
'coupon_rec_id':couponRecId,
'integral':integral,
'type':type,
},
);
if (result.data is! Map) return PayOrderModel();
return PayOrderModel.fromJson(result.data);
}
/// 9、获取订单状态
static Future <bool> orderStatus({
required String orderNumber,
}) async {
final result = await HttpService.to.post(
'/v1/orders/Orders/getOrdersStatus',
params: {
'ordersnum':orderNumber,
},
);
if (result.data is Map && result.data['pay_success'] == 1){
return true;
}
return false;
}
} }
\ No newline at end of file
...@@ -27,6 +27,10 @@ class BookPayController extends GetxController { ...@@ -27,6 +27,10 @@ class BookPayController extends GetxController {
PayModel(type: 3, name: '紫荆币', icon: 'assets/images/pay_coin.png', selected: false), PayModel(type: 3, name: '紫荆币', icon: 'assets/images/pay_coin.png', selected: false),
]; ];
// 支付宝
Tobias tobias = Tobias();
Fluwx fluwx = Fluwx();
// 时候展示底部视图 // 时候展示底部视图
bool showDetail = false; bool showDetail = false;
...@@ -137,6 +141,8 @@ class BookPayController extends GetxController { ...@@ -137,6 +141,8 @@ class BookPayController extends GetxController {
/// 创建订单 /// 创建订单
void createOrder() async { void createOrder() async {
fluwx.registerApi(appId: "wxd930ea5d5a228f5f",universalLink: "https://your.univerallink.com/link/");
List<Map<String, dynamic>> bookIdsList = []; List<Map<String, dynamic>> bookIdsList = [];
for (CourseModel model in buy){ for (CourseModel model in buy){
Map<String, dynamic> tempMap = { Map<String, dynamic> tempMap = {
...@@ -148,11 +154,30 @@ class BookPayController extends GetxController { ...@@ -148,11 +154,30 @@ class BookPayController extends GetxController {
} }
// 书豆支付的话先判断书豆数量 // 书豆支付的话先判断书豆数量
if (payModel.type == 3){
if (finalPrice.toDouble() > double.parse(showModel.membersBean.toString())){ if (finalPrice.toDouble() > double.parse(showModel.membersBean.toString())){
Toast.show('紫金币不足,请先充值紫荆币'); Toast.show('紫金币不足,请先充值紫荆币');
return; return;
} }
final result = await CommonAPI.createOrder( }
// 支付宝
if (payModel.type == 2){
final result = await tobias.isAliPayInstalled;
if(!result){
Toast.show('请先安装支付宝');
return;
}
}
// 微信
if (payModel.type ==1){
final result = await fluwx.isWeChatInstalled;
if(!result){
Toast.show('请先安装微信');
return;
}
}
final result = await ShopAPI.createOrder(
bookIdsList:jsonEncode(bookIdsList) , bookIdsList:jsonEncode(bookIdsList) ,
totalPrice: finalPrice.toString(), totalPrice: finalPrice.toString(),
couponRecId: useCouponModel.couponRecId.toString(), couponRecId: useCouponModel.couponRecId.toString(),
...@@ -164,26 +189,72 @@ class BookPayController extends GetxController { ...@@ -164,26 +189,72 @@ class BookPayController extends GetxController {
// 微信 // 微信
if(payModel.type == 1){ if(payModel.type == 1){
String orderNumber = payOrderModel.ordersnum.toString(); String orderNumber = payOrderModel.ordersnum.toString();
//TODO: 拿到订单编号进行微信支付操作 requestWechat();
} }
// 支付宝 // 支付宝
else if(payModel.type == 2){ else if(payModel.type == 2){
String orderNumber = payOrderModel.ordersnum.toString(); String orderNumber = payOrderModel.ordersnum.toString();
//TODO: 拿到订单编号进行支付宝支付操作 requestAliPay();
} }
// 书豆 // 书豆
else if (payModel.type == 3){ else if (payModel.type == 3){
if(payOrderModel.code == -1){ if(payOrderModel.code == -1){
Toast.show('紫金币不足,请先充值紫荆币'); Toast.show('紫金币不足,请先充值紫荆币');
return;
} }
String orderNumber = payOrderModel.ordersnum.toString(); String orderNumber = payOrderModel.ordersnum.toString();
//TODO: 拿到订单编号进行后续操作 //TODO: 拿到订单编号进行后续操作
} }
}
// 支付宝支付
void requestAliPay(){
print('================================================================${payOrderModel.encryptionOrder!}');
tobias.pay(payOrderModel.encryptionOrder!).then((payResult){
if (payResult['resultStatus'] == '9000') {
requestOrderStatus();
} else {
Toast.show(payResult['memo'].toString());
}
});
}
// 微信支付
void requestWechat(){
Payment payment = Payment(
appId: payOrderModel.appid??'',
partnerId: payOrderModel.partnerid??'',
prepayId: payOrderModel.prepayid??'',
packageValue: payOrderModel.package??'',
nonceStr: payOrderModel.noncestr??'',
timestamp: payOrderModel.timestamp!.toInt(),
sign: payOrderModel.sign??''
);
fluwx.pay(which: payment);
fluwx.addSubscriber((response) {
if (response.errCode == 0) {
requestOrderStatus();
}
else{
Toast.show('${response.errStr}');
}
});
} }
void requestOrderStatus() async {
final result = await ShopAPI.orderStatus(orderNumber: payOrderModel.ordersnum??'');
if (result){
Toast.show('订单支付完成');
}
}
} }
\ No newline at end of file
...@@ -10,8 +10,10 @@ import 'package:flutter_book/apis/index.dart'; ...@@ -10,8 +10,10 @@ import 'package:flutter_book/apis/index.dart';
import 'package:flutter_book/theme.dart'; import 'package:flutter_book/theme.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:fluwx/fluwx.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:tobias/tobias.dart';
import '../../models/index.dart'; import '../../models/index.dart';
import '../../routes/index.dart'; import '../../routes/index.dart';
......
...@@ -12,7 +12,7 @@ class BuildItem extends StatelessWidget { ...@@ -12,7 +12,7 @@ class BuildItem extends StatelessWidget {
return Container( return Container(
margin: EdgeInsets.only(left: 10.w,right: 10.w,top:10.w), margin: EdgeInsets.only(left: 10.w,right: 10.w,top:10.w),
padding: const EdgeInsets.symmetric(horizontal: 10,vertical: 10), padding: const EdgeInsets.symmetric(horizontal: 10,vertical: 10),
height: 75.w, // height: 75.w,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.w), borderRadius: BorderRadius.circular(8.w),
color: Colors.white color: Colors.white
......
差异被折叠。
...@@ -99,6 +99,8 @@ dependencies: ...@@ -99,6 +99,8 @@ dependencies:
flutter_app_update: ^3.0.4 flutter_app_update: ^3.0.4
# 能指定滑动位置的listView # 能指定滑动位置的listView
azlistview: ^2.0.0 azlistview: ^2.0.0
# 支付宝
tobias: ^3.3.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
...@@ -151,3 +153,5 @@ flutter: ...@@ -151,3 +153,5 @@ flutter:
# #
# For details regarding fonts from package dependencies, # For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages # see https://flutter.dev/custom-fonts/#from-packages
tobias:
url_scheme: zijingbook
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论