Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions alipay_kit/lib/src/alipay_kit_method_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ class MethodChannelAlipayKit extends AlipayKitPlatform {
Future<void> pay({
required String orderInfo,
bool isShowLoading = true,
bool sandbox = false /// 沙箱模式
}) {
return methodChannel.invokeMethod<void>(
'pay',
<String, dynamic>{
'orderInfo': orderInfo,
'isShowLoading': isShowLoading,
'sandbox': sandbox,
},
);
}
Expand Down
5 changes: 4 additions & 1 deletion alipay_kit/lib/src/alipay_kit_platform_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ abstract class AlipayKitPlatform extends PlatformInterface {
Future<void> pay({
required String orderInfo,
bool isShowLoading = true,
bool sandbox = false /// 沙箱模式
}) {
throw UnimplementedError(
'pay({required orderInfo, isShowLoading}) has not been implemented.');
Expand All @@ -55,9 +56,11 @@ abstract class AlipayKitPlatform extends PlatformInterface {
/// 登录
Future<void> auth({
required String authInfo,
bool isShowLoading = true,
bool isShowLoading = true
}) {
throw UnimplementedError(
'auth({required info, isShowLoading}) has not been implemented.');
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import androidx.annotation.NonNull;

import com.alipay.sdk.app.EnvUtils;
import com.alipay.sdk.app.AuthTask;
import com.alipay.sdk.app.PayTask;

Expand Down Expand Up @@ -88,14 +89,19 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
} else if ("pay".equals(call.method)) {
final String orderInfo = call.argument("orderInfo");
final boolean isShowLoading = call.argument("isShowLoading");
final boolean sandbox = call.argument("sandbox");
final WeakReference<Activity> activityRef = new WeakReference<>(activity);
final WeakReference<MethodChannel> channelRef = new WeakReference<>(channel);

//noinspection deprecation
new AsyncTask<String, String, Map<String, String>>() {
@Override
protected Map<String, String> doInBackground(String... params) {
final Activity activity = activityRef.get();
if (activity != null && !activity.isFinishing()) {
if(sandbox){
EnvUtils.setEnv(EnvUtils.EnvEnum.SANDBOX);
}
final PayTask task = new PayTask(activity);
return task.payV2(orderInfo, isShowLoading);
}
Expand Down