diff --git a/packages/taro-h5/src/api/alipay/index.ts b/packages/taro-h5/src/api/alipay/index.ts index fd2c68e63f30..9d5c885279e5 100644 --- a/packages/taro-h5/src/api/alipay/index.ts +++ b/packages/taro-h5/src/api/alipay/index.ts @@ -2,3 +2,4 @@ import { temporarilyNotSupport } from '../../utils' // AliPay export const getOpenUserInfo = /* @__PURE__ */ temporarilyNotSupport('getOpenUserInfo') +export const tradePay = /* @__PURE__ */ temporarilyNotSupport('tradePay') diff --git a/packages/taro-h5/src/api/media/video/chooseMedia.ts b/packages/taro-h5/src/api/media/video/chooseMedia.ts index 21d16c440b4b..f7ed8aef575c 100644 --- a/packages/taro-h5/src/api/media/video/chooseMedia.ts +++ b/packages/taro-h5/src/api/media/video/chooseMedia.ts @@ -71,7 +71,7 @@ export const chooseMedia = async function ( const { tapIndex } = await showActionSheet({ itemList: ['拍摄', '从相册选择'], }, methodName) - sourceType.splice(0, 1, tapIndex === 0 ? 'camera' : 'album') + sourceType.splice(0, sourceType.length, tapIndex === 0 ? 'camera' : 'album') } catch (e) { return handle.fail({ errMsg: e.errMsg?.replace('^.*:fail ', '') diff --git a/packages/taro/types/api/alipay/index.d.ts b/packages/taro/types/api/alipay/index.d.ts index 1c96f8e98b99..bbbf682fc75f 100644 --- a/packages/taro/types/api/alipay/index.d.ts +++ b/packages/taro/types/api/alipay/index.d.ts @@ -15,6 +15,42 @@ declare module '../../index' { response: string } } + namespace tradePay { + interface Option { + /** 接入小程序支付时传入此参数。此参数为支付宝交易号,注意参数有大小写区分(调用 小程序支付 时必填) */ + tradeNO?: string + /** 完整的支付参数拼接成的字符串,从服务端获取(调用 支付宝预授权 时必填) */ + orderStr?: string + /** 接口调用成功的回调函数 */ + success?: (res: SuccessCallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?:(res: TaroGeneral.CallbackResult) => void + } + interface ResultCode { + /** 无权限调用(N22104) */ + 4 + /** 订单处理成功 */ + 9000 + /** 正在处理中。支付结果未知(有可能已经支付成功) */ + 8000 + /** 订单处理失败 */ + 4000 + /** 用户中途取消 */ + 6001 + /** 网络连接出错 */ + 6002 + /** 处理结果未知(有可能已经成功) */ + 6004 + } + interface SuccessCallbackResult { + /** success 回调函数会携带一个 Object 类型的对象,其属性如下: */ + response: { + resultCode: ResultCode + } + } + } interface TaroStatic { /** * 此接口可获取支付宝会员的基础信息(头像图片地址、昵称、性别、国家码、省份、所在市区),接入方法请参考 获取会员基础信息介绍。如需获取支付宝会员标识(user_id),请调用 my.getAuthCode 和 alipay.system.oauth.token 接口。 @@ -22,5 +58,12 @@ declare module '../../index' { * @see https://docs.alipay.com/mini/api/ch8chh */ getOpenUserInfo(Option: getOpenUserInfo.Option): Promise + + /** + * 此接口是用于发起支付的 API,此 API 暂仅支持企业支付宝小程序使用 + * @supported alipay + * @see https://opendocs.alipay.com/mini/api/openapi-pay + */ + tradePay(Option: tradePay.Option): Promise } }