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)

这是我的代码。我已经尝试了所有组合,但是我不确定卡[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);

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

解决方法

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

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