Типси-Stripe: не удается создать исходный код из токена

#javascript #react-native #stripe-payments

#javascript #react-native #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=iosamp;dev=trueamp;minify=false:2275:36)
    at Stripe.createSourceWithParams (http://localhost:8081/index.bundle?platform=iosamp;dev=trueamp;minify=false:190106:29)
    at payWithCard$ (http://localhost:8081/src/CheckoutForm.bundle?platform=iosamp;dev=trueamp;minify=falseamp;modulesOnly=trueamp;runModule=falseamp;shallow=true:383:72)
    at tryCatch (http://localhost:8081/index.bundle?platform=iosamp;dev=trueamp;minify=false:28564:19)
    at Generator.invoke [as _invoke] (http://localhost:8081/index.bundle?platform=iosamp;dev=trueamp;minify=false:28740:24)
    at Generator.prototype.<computed> [as next] (http://localhost:8081/index.bundle?platform=iosamp;dev=trueamp;minify=false:28607:23)
    at tryCatch (http://localhost:8081/index.bundle?platform=iosamp;dev=trueamp;minify=false:28564:19)
    at invoke (http://localhost:8081/index.bundle?platform=iosamp;dev=trueamp;minify=false:28640:22)
    at http://localhost:8081/index.bundle?platform=iosamp;dev=trueamp;minify=false:28650:15
    at tryCallOne (http://localhost:8081/index.bundle?platform=iosamp;dev=trueamp;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);
  

Любые предложения были бы очень признательны. Это большая библиотека, я бы подумал, что эта проблема широко распространена? Спасибо.

Ответ №1:

API изменился, и документы не обновляются. Это новый формат:

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