IAP错误代码?

时间:2018-03-17 17:18:36

标签: android google-play in-app-purchase ionic3 in-app-billing

我已将应用内购买(non_consumable)联系起来,并且我收到了“付款成功”,其中包含“您希望确认购买密码的频率”警告框。

然而,在成功之后,我收到了此错误消息。我收到这些消息是因为我在测试帐户中使用Alpha进行测试吗?似乎无法找到这两个错误的文档。

Store Error {"code": 6777017,"message":" Purchase Failed: Error Purchasing: labResult: Signature verification Failed for sku com.app.Jumphop.quiz (response:6777017: Error)"}

Store Error {"code":7,"message":" Purchase failed: Error Purchasing: labResult: Unable to buy item (response: 7:Error)"}

编辑:我正在使用此代码库https://github.com/thielCole/ionic-iap2 ....以下是IAP正在处理的代码......

export class AboutPage implements OnInit {

  public product: any = {
    name: 'My Product',
    appleProductId: '1234',
    googleProductId: 'com.38plank.spartan_one'
  };

  constructor(public navCtrl: NavController,
              private store: InAppPurchase2,
              public platform: Platform) {

  }

  ngOnInit() {
    this.configurePurchasing();
  }

  configurePurchasing() {
    if (!this.platform.is('cordova')) { return; }
    let productId;
    try {
      if (this.platform.is('ios')) {
        productId = this.product.appleProductId;
      } else if (this.platform.is('android')) {
        productId = this.product.googleProductId;
      }

      // Register Product
      // Set Debug High
      this.store.verbosity = this.store.DEBUG;
      // Register the product with the store
      this.store.register({
        id: productId,
        alias: productId,
        type: this.store.NON_RENEWING_SUBSCRIPTION
      });

      this.registerHandlers(productId);

      this.store.ready().then((status) => {
        console.log(JSON.stringify(this.store.get(productId)));
        console.log('Store is Ready: ' + JSON.stringify(status));
        console.log('Products: ' + JSON.stringify(this.store.products));
      });

      // Errors On The Specific Product
      this.store.when(productId).error( (error) => {
        alert('An Error Occured' + JSON.stringify(error));
      });
      // Refresh Always
      console.log('Refresh Store');
      this.store.refresh();
    } catch (err) {
      console.log('Error On Store Issues' + JSON.stringify(err));
    }
  }

  registerHandlers(productId) {
    // Handlers
    this.store.when(productId).approved( (product: IAPProduct) => {
      // Purchase was approved
      product.finish();
    });

    this.store.when(productId).registered( (product: IAPProduct) => {
      console.log('Registered: ' + JSON.stringify(product));
    });

    this.store.when(productId).updated( (product: IAPProduct) => {
      console.log('Loaded' + JSON.stringify(product));
    });

    this.store.when(productId).cancelled( (product) => {
      alert('Purchase was Cancelled');
    });

    // Overall Store Error
    this.store.error( (err) => {
      alert('Store Error ' + JSON.stringify(err));
    });
  }

  async purchase() {
    /* Only configuring purchase when you want to buy, because when you configure a purchase
    It prompts the user to input their apple id info on config which is annoying */
    if (!this.platform.is('cordova')) { return };

    let productId;

    if (this.platform.is('ios')) {
      productId = this.product.appleProductId;
    } else if (this.platform.is('android')) {
      productId = this.product.googleProductId;
    }

    console.log('Products: ' + JSON.stringify(this.store.products));
    console.log('Ordering From Store: ' + productId);
    try {
      let product = this.store.get(productId);
      console.log('Product Info: ' + JSON.stringify(product));
      let order = await this.store.order(productId);
      alert('Finished Purchase');
    } catch (err) {
      console.log('Error Ordering ' + JSON.stringify(err));
    }
  }

0 个答案:

没有答案
相关问题