首页 > 解决方案 > Tipsi-Stripe:无法从令牌创建源

问题描述

完全不知道这里可能是什么问题,我不知道这个错误意味着什么。尝试从我的令牌创建源时,出现此错误:

Unhandled Promise Rejection (id: 40):

Error: The payment method `card` requires the parameter: card[number].
Error: The payment method `card` requires the parameter: card[number].
    at Object.promiseMethodWrapper [as createSourceWithParams] (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2275:36)
    at Stripe.createSourceWithParams (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:190106:29)
    at payWithCard$ (http://localhost:8081/src/CheckoutForm.bundle?platform=ios&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true:383:72)
    at tryCatch (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:28564:19)
    at Generator.invoke [as _invoke] (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:28740:24)
    at Generator.prototype.<computed> [as next] (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:28607:23)
    at tryCatch (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:28564:19)
    at invoke (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:28640:22)
    at http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:28650:15
    at tryCallOne (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:3475:14)

这是我的代码。我已经尝试过任何组合,但我不确定 card[number] 是什么意思。我的令牌绝对有效,并且我在每个文档中传递了正确的值:https ://tipsi.github.io/tipsi-stripe/docs/createsourcewithparamsparams.html

 const options = {
      requiredBillingAddressFields: 'full',
      theme: {
        primaryBackgroundColor: '#f1f1f1',
      },
    };

    const token = await stripe.paymentRequestWithCardForm(options);
    const params = {
      type: 'card',
      amount: 50,
      // currency: 'USD',
      // returnURL: 'example://stripe-redirect',
      card: token.card.cardId,
      // card: token.card,
      // card123: token.card.cardId,
      token: token.tokenId,
    };

    console.log(token);
    const source = await stripe.createSourceWithParams(params);
    alert(source);
    console.log(source);

任何建议将不胜感激。这是一个大图书馆,我认为这个问题很普遍?谢谢。

标签: javascriptreact-nativestripe-payments

解决方案


API 已更改,文档未更新。这是新格式:

 const source = await stripe.createSourceWithParams({
    type: 'card',
    number: '5555555555554444',
    expMonth: 11,
    expYear: 29,
    cvc: '789',
  })

推荐阅读