React Native Stripe Firebase-测试令牌正常运行,但测试卡未定义

问题描述

我正在尝试通过Firebase云功能将费用发送给条带化,当我发送测试令牌(例如“ tok_mastercard”)时,一切正常。一旦我替换了Tipsi Stripe Firebase创建的令牌,我将显示所有未定义发送的信息。我已经在控制台中将控制台的令牌记录在云功能中,并且一切正常。

我觉得我缺少明显的东西。预先感谢您的帮助。

防火墙云功能

g

控制台记录的令牌

unkNown

使用TIPSI条纹生成代币

const functions = require("firebase-functions");
const stripe = require("stripe")(MY SECRET KEY);

exports.payWithStripe = functions.https.onRequest(async (request,response) => {
  stripe.charges
    .create({
      amount: request.body.amount,currency: request.body.currency,source: request.body.token,})
    .then((charge) => response.send(charge))
    .catch((err) => {
      console.log(err);
    });
});

退出结帐

{"card": {"addressCity": "Macon","addressCountry": "Estonia","addressLine1": "Canary Place","addressLine2": "3","addressstate": "","addressZip": "31217","brand": "Visa","cardId": "card_1HdFN7C7qEwniOSJWxN2Tbs6","country": "US","expMonth": 1,"expYear": 2022,"funding": "credit","isApplePayCard": false,"last4": "4242","name": "Enappd Store"},"created": 1602940977,"livemode": false,"tokenId": "tok_1HdFN7C7qEwniOSJc1nUQcqH"}

防火墙日志


  stripe.setoptions({
    publishableKey:"MY TEST KEY",});

  const [token,setToken] = useState(null);


  const handleCardPayPress = async () => {
    try {
      setLoading(true);
      setToken(null);
      const token = await stripe.paymentRequestWithCardForm({
        smsAutofilldisabled: true,requiredBillingAddressFields: "full",prefilledinformation: {
          billingAddress: {
            name: "Enappd Store",line1: "Canary Place",line2: "3",city: "Macon",state: "",country: "Estonia",postalCode: "31217",email: "admin@enappd.com",},});
      setToken(token);
      console.log(token);
      setLoading(false);
      Alert.alert("Your card information has been entered!");
    } catch (error) {
      console.log(error);
      setLoading(false);
    }
  };

解决方法

解决方案是更改:

setToken(token)

setToken(token.tokenId)