Необработанная ошибка TypeError: невозможно прочитать свойство create из undefined - PullRequest
0 голосов
/ 21 июня 2020

Я пытаюсь настроить функцию, чтобы перевернуть меня: ephemeralKeys

Ошибка, возвращаемая firestoreCloud

  Unhandled error TypeError: Cannot read property 'create' of undefined
        at exports.createEphemeralKey.functions.https.onCall (/srv/index.js:28:32)
        at func (/srv/node_modules/firebase-functions/lib/providers/https.js:272:32)
        at <anonymous>
        at process._tickDomainCallback (internal/process/next_tick.js:229:7) 

Мой оператор полосы

const stripe = require ('stripe') ('MySecretApi');

Моя функция CreateEphemeralKeys

exports.createEphemeralKey = functions.https.onCall((data, context) => __awaiter(this, void 0, void 0, function* () {
    const customerId = data.customer_id;
    const stripeVersion = data.stripe_version;
    console.log(stripeVersion);
    console.log(customerId);
    return stripe.ephemeralKeys({ customer: customerId }, { stripe_version: stripeVersion }).then((key) => {
        return key;
    }).catch((err) => {
        console.log(err);
        throw new functions.https.HttpsError('internal', ' Unable to create ephemeral key: ' + err);
    });
}));

"" Класс STPCustomerEphemeralKeyProvider ""

class _StripeApi: NSObject, STPCustomerEphemeralKeyProvider {
    
    func createCustomerKey(withAPIVersion apiVersion: String, completion: @escaping STPJSONResponseCompletionBlock) {
        
        let data = [
            "stripe_version": apiVersion,
            "customer_id" : UserService.user.stripeId
        ]
                
        Functions.functions().httpsCallable("createEphemeralKey").call(data) { (result, error) in
            
            if let error = error {
                debugPrint(error.localizedDescription)
                completion(nil, error)
                return
            }
            
            guard let key = result?.data as? [String: Any] else {
                completion(nil, nil)
                return
            }
            
            completion(key, nil)
        }
    }
}

1 Ответ

0 голосов
/ 22 июня 2020

stripe.ephemeralKeys не является функцией. Вы хотите stripe.ephemeralKeys.create. См. Документацию здесь: https://stripe.com/docs/mobile/ios/basic#ephemeral -key

...