xu-li / cordova-plugin-wechat

A cordova plugin, a JS version of Wechat SDK
1.22k stars 509 forks source link

wechat支付方法报 “发送请求失败” 错误! #586

Closed Zhliyun closed 3 years ago

Zhliyun commented 4 years ago

首先非常感谢解答我的问题~

我有个ionic项目,插件相关依赖如下: "@ionic-native/wechat": "^5.27.0", "cordova-plugin-wechat": "^3.0.0"

// wechat-pay.service.ts

import { Injectable } from '@angular/core';
import { Wechat } from '@ionic-native/wechat/ngx';

@Injectable({
  providedIn: 'root'
})
export class WechatPayService {

  constructor(private weChat: Wechat) { }

  pay(payParams) {
    const params = {
      partnerid: payParams.partnerid,
      prepayid: payParams.prepayid,
      noncestr: payParams.nonce_str,
      timestamp: payParams.timestamp,
      sign: payParams.sign
    };
    console.log('pay', params);
    this.weChat.sendPaymentRequest(params)
      .then(() => {
        console.log('pay Success');
      })
      .catch((error) => {
        console.log('pay', error);
      });
  }
}

在ios中调用sendPaymentRequest方法会得到“发送请求失败”的错误信息,请问是我哪里出了问题,谢谢~

pkwdzc commented 3 years ago

请问大兄弟解决了么。我用cordova开发ios时,也是卡在这一步了,发送请求失败,但是android没问题,能正常调起支付。android已经上线了,但是ios还在支付的坑里跳不出来

TianKong-0512 commented 3 years ago

请问,ios发送请求失败的问题解决了吗?

Zhliyun commented 3 years ago

“发送请求失败”原因是未正确配置Universal Link,需要检查插件安装时,填写的universalLink参数是否生效 不过现在遇到新的问题,wechat SDK自检时,会报如下错误:

+[WXApi genExtraUrlByReq:withAppData:]: unrecognized selector sent to class 0x1036a2628

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[WXApi genExtraUrlByReq:withAppData:]: unrecognized selector sent to class 0x1036a2628'

此问题依旧没解决

Zhliyun commented 3 years ago

+[WXApi genExtraUrlByReq:withAppData:]: unrecognized selector sent to class 0x1036a2628

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[WXApi genExtraUrlByReq:withAppData:]: unrecognized selector sent to class 0x1036a2628'

此问题已解决,由于使用 Capacitor 添加 Cordova 插件,会导致部分配置未写入,需要手动在 CordovaPlugins.podspec 文件中写入: s.static_framework = true 之后 pod install 即可

Riuhou commented 3 years ago

@Ayvods-Yun 你的Capacitor在使用微信登陆或者分享后会正确返回数据吗?我现在的症状是拿不到任何返回信息。onResp没有执行。

cxiaozhi commented 11 months ago

请问大兄弟解决了么。我用cordova开发ios时,也是卡在这一步了,发送请求失败,但是android没问题,能正常调起支付。android已经上线了,但是ios还在支付的坑里跳不出来

请问当初是怎么解决的啊

fyxtc commented 11 months ago

@Zhliyun 感谢你详细的记录问题和解决方案,真的帮了很多后来人,谢谢