@@ -51,6 +51,9 @@ export default class TobiasPlugin implements FlutterPlugin, MethodCallHandler, A
5151 case "pay":
5252 this.pay(call, result);
5353 break;
54+ case "payOhosAutoSub":
55+ this.payOhosAutoSub(call, result);
56+ break;
5457 case "auth":
5558 result.notImplemented();
5659 break;
@@ -73,44 +76,42 @@ export default class TobiasPlugin implements FlutterPlugin, MethodCallHandler, A
7376
7477 pay(call: MethodCall, result: MethodResult): void {
7578 const order: string = call.argument("order");
76- const isOhosAutoSub: boolean = call.argument("isOhosAutoSub");
77- if(isOhosAutoSub){
78- console.log(TAG, '当前为自动订阅');
79- let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
80- let openLinkOptions: OpenLinkOptions = {
81- appLinkingOnly: false
82- };
83- const resp: Map<string, string> = new Map();
84- try {
85- context.openLink(order, openLinkOptions)
86- .then(() => {
87- console.log(TAG, 'open link success.');
88- resp.set("resultStatus", "success");
89- result.success(resp)
90- }).catch((err: BusinessError) => {
91- console.log(TAG, `open link failed. Code is ${err.code}, message is ${err.message}`);
92- resp.set("resultStatus", "erroe");
79+ const isShowLoading: boolean = true;
80+ const payment = new alipay.Pay();
81+ payment.pay(order, isShowLoading)
82+ .then((res: Map<string, string>) => {
83+ result.success(res);
84+ })
85+ .catch((_: BusinessError) => {
86+ const resp: Map<string, string> = new Map();
87+ resp.set("resultStatus", "-1");
88+ result.success(resp);
89+ });
90+ }
91+
92+ payOhosAutoSub(call: MethodCall, result: MethodResult): void {
93+ const order: string = call.argument("order");
94+ let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
95+ let openLinkOptions: OpenLinkOptions = {
96+ appLinkingOnly: false
97+ };
98+ const resp: Map<string, string> = new Map();
99+ try {
100+ context.openLink(order, openLinkOptions)
101+ .then(() => {
102+ console.log(TAG, 'open link success.');
103+ resp.set("resultStatus", "success");
93104 result.success(resp)
94- })
95- } catch (paramError) {
96- console.log(TAG, `Failed to start link. Code is ${paramError.code}, message is ${paramError.message}`);
105+ }).catch((err: BusinessError) => {
106+ console.log(TAG, `open link failed. Code is ${err.code}, message is ${err.message}`);
97107 resp.set("resultStatus", "erroe");
98108 result.success(resp)
99- }
100- } else {
101- console.log(TAG, '当前为非自动订阅');
102- const isShowLoading: boolean = true;
103- const payment = new alipay.Pay();
104- payment.pay(order, isShowLoading)
105- .then((res: Map<string, string>) => {
106- result.success(res);
107- })
108- .catch((_: BusinessError) => {
109- const resp: Map<string, string> = new Map();
110- resp.set("resultStatus", "-1");
111- result.success(resp);
112- });
113- }
109+ })
110+ } catch (paramError) {
111+ console.log(TAG, `Failed to start link. Code is ${paramError.code}, message is ${paramError.message}`);
112+ resp.set("resultStatus", "erroe");
113+ result.success(resp)
114+ }
114115 }
115116
116117 isAliPayInstalled(result: MethodResult): void {
0 commit comments