react-native-make-payment icon indicating copy to clipboard operation
react-native-make-payment copied to clipboard

Expo plugin to enable `com.google.android.gms.wallet.api.enabled`

Open whatyoubendoing opened this issue 2 years ago • 1 comments

const { AndroidConfig, withAndroidManifest } = require("@expo/config-plugins");

const { addMetaDataItemToMainApplication, getMainApplicationOrThrow } =
  AndroidConfig.Manifest;

/**
 * Adds the following to AndroidManifest.xml:
 *
 * <application>
 *   ...
 *	 <meta-data
 *     android:name="com.google.android.gms.wallet.api.enabled"
 *     android:value="true|false" />
 * </application>
 */
function setGooglePayMetaData(modResults) {
  const GOOGLE_PAY_META_NAME = "com.google.android.gms.wallet.api.enabled";
  const mainApplication = getMainApplicationOrThrow(modResults);

  addMetaDataItemToMainApplication(
    mainApplication,
    GOOGLE_PAY_META_NAME,
    "true",
  );

  return modResults;
}

function withGooglePayAndroid(expoConfig) {
  return withAndroidManifest(expoConfig, (config) => {
    config.modResults = setGooglePayMetaData(config.modResults);
    return config;
  });
}

module.exports = function withGooglePay(config, props) {
  config = withGooglePayAndroid(config, props);
  return config;
};

whatyoubendoing avatar Jul 16 '23 13:07 whatyoubendoing

Thanks Ben, would you like to add this as a pull request? Happy to merge.

stephenmcd avatar Sep 27 '23 01:09 stephenmcd