Skip to content

Latest commit

 

History

History
141 lines (96 loc) · 4.61 KB

README_CN.md

File metadata and controls

141 lines (96 loc) · 4.61 KB

logo pub package

QQ 群:892398530。

Tobias是什么

Tobias是一个为支付宝支付SDK做的Flutter插件。

开始

在使用前强烈阅读官方接入指南。 Tobias 可以完成一部分但不是全部工作。 例如,在iOS上你还要设置URL Scheme。

支付

Tobias使用起来很简单,只需要把从服务器取得的字符串交给Tobias就行了:
如果安卓出现Unhandled Exception: MissingPluginException(No implementation found for method pay on channel com.jarvanmo/tobias)错误
请将android/build.gradle更改为同一版本。

import 'package:tobias/tobias.dart' as tobias;
tobias.pay(yourOrder);

返回值是一个包含支付宝支付结果的map。其中还包含了一个额外的 platform字段, 它的值为 iOSandroid

注意:Tobias 使用的是 pay_V2.

授权登录

    tobias.auth("your auth str");

检查支付宝安装情况

    var result = await tobias.isAliPayInstalled();
   

如果你想在iOS上检测支付宝是否已安装,请确保你已经在info.plist中将alipays添加至白名单。

在 iOS中还要添加一个名为alipay的URL Schema,否则无法返回你的app. 通过GUI添加: url_schema

info.plist文件中添加:

<array>
   		<dict>
   			<key>CFBundleTypeRole</key>
   			<string>Editor</string>
   			<key>CFBundleURLName</key>
   			<string>alipay</string>
   			<key>CFBundleURLSchemes</key>
   			<array>
   				<string>tobiasexample</string>
   			</array>
   		</dict>
   	</array>

你可以通过调用 tobias.version() 来获取对应平上的SDK版本,其返回值是一个包含 versionplatform的map。 结果示例:

{
result: partner="2088411752388544"&seller_id="[email protected]"&out_trade_no="180926084213001"&subject="test pay"&total_fee="0.01"&notify_url="http://127.0.0.1/alipay001"&service="mobile.securitypay.pay"&payment_type="1"&_input_charset="utf-8"&it_b_pay="30m"&return_url="m.alipay.com"&success="true"&sign_type="RSA"&sign="nCZ8MDhsNvYNAbrLZJZ2VUy6vydgAp+JCq1aQo6ORDYtI9zwtnja3qNGQNiDJCuktoIj7fSTM487XhjPDqnOreZjIA1GJpxu9D1I3nMXIn1M7DfZ0noDwXcYZ438/jbYac7g8mhpwdKGweLCAni9mO3Y6q3iBFkox8i9PcsGxJY=",
resultStatus: 9000,
 memo: ,
 platform:iOS
}

升级到1.0.0

tobais 1.0.0开始开发者不必重写AppDelegate了。如果你以前重写了这个方法,请在 AppDelegate中删除相应的代码:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
  return [WXApi handleOpenURL:url delegate:[FluwxResponseHandler defaultManager]];
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options
{
  return [WXApi handleOpenURL:url delegate:[FluwxResponseHandler defaultManager]];
}

如果一定要重写这2个方法,请确保你调用了 super:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    
  return [super application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options
{
    
  return [super application:application openURL:url options:options];
}

请作者喝杯咖啡。

欢迎关注公众号

subscribe

LICENSE

Copyright 2018 OpenFlutter Project

Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements.  See the NOTICE file distributed with this work for
additional information regarding copyright ownership.  The ASF licenses this
file to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License.  You may obtain a copy of
the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
License for the specific language governing permissions and limitations under
the License.