How to use the tipsi-stripe.createPaymentMethod function in tipsi-stripe

To help you get started, we’ve selected a few tipsi-stripe examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tipsi / tipsi-stripe / example / src / scenes / PaymentIntentScreen.js View on Github external
onAttachPaymentMethod = async (cardNumber) => {
    this.setState({ ...this.state, loading: true })

    if (this.state.confirmationMethod === 'manual') {
      // Create a payment method
      console.log('Calling stripe.createPaymentMethod()')

      let paymentMethod
      try {
        paymentMethod = await stripe.createPaymentMethod(
          demoPaymentMethodDetailsWithCard(cardNumber)
        )
      } catch (e) {
        console.dir(e)
        // One way a payment method can fail to be created is if the card number is invalid
        this.setState({ ...this.state, loading: false, display: e })
        return
      }

      console.log('Payment Method', paymentMethod)
      console.log('Payment Intent', this.state.paymentIntent)

      // Send the payment method to the server and ask it to confirm.
      console.log('Calling /confirm_payment on backend example server')

      let confirmResult = null