uni-app 苹果支付发生未知错误 No auth plugin to verify credentials for accounts of type

uni-app 苹果支付发生未知错误 No auth plugin to verify credentials for accounts of type

信息类别 详情
产品分类 uniapp/App
PC开发环境操作系统 Mac
PC开发环境操作系统版本号 macOS 14
HBuilderX类型 正式
HBuilderX版本号 4.41
手机系统 iOS
手机系统版本号 iOS 18
手机厂商 模拟器
手机机型 iPad Air 5
页面类型 vue
vue版本 vue2
打包方式 云端
项目创建方式 HBuilderX

示例代码:

// 请求苹果支付
const transaction = await this._iap.requestPayment({
productid: this.applePayInfo.productId,
manualFinishTransaction: false, //手动关闭订单,值为 false 时支付完成后自动关闭订单,true时不关闭订单,需要在合适的时机调用 finishTransaction 关闭订单。建议设置为 true, 默认值为 false 是为了向下兼容
username: orderno //username + orderId //根据业务需求透传参数,关联用户和订单关系
});

操作步骤:

调用苹果支付

预期结果:

返回支付结果

实际结果:

支付失败 错误如上

bug描述:

i不是所有的苹果设备会出现,目前在iPad Air 5上支付不成功, { “errMsg”: "requestPayment:fail Payment_appleiap:Error Domain=SKErrorDomain Code=0 “发生未知错误” UserInfo={NSLocalizedDescription=发生未知错误, NSUnderlyingError=0x600002528360 {Error Domain=ASDErrorDomain Code=500 “Unhandled exception” UserInfo={NSMultipleUnderlyingErrorsKey=( “Error Domain=AMSErrorDomain Code=2 “发生未知错误。请再尝试一次。” UserInfo={NSLocalizedDescription=发生未知错误。请再尝试一次。}” “Error Domain=com.apple.accounts Code=4 “No auth plugin to verify credentials for accounts of type com.apple.account.iTunesStore.sandbox” UserInfo={NSLocalizedDescription=No auth plugin to verify credentials for accounts of type com.apple.account.iTunesStore.sandbox}” ), NSLocalizedDescription=Unhandled exception, NSLocalizedFailureReason=An unknown error occurred}}}


更多关于uni-app 苹果支付发生未知错误 No auth plugin to verify credentials for accounts of type的实战教程也可以访问 https://www.itying.com/category-93-b0.html

1 回复

更多关于uni-app 苹果支付发生未知错误 No auth plugin to verify credentials for accounts of type的实战教程也可以访问 https://www.itying.com/category-93-b0.html


在处理 uni-app 中集成苹果支付(Apple Pay)时遇到“No auth plugin to verify credentials for accounts of type”这类错误,通常意味着在支付流程中有一些配置或实现上的缺失,尤其是在验证账户凭证方面。由于这是一个比较特定的错误,解决它通常涉及到确保所有相关的配置和代码实现都是正确的。

以下是一个简化的 uni-app 集成苹果支付的代码示例,以及可能帮助你定位和解决问题的方向。请注意,实际实现可能需要根据你的具体业务逻辑进行调整。

uni-app 集成苹果支付示例代码

首先,确保你的项目中已经包含了必要的支付库和配置。在 uni-app 中,你可能会使用类似 uni-pay 的插件来处理支付流程,但苹果支付的具体实现需要依赖原生代码。

1. 在原生插件中配置 Apple Pay

在你的原生插件(iOS 部分)中,你需要配置 Apple Pay。这通常涉及到在 AppDelegate.m 或相应的原生文件中添加代码来注册和配置 Apple Pay。

#import <PassKit/PassKit.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // ... 其他初始化代码
    
    PKPaymentButton *paymentButton = [PKPaymentButton buttonWithType:PKPaymentButtonTypeBuy style:PKPaymentButtonStyleBlackWhite];
    [paymentButton addTarget:self action:@selector(handlePayment:) forControlEvents:UIControlEventTouchUpInside];
    [self.window.rootViewController.view addSubview:paymentButton];
    
    return YES;
}

- (void)handlePayment:(PKPaymentButton *)sender {
    // 创建 PKPaymentRequest 并处理支付请求
    PKPaymentRequest *request = [[PKPaymentRequest alloc] init];
    request.merchantIdentifier = @"your-merchant-identifier"; // 确保已在 Apple Developer 账户中配置
    request.supportedNetworks = @[@"visa", @"masterCard", @"amex"];
    request.merchantCapabilities = PKMerchantCapability3DS;
    
    // 添加支付摘要等信息
    PKPaymentSummaryItem *summaryItem = [PKPaymentSummaryItem summaryItemWithLabel:@"Label" amount:[NSDecimalNumber decimalNumberWithString:@"10.00"]];
    request.paymentSummaryItems = @[summaryItem];
    
    [PKPaymentAuthorizationController presentAuthorizationController:[[PKPaymentAuthorizationController alloc] initWithPaymentRequest:request] delegate:self];
}

2. 在 uni-app 中调用原生支付功能

在 uni-app 的 JavaScript 代码中,你可能需要通过 JSBridge 调用原生支付功能。这部分代码依赖于你如何封装原生插件的接口。

// 假设你有一个封装好的支付插件
uni.requestPayment({
    timeStamp: '', // 时间戳
    nonceStr: '', // 随机字符串
    package: '', // 统一下单接口返回的 prepay_id 参数值
    signType: 'MD5', // 签名方式
    paySign: '', // 签名
    success: function (res) {
        console.log('支付成功', res);
    },
    fail: function (err) {
        console.error('支付失败', err);
    }
});

注意:上述代码仅为示例,并未完整展示所有步骤和细节。特别是关于如何正确配置 Apple Pay 和处理支付回调,需要根据 Apple 的官方文档和你的具体业务需求进行深入实现。

回到顶部