Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

最新版本0.2.3在IOS上无法触发支付(失败)回调 #1

Closed
fuxianwei opened this issue Nov 30, 2017 · 20 comments
Closed

最新版本0.2.3在IOS上无法触发支付(失败)回调 #1

fuxianwei opened this issue Nov 30, 2017 · 20 comments
Labels

Comments

@fuxianwei
Copy link

fuxianwei commented Nov 30, 2017

react-native-alipay 0.2.2版本是正常的

@fuxianwei fuxianwei changed the title 最新版本0.2.3在IOS上无法触发支付回调 最新版本0.2.3在IOS上无法触发支付(失败)回调 Nov 30, 2017
@0x5e
Copy link
Owner

0x5e commented Nov 30, 2017

0.2.3只是更新了支付宝iOS SDK,你测试使用的是正确的支付参数吗?我这边没有条件,用错误的支付参数测试,确实存在这问题

@fuxianwei
Copy link
Author

参数是可以的,我0.2.2上使用一切是正常的,你试试用0.2.3在IOS下跳转支付然后取消看看能否收到正确的取消提示,目前我这边(0.2.3)是收不到用户正确取消的信息,但是0.2.2版本一切正常

@fuxianwei
Copy link
Author

目前是IOS下面取消支付不能正确提示‘支付取消,请返回重新支付!’
这里是支付代码:
`
async pay() {
try {
let {cartInfo, orderType, resParams} = this.props.navigation.state.params
let res = null, payResult = null

        this.setState({
            requesting: true
        })

        if(this.state.payType == 0) {
            res = await api.aliPay(resParams)
        } else if(this.state.payType == 1) {
            res = await api.weixinPay(resParams)
        }

        this.setState({
            requesting: false
        })

        if (res && res.data.status == 1) {
            if (orderType == 2) {
                this.props.dispatch(ShopActions.cartRemoveShop(id))
            }

            if(this.state.payType == 0) {
                payResult = await Alipay.pay(res.data.data)

                if(payResult.resultStatus == 9000) {
                    this.props.navigation.dispatch({
                        type: 'ReplaceCurrentScreen',
                        routeName: "PayResult",
                        params: {res: 'ok', msg: `${cartInfo.totalPrice} 元`}
                    })
                } else if(payResult.resultStatus == 6001) {
                    this.props.navigation.navigate('PayResult', {res: 'fail', msg: '支付取消,请返回重新支付!'})
                } else {
                    this.props.navigation.navigate('PayResult', {res: 'fail', msg: '支付失败,请返回重新支付!'})
                }
            } else if(this.state.payType == 1) {
                let payParam = {
                    partnerId: res.data.data.partnerid,  // 商家向财付通申请的商家id
                    prepayId: res.data.data.prepayid,   // 预支付订单
                    nonceStr: res.data.data.noncestr,   // 随机串,防重发
                    timeStamp: res.data.data.timestamp.toString(),  // 时间戳,防重发
                    package: res.data.data.package,    // 商家根据财付通文档填写的数据和签名
                    sign: res.data.data.sign        // 商家根据微信开放平台文档对数据做的签名
                }

                payResult = await WeChat.pay(payParam)

                if(payResult.type == 'PayReq.Resp') {
                    if(payResult.errCode == 0) {
                        this.props.navigation.dispatch({
                            type: 'ReplaceCurrentScreen',
                            routeName: "PayResult",
                            params: {res: 'ok', msg: `${cartInfo.totalPrice} 元`}
                        })
                    }
                }
            }
        } else {
            Alert.alert(
                '提示',
                res.data.err_msg || '订单提交失败!',
                [
                    {
                        text: '确定', onPress: () => {
                    }, style: 'cancel'
                    }
                ],
                {cancelable: false}
            )
        }
    } catch (e) {
        this.setState({
            requesting: false
        })
        if(e.name == 'WechatError') {
            if(e.code == -1) {
                this.props.navigation.navigate('PayResult', {res: 'fail', msg: '支付失败,请返回重新支付!'})
            } else if(e.code == -2) {
                this.props.navigation.navigate('PayResult', {res: 'fail', msg: '支付取消,请返回重新支付!'})
            }
        }
    }
}

`

@0x5e 0x5e added the bug label Dec 6, 2017
@woshizhoujie
Copy link

退回了0.2.2版本。。。

@fuxianwei
Copy link
Author

目前只能回退版本了,等作者更新

@0x5e
Copy link
Owner

0x5e commented Dec 6, 2017

我用支付宝demo试下来的情况是 Alipay iOS SDK v15.5.0 的[AlipaySDK.defaultService payOrder:fromScheme:callback:]回调没有执行,而v15.4.1是正常的。。。先回退吧,我再确认下如果确实是这问题的话,等官方修复了😅

@fuxianwei
Copy link
Author

🙃哈哈只能这样了

@woshizhoujie
Copy link

image
求助

@0x5e
Copy link
Owner

0x5e commented Dec 14, 2017

@woshizhoujie 还有别的编译错误一起出现吗?试试删除node_modules/react-native/third-party目录重新编译一下,看下这个:facebook/react-native#14382

@django-wong
Copy link

+1

@dioxide
Copy link

dioxide commented Apr 26, 2018

sdk 升到15.5.3 实测支付回调还是不执行@0x5e

追加:
在 RCTAlipay.m 的 handleOpenURL 方法始终是执行的, 可以在这里调用resolve(),

@0x5e
Copy link
Owner

0x5e commented Apr 27, 2018

已经在develop分支更新了sdk并作了兼容,我电脑近期没有测试环境,几位方便的话帮忙测试一下 @dioxide @django-wong @fuxianwei ,谢谢了

@evianzhow
Copy link
Contributor

@0x5e Tested on Android and iOS latest Alipay App (10.1.22), and works fine. But you have to fix this issue first #9

@evianzhow
Copy link
Contributor

@0x5e Now that #9 is closed, I think it's time to release the new version.

@0x5e
Copy link
Owner

0x5e commented May 9, 2018

@evianzhow Sure, thanks😄

@0x5e 0x5e closed this as completed May 9, 2018
@Micjoyce
Copy link

在最新版的 0.2.4 上,ios网页跳转支付完成之后,还是不会触发回调。

@django-wong
Copy link

django-wong commented Aug 10, 2018

试了一下0.2.4的Alipay.pay()返回的Promise不会被Resolve, 我又downgrade到0.2.2了

react-native@0.54.4
react@16.3.2

@Icacls
Copy link

Icacls commented Jan 14, 2019

试了0.2.4和0.2.2 都不能正确触发回调 代码如下:

async alipayLogin() {
// 快捷登录授权
try {
let response = await Alipay.authWithInfo(this.state.infoStr);
console.info('alipayLogin------>', response);
let { resultStatus, result, memo } = response;
// let { success, result_code, auth_code, user_id } = QueryString.parse(result);

} catch (error) {
  console.error(error);
}
}

另外native端iOS openURL也没有触发。有人有遇到类似问题么

@0x5e
Copy link
Owner

0x5e commented Jan 15, 2019

@Icacls 请试一下develop分支看看(0.2.5)

@Icacls
Copy link

Icacls commented Jan 15, 2019

develop分支(0.2.5)测试OK 👌多谢了!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants