反应本机导航条

问题描述

我试图从导航到用户输入信用卡详细信息并按“付款”按钮,然后将其带到我应用程序中的另一个屏幕。我已经将导航路径设置为一个名为product的屏幕。但是我的付款功能通过Stripe进行付款,但没有导航到下一个屏幕。我在做什么错了?

这是我的付款功能

  import React,{ useState } from 'react'
    import { Image,Text,TextInput,TouchableOpacity,View,ImageBackground } from 'react-native'
    import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
    import styles from './styles';
    import stripe from 'tipsi-stripe';
    import axios from 'axios'

 stripe.setOptions({
    publishableKey:
    'pk_test_XXXXX'
})

export default function PaymentScreen({navigation}) {
    const [ccNumber,setCCNumber] = useState('')
    const [expDate,setExpDate] = useState('')
    const [zipCode,setZipCode] = useState('')
    const [cvv,setCvv] = useState('')
    const [ loading,setLoading] = useState(false)
    const [token,setToken] = useState(null)

   const onPaymentPress = async () => {
        if ( ccNumber && expDate && zipCode && cvv == null) {
            alert("All fields must be completed")
            return
        };
        const token = await stripe.paymentRequestWithCardForm({
            smsAutofillDisabled: true,requiredBillingAddressFields: 'full',prefilledInformation: {
          billingAddress: {
            name: 'Gunilla Haugeh',line1: 'Canary Place',line2: '3',city: 'Macon',state: 'Georgia',country: 'US',postalCode: '31217',email: 'ghaugeh0@printfriendly.com',},})
    
        axios({
            method:'POST',url: 'https://us-central1-lvc2-73300.cloudfunctions.net/completePaymentWithStripe',data: {
                amount: 50000,currency:'usd',token: token
            },})
        .then(response => {
            console.log(response);
            loading:false
        })
        navigation.navigate('Products',{token})
            
    }

这是我的激活付款功能

 <TouchableOpacity
                        style={styles.button}
                        onPress={() => onPaymentPress()}>
                        <Text style={styles.buttonTitle}>Submit Payment</Text>
                    </TouchableOpacity>

我也正在使用Firebase存储数据 这是我的数据库Firebase后端

const stripe = require('stripe')('sk_test_XXXX)

exports.completePaymentWithStripe = functions.https.onRequest(
    (request,response) => {
        stripe.charges.create({
amount: request.body.amount,currency: request.body.currency,source: request.body.token.tokenId,})

        .then(charge => {
            response.send(charge)
            return null
        })
        .catch(error => {
            console.log(error)
        })
    }
)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...