反应原生 IAP:订阅总是返回状态:21002 a

Posted

技术标签:

【中文标题】反应原生 IAP:订阅总是返回状态:21002 a【英文标题】:react native IAP : Subscription always return status: 21002 a 【发布时间】:2021-05-07 10:08:39 【问题描述】:

我正在处理身份验证可更新订阅。但是每次我进行收据验证时,它都会给我错误 21002

      const validateiosReceipt = async (receipt) => 
    const isTestEnvironment = __DEV__;

    const receiptBody = 
      'receipt-data': receipt,
      password: DataConfig.IAP_SHARED_SECRET
    ;
    console.log('receiptBody data',receiptBody)
    try 
      const validatedReceipt = await validateReceiptIos(
        receiptBody,
        isTestEnvironment,
      );
        console.log('receiptBody responce',validatedReceipt)
      return validatedReceipt;
     catch (error) 
      console.log(error);

      return ;
    
  ;



receipt-data: "MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgkqhkiG9w0BBwGggCSABIIBaDGCAWQwDwIBAAIBAQQHDAVYY29kZTALAgEBAgEBBAMCAQAwFQIBAgIBAQQNDAtjb20ubXRwLmFwcDANAgEDAgEBBAUMAzEuMDAQAgEEAgEBBAh4/vv/BwAAADAcAgEFAgEBBBS4diJApX5mLeCKV1vbdIl4IfQ7tTAKAgEIAgEBBAIWADAiAgEMAgEBBBoWGDIwMjEtMDUtMDdUMTA6MDg6NDArMDUzMDCBmQIBEQIBAQSBkDGBjTAMAgIGpQIBAQQDAgEBMB8CAgamAgEBBBYMFGNvbS5tdHAuYXBwLnRlYW1wYXNzMAwCAganAgEBBAMMATAwHwICBqgCAQEEFhYUMjAyMS0wNS0wNlQyMTo1OTowMVowHwICBqwCAQEEFhYUMjAyMi0wNS0wNlQyMTo1OTowMVowDAICBrcCAQEEAwIBADAiAgEVAgEBBBoWGDQwMDEtMDEtMDFUMDU6MzA6MDArMDUzMAAAAAAAAKCCA3gwggN0MIICXKADAgECAgEBMA0GCSqGSIb3DQEBCwUAMF8xETAPBgNVBAMMCFN0b3JlS2l0MREwDwYDVQQKDAhTdG9yZUtpdDERMA8GA1UECwwIU3R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MIIBiwIBATBkMF8xETAPBgNVBAMMCFN0b3JlS2l0MREwDwYDVQQKDAhTdG9yZUtpdDERMA8GA1UECwwIU3RvcmVLaXQxCzAJBgNVBAYTAlVTMRcwFQYJKoZIhvcNAQkBFghTdG9yZUtpdAIBATANBglghkgBZQMEAgEFADANBgkqhkiG9w0BAQsFAASCAQCt9IrmodXgzpjw4hnJUNXBYNf2V7g+X85J4fPvfUiNZeLZA+9n5vpVwnfLfdikUHiwxbXdCEPOaUDhIHIuwiOqnBtEKgILkf+0k6qQb30BkHXy/DBPomYim2xJ/zEU2zSkcgjCwbzcoAd7KukNP583AhIy8n0qpsIumGkWLrvtTnfjEbdhan+cb9c3oXfQ7oxJJjKiASFU3Lml5TeSBLOUzi7Z6NbvqKn9+g4hoeqO1DL267aI4rUo9lO2FR9oti2qvwglfTjwjFwG7SxGeUlNcnX07C5yCejlrRo+TfjIkio3D+fgwRDVwPrYUm9wRJ8lZnVSkgYf2K48d4/wA2QWAAAAAAAA", 'password': "a56a9*****9b4bf5d1a6ddc9591a2"

【问题讨论】:

【参考方案1】:

您的收据数据似乎没有正确到达 Apple 端:

21002 收据数据属性中的数据格式错误或服务遇到临时问题。再试一次。

所有代码见here

【讨论】:

我从 24 小时就开始尝试.. 我该怎么办 很难根据您当前的代码剪断来判断。 validateReceiptIos 是做什么的? 首先,我会通过使用无尽的 API 测试工具或 cURL 发送收据数据来确保收据数据是正确的。如果收据数据是正确的,我会在我的代码没有做它应该做的地方进行逆向工程。 validateReceiptIos 是 react-native-iap 方法 对应这个问题github.com/dooboolab/react-native-iap/issues/1127 react-native 实现不适用于调试版本。它似乎只适用于 TestFlight 或生产版本

以上是关于反应原生 IAP:订阅总是返回状态:21002 a的主要内容,如果未能解决你的问题,请参考以下文章

反应原生返回 null 状态

使用上下文和钩子更新未安装组件的状态 - 反应原生

IAP-可以获取免费订阅产品,但不能获取付费产品

如何将新的键:值对添加到已经存在的数组状态变量反应原生

渲染后调用的函数反应原生

this.setState 不是函数,反应原生