实施Apple Pay时,在Ionic 2.x中出现错误

时间:2018-06-27 09:52:20

标签: angular ionic-framework ionic2 applepay

任何人都知道如何在ionic 2.x中实施申请工资

下面的

在我的浏览器中显示错误。请让我知道,错误在哪里感谢您。

错误:您可能需要适当的加载程序来处理此文件类型。 | this.applePay = applePay;

代码如下:

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { ApplePay } from '@ionic-native/apple-pay';
@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController,private applePay: ApplePay) {
    try {
      const applePayTransaction = await this.applePay.makePaymentRequest({
        items:'hello',
        shippingMethods:'',
        merchantIdentifier:'merchantIdentifier.com.example',
        currencyCode:'USD',
        countryCode:'1',
        billingAddressRequirement: ['name', 'email', 'phone'],
        shippingAddressRequirement: 'none',
        shippingType: 'shipping'
      });

      const transactionStatus = await completeTransactionWithMerchant(applePayTransaction);
      await this.applePay.completeLastTransaction(transactionStatus);
    } catch {
      // handle payment request error
      // Can also handle stop complete transaction but these should normally not occur
    }

    // only if you started listening before
    await this.applePay.stopListeningForShippingContactSelection();
  }
  async applePay() {
  // This block is optional -- only if you need to update order items/shipping
  // methods in response to shipping method selections
  this.applePay.startListeningForShippingContactSelection()
    .subscribe(async selection => {
      try {
        await this.applePay.updateItemsAndShippingMethods({
          items: getFromSelection(selection),
          shippingMethods: getFromSelection(selection),
        });
      }
      catch {
        // handle update items error
      }
    });


}

}

0 个答案:

没有答案