Undefined Payments.initialize

I use this code:

import { DangerZone } from 'expo';
const { Payments } = DangerZone;
Payments.initialize({ publishableKey: 'pk_live_xxxxx' })

and expo 21.

with android, the Payments api is supposed to still be there with expo 21 but I am getting the following error:

[exp] We temporarily removed the Expo Payments API. Please see the SDK 20 release notes for more information: https://blog.expo.io/expo-sdk-v20-0-0-is-now-available-79f84232a9d1
[exp] Possible Unhandled Promise Rejection (id: 0):
[exp] TypeError: undefined is not a function (evaluating 'Payments.paymentRequestWithCardFormAsync(options)')
    const options = {
      smsAutofillDisabled: true,
      requiredBillingAddressFields: 'full',
      prefilledInformation: {
        billingAddress: {
          name: 'Gunilla Haugeh',
          line1: 'Canary Place',
          line2: '3',
          city: 'Macon',
          state: 'Georgia',
          country: 'US',
          postalCode: '31217',
        },
      },
    }
    const token = await Payments.paymentRequestWithCardFormAsync(options)

any idea why?

Are you sure you’re attempting to do this on Android? I don’t see any way to get that error message outside of iOS.

yes I am testing on Android using the XDE client @thetc

What exp command did you run and what does Expo.Constants.platform say?

I am using exp start.

and here is my Constants:

[exp] Object {
[exp]   "appOwnership": "expo",
[exp]   "deviceId": "047bf5b4-f021-4f2b-ac00-7486bd04c319",
[exp]   "deviceName": "LG-H870",
[exp]   "deviceYearClass": 2014,
[exp]   "experienceUrl": "exp://2n-acr.herve76.mobile-app.exp.direct:80",
[exp]   "expoVersion": "1.20.0",
[exp]   "getWebViewUserAgentAsync": [Function fn],
[exp]   "intentUri": "exp://2n-acr.herve76.mobile-app.exp.direct:80",
[exp]   "isDevice": true,
[exp]   "linkingUri": "exp://2n-acr.herve76.mobile-app.exp.direct:80/+",
[exp]   "manifest": Object {
[exp]     "android": Object {
[exp]       "config": Object {
[exp]         "googleMaps": Object {
[exp]           "apiKey": "AIzaSyAgFjSKPvJ-YjqpN-uSdyQYFzaJSTWhmSA",
[exp]         },
[exp]         "googleSignIn": Object {
[exp]           "apiKey": "AIzaSyCVG4-ws9BUk9mOtXYRyUaF2pzIpEjtFFw",
[exp]           "certificateHash": "545519706776-dl99l7vt050kkqv1f0bfg7be53rnpd2b.apps.googleusercontent.com",
[exp]         },
[exp]       },
[exp]       "package": "trade.offmarket.app",
[exp]       "permissions": Array [
[exp]         "ACCESS_FINE_LOCATION",
[exp]       ],
[exp]       "versionCode": 1,
[exp]     },
[exp]     "bundleUrl": "http://packager.2n-acr.herve76.mobile-app.exp.direct:80/node_modules/expo/AppEntry.bundle?platform=android&dev=true&strict=false&minify=false&hot=false&assetPlugin=exp
o/tools/hashAssetFiles",
[exp]     "debuggerHost": "packager.2n-acr.herve76.mobile-app.exp.direct:80",
[exp]     "description": "Real time networking for commercial real estate professionals.",
[exp]     "developer": Object {
[exp]       "tool": "exp",
[exp]     },
[exp]     "env": Object {},
[exp]     "icon": "./assets/images/app_icon.png",
[exp]     "iconUrl": "http://packager.2n-acr.herve76.mobile-app.exp.direct:80/assets/./assets/images/app_icon.png",
[exp]     "id": "@herve76/offmarket",
[exp]     "ios": Object {
[exp]       "buildNumber": "40",
[exp]       "bundleIdentifier": "trade.offmarket",
[exp]       "config": Object {
[exp]         "googleSignIn": Object {
[exp]           "reservedClientId": "com.googleusercontent.apps.545519706776-58ujchtijhev4kms634le5enem6cpk36",
[exp]         },
[exp]         "usesNonExemptEncryption": false,
[exp]       },
[exp]       "icon": "./assets/images/app_icon.png",
[exp]       "iconUrl": "http://packager.2n-acr.herve76.mobile-app.exp.direct:80/assets/./assets/images/app_icon.png",
[exp]       "infoPlist": Object {},
[exp]       "supportsTablet": false,
[exp]     },
[exp]     "isVerified": true,
[exp]     "loading": Object {
[exp]       "hideExponentText": true,
[exp]       "icon": "./assets/images/app_icon.png",
[exp]       "iconUrl": "http://packager.2n-acr.herve76.mobile-app.exp.direct:80/assets/./assets/images/app_icon.png",
[exp]     },
[exp]     "logUrl": "http://2n-acr.herve76.mobile-app.exp.direct:80/logs",
[exp]     "mainModuleName": "node_modules/expo/AppEntry",
[exp]     "name": "OffMarket",
[exp]     "notification": Object {
[exp]       "color": "#000000",
[exp]       "icon": "./assets/images/app_icon.png",
[exp]       "iconUrl": "http://packager.2n-acr.herve76.mobile-app.exp.direct:80/assets/./assets/images/app_icon.png",
[exp]     },
[exp]     "orientation": "default",
[exp]     "packagerOpts": Object {
[exp]       "dev": true,
[exp]       "hostType": "tunnel",
[exp]       "lanType": "ip",
[exp]       "minify": false,
[exp]       "strict": false,
[exp]       "urlRandomness": "2n-acr",
[exp]       "urlType": "exp",
[exp]     },
[exp]     "primaryColor": "#cccccc",
[exp]     "privacy": "unlisted",
[exp]     "sdkVersion": "20.0.0",
[exp]     "slug": "offmarket",
[exp]     "version": "0.1.19",
[exp]     "xde": true,
[exp]   },
[exp]   "sessionId": "c592201f-15f0-4a05-8dbd-c8596a570183",
[exp]   "statusBarHeight": 24,
[exp]   "systemFonts": Array [
[exp]     "normal",
[exp]     "notoserif",
[exp]     "sans-serif",
[exp]     "sans-serif-light",
[exp]     "sans-serif-thin",
[exp]     "sans-serif-condensed",
[exp]     "sans-serif-medium",
[exp]     "serif",
[exp]     "Roboto",
[exp]     "monospace",
[exp]   ],
[exp]   "systemVersion": "7.0",
[exp] }

Expo.Constants.platform is undefined. @thetc

Oh, I’m sorry. Platform.OS and NativeModules.TPSStripeManager from react-native?

Platform.OS = android

NativeModules = Object {}

@thetc

Were you able to solve the undefined Payments.initialize issues?

I am just getting started with payments

Stripe is working ok with android but not with iOS

weird issue, i gave up in the end and configured tipsi-stripe directly.

Same problem here. On IOS Payments is Undefined. I used the exact same code as specified in the documentation.

hey, have you guys detached to ExpoKit and added the payments module into your projects?

Payments work without detaching for android, but on iOS the payments module was removed (hence the undefined error) from expo because some apps that weren’t offering anything for sale were getting rejected from the app store.

As a result, until an alternate solution is released you’ll have to Detach and manually include the payments module if you want payment functionality on iOS.

I have detached, followed the instructions as written (added Payments to podfile and did pod install. No errors in Xcode, however when attempting to use the payments module I as well receive the error: ‘undefined is not an object (evaluating ‘Payments.initiatlize’)’

1 Like