2

我正在尝试使用 Phonegap 构建的 Apple Pay cordova 插件。这是我在配置文件中的条目:

     <plugin name="cordova-plugin-applepay-stripe" source="npm">
<param name="STRIPE_TEST_PUBLISHABLE_KEY" value="xxxxxxxx" />
<param name="STRIPE_LIVE_PUBLISHABLE_KEY" value="xxxxxxxxx" />
<param name="APPLE_MERCHANT_IDENTIFIER" value="merchant.etc.etc" />
</plugin>

该插件安装正确,但它不起作用,因为我没有在 Xcode 中启用 Apply Pay 权利,因为我使用的是 PC。

我知道您可以直接从 phonegap build config.xml 文件中编辑 plist 文件,就像我在这里所做的那样:

<gap:config-file platform="ios" parent="NSPhotoLibraryUsageDescription" overwrite="true">
<string>We are using the Photo Library for PayPal</string>...

所以我的问题是我到底如何编辑 Entitlements.plist 文件以便我可以启用 ApplePay 并添加我的商家 ID?!

我尝试了以下方法:

  <config-file platform="ios" target="*-Entitlements.plist" parent="com.apple.developer.in-app-payments">  
        <array>
            <string>merchant.etc.etc/string>
        </array>
</config-file>  

但这没有奏效。任何帮助,将不胜感激!

4

1 回答 1

7

由于某种原因,它似乎config-file只适用于插件。看起来它应该在你的项目中工作config.xml,但不幸的是它没有。但是,您可以使用本地插件来管理您的权利,以达到或多或少相同的效果。

例如,src/local-plugins/app-entitlements

将此添加到您的config.xml

<plugin name="app-entitlements" spec="src/local-plugins/app-entitlements" />

你只需要这个src/local-plugins/app-entitlements/plugin.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<plugin id="app-entitlements" version="0.0.0" xmlns="http://apache.org/cordova/ns/plugins/1.0">
  <name>AppEntitlements</name>
  <platform name="ios">
    <config-file target="*-Debug.plist" parent="com.apple.developer.in-app-payments">
      <array>
        <string>YOUR DEBUG MERCHANT ID HERE</string>
      </array>
    </config-file>
    <config-file target="*-Release.plist" parent="com.apple.developer.in-app-payments">
      <array>
        <string>YOUR RELEASE MERCHANT ID HERE</string>
      </array>
    </config-file>
  </platform>
</plugin>

当然,您可以在此处设置其他权利,例如推送通知或您想要的任何内容。

现在,当你做一个新的cordova platform add ios,它应该Entitlements-*.plist用这些键创建,你应该很高兴。

请记住,Xcode 中的“功能”选项卡是单独处理的,只是一个 GUI 助手。它不会反映这些文件的权利。

于 2017-09-22T19:57:21.767 回答