首页 > 解决方案 > 在cordova项目中集成了cordova-plugin-applepay,但付款没有成功,使用了cordova的相同代码

问题描述

在 Cordova 项目中实施 ApplePay 时遇到问题。安装插件“cordova-plugin-applepay”并按照相同的说明进行测试付款在模拟器上运行时付款失败并收到“'我的时装公司'无法完成付款。请重试”

使用以下插件:https ://www.npmjs.com/package/cordova-plugin-applepay并按照此插件网站中的说明更改配置,然后使用示例代码(在上述网站上)进行测试付款。

我已经在苹果开发者和证书配置上创建了商家 ID。

我实施了以下代码以使用 Apple Pay 付款:

ApplePay.makePaymentRequest(
{
  items: [
      {
          label: '3 x Basket Items',
          amount: 49.99
      },
      {
          label: 'Next Day Delivery',
          amount: 3.99
      },
              {
          label: 'My Fashion Company',
          amount: 53.98
      }
  ],
  shippingMethods: [
      {
          identifier: 'NextDay',
          label: 'NextDay',
          detail: 'Arrives tomorrow by 5pm.',
          amount: 3.99
      },
      {
          identifier: 'Standard',
          label: 'Standard',
          detail: 'Arrive by Friday.',
          amount: 4.99
      },
      {
          identifier: 'SaturdayDelivery',
          label: 'Saturday',
          detail: 'Arrive by 5pm this Saturday.',
          amount: 6.99
      }
  ],
  supportedNetworks: ['visa', 'masterCard', 'discover'],
  merchantCapabilities: ['3ds', 'debit', 'credit'],          
  merchantIdentifier: 'using my merchant Id',
  currencyCode: 'GBP',
  countryCode: 'GB',
  billingAddressRequirement: 'none',
  shippingAddressRequirement: 'none',
  shippingType: 'shipping'
}).then((paymentResponse) => {
  // The user has authorized the payment.

  // Handle the token, asynchronously, i.e. pass to your merchant bank to
  // action the payment, then once finished, depending on the outcome:

  // Here is an example implementation:

  // MyPaymentProvider.authorizeApplePayToken(token.paymentData)
  //    .then((captureStatus) => {
  //        // Displays the 'done' green tick and closes the sheet.
  //        ApplePay.completeLastTransaction('success');
  //    })
  //    .catch((err) => {
  //        // Displays the 'failed' red cross.
  //        ApplePay.completeLastTransaction('failure');
  //    });
}).catch((e) => {
  // Failed to open the Apple Pay sheet, or the user cancelled the payment.`enter code here`
})

付款后,它应该完成付款。我在这里错过了什么吗?

标签: cordovaapplepayintegrate

解决方案


推荐阅读