From afa8dee9b68b6f8f7ed23e7a9a2bf909eb98e4c0 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Wed, 8 Jul 2020 10:21:49 +0800 Subject: [PATCH] feat: Add setAlipaySandbox props. --- README.md | 2 ++ index.d.ts | 5 +++++ index.js | 10 ++++++++++ 3 files changed, 17 insertions(+) diff --git a/README.md b/README.md index 77cae37..26a634f 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ import Alipay from 'react-native-uiwjs-alipay'; // 设置 支付宝 URL Schemes // scheme = `ap` + `APPID` Alipay.setAlipayScheme(scheme); +// 设置支付宝沙箱环境 +Alipay.setAlipaySandbox(isSandbox); // 支付宝 iOS 端的支付 // payInfo 是后台拼接好的支付参数 Alipay.alipay(payInfo, (res)=>console.log(res)) diff --git a/index.d.ts b/index.d.ts index cc2f7c7..f24a157 100644 --- a/index.d.ts +++ b/index.d.ts @@ -54,6 +54,11 @@ export const Alipay: { * @param scheme scheme = `ap` + `APPID` */ setAlipayScheme: (scheme: string) => void; + /** + * 设置支付宝沙箱环境,仅 Android + * @param isSandBox + */ + setAlipaySandbox: (isSandbox: boolean) => void; }; export default Alipay; \ No newline at end of file diff --git a/index.js b/index.js index 0fe2d6f..30e0ee3 100644 --- a/index.js +++ b/index.js @@ -20,4 +20,14 @@ export default class Alipay { NativeModules.Alipay.setAlipayScheme(scheme); } } + + /** + * 设置支付宝沙箱环境,仅 Android + * @param isSandBox + */ + static setAlipaySandbox(isSandbox) { + if (Platform.OS === 'android') { + NativeModules.Alipay.setAlipaySandbox(isSandBox); + } + } }