#noor_code

1 messages Ā· Page 1 of 1 (latest)

scarlet deltaBOT
#

šŸ‘‹ Welcome to your new thread!

ā²ļø We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

ā±ļø We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

šŸ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1234508027927728170

šŸ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

devout terraceBOT
ionic sphinx
#

Hello

umbral root
#

hi

ionic sphinx
#

Looks like you may not be passing the PaymentIntent client secret here but instead the PaymentIntent ID?

#

Providing a drive link to your full project isn't really a way I can help you troubleshoot

#

I would need to see the exact code snippets those logs correspond to

umbral root
ionic sphinx
#

What are you returning for json.paymentIntent ?

#

Is it the PaymentIntent ID or its client secret?

umbral root
#

client secret

ionic sphinx
#

Can you show me that full string?

#

Instead of redacting?

#

What does it look like?

umbral root
#

wait

ionic sphinx
#

Oh sorry

#

Your log indicates the error isn't there

#

You are initing PaymentSheet just fine

#

The issue is likely that your total is set to 0 still

#

Per onPress={() => (total != 0 ? openPaymentSheet() : null)}

#

So first, try removing that conditional

#

And just having openPaymentSheet() run regardless

#

And see if your sheet is presented

umbral root
#

`// This example sets up an endpoint using the Express framework.
// Watch this video to get started: https://youtu.be/rPR2aJ6XnAc.
const http = require('http')
const express = require('express')
const app = express()
app.use(express.json())
const stripe = require('stripe')('sk_test_51P8pFGJez7Un1YiNlK93NNXYDWfmxQqGEVIXJmYdCO8A0L6PyJaB3DOBnx9efMXL7jSR01vUm5OacVs2pEQphfEA00TDo6huja');

app.post('/paymentsheet', async (req, res) => {
const amount = req.body?.amount
console.log("amount ", amount);
if (!amount || amount <= 0.5) {
return res.status(400).json({ message: "the amount is insufficient :" + amount });
} else if (amount > 10000) {
return res.status(400).json({ message: "Amount must be at most €10,000.00 EUR"});
}

const customer = await stripe.customers.create();
const ephemeralKey = await stripe.ephemeralKeys.create(
{ customer: customer.id },
{ apiVersion: '2024-04-10' }
);
const paymentIntent = await stripe.paymentIntents.create({
amount: amount*100,
currency: 'eur',
customer: customer.id,
payment_method_types: ['bancontact', 'card', 'ideal', 'klarna', 'sepa_debit'],
});

res.status(200).json({
paymentIntent: paymentIntent.client_secret,
ephemeralKey: ephemeralKey.secret,
customer: customer.id,
publishableKey: 'pk_test_51P8pFGJez7Un1YiNs5HFPM02R2m9AQzqVq5Y0jWyCFqxn56str9fzJ44mJ3gKpScDlViFaxOPSEBGh7RU4VI2arA00Hap7qfJQ'
});
});
const port = process.env.PORT || 3000; // Use environment variable for port or default to 3000
const server = http.createServer(app)
app.listen(port, () => {
console.log(Server listening on port ${port});
});

//server.js
``

#

i`mport React from 'react';
import { View, Text } from 'react-native';
import { createMaterialBottomTabNavigator } from 'react-native-paper/react-navigation';
import { StripeProvider } from '@stripe/stripe-react-native';
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
import Ionicons from 'react-native-vector-icons/Ionicons'
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import Home from './components/screens/Home';
import MyCart from './components/screens/MyCart';
import ProductInfo from './components/screens/ProductInfo';
import splash from './splashscreen/splash';
import splashdone from './splashdone/done';
import Provider from './store/Provider';
import auth from './auth/AuthLogic';
import support from './components/screens/support'

const Stack = createNativeStackNavigator();
const Tab = createMaterialBottomTabNavigator();

const TabNavigator = () => (
<Tab.Navigator shifting={true}>
<Tab.Screen
name="Home"
component={Home}
options={{
tabBarIcon: ({ color }) => (
<MaterialCommunityIcons name="home" color={color} size={26} />
),
}}
/>
<Tab.Screen
name="MyCart"
component={MyCart}
options={{
tabBarIcon: ({ color }) => (
<Ionicons name="cart" color={color} size={26} />
),
}}
/>

     <Tab.Screen
        name="auth"
        component={auth}
        options={{
          tabBarIcon: ({ color }) => (
            <MaterialCommunityIcons name="account" color={color} size={26} />
          ),
        }}
      />

      <Tab.Screen
        name="support"
        component={support}
        options={{
          tabBarIcon: ({ color }) => (
            <Ionicons name="help-circle-outline"
             color={color} size={26} />
          ),
        }}
      />

</Tab.Navigator>
);

const App = () => {
return (
<Provider>
<StripeProvider
publishableKey="pk_test_51P8pFGJez7Un1YiNs5HFPM02R2m9AQzqVq5Y0jWyCFqxn56str9fzJ44mJ3gKpScDlViFaxOPSEBGh7RU4VI2arA00Hap7qfJQ"
>
<NavigationContainer>
<Stack.Navigator screenOptions={{ headerShown: false }}>
<Stack.Screen name="hi" component={splash} />
<Stack.Screen name="Main" component={TabNavigator} />
<Stack.Screen name="orderdone" component={splashdone} />
<Stack.Screen name="ProductInfo" component={ProductInfo} />
</Stack.Navigator>
</NavigationContainer>
</StripeProvider>
</Provider>

);
};

// <Tab.Screen
//name="search"
//component={search}
//options={{
//tabBarIcon: ({ color }) => (
//<FontAwesome name="search" color={color} size={26} />
//),
//}}
///>

export default App;`

ionic sphinx
#

Please stop just dumping code

umbral root
#

`//WELCOME TO API

//URL FOR GET PRODUCT AND MORE
const baseurl = "https://raferserver.onrender.com";

const appFerch = async (url, method, body, headers) => {
const Fullurl = baseurl + url;
const bodystr = JSON.stringify(body) || '';

try {
const response = await fetch(Fullurl, {
method: method,
body: headers ? body : bodystr,
headers: headers || {
'content-type': 'application/json',
},
});

if (!response.ok) {
  throw new Error(`http error: ${response.status}`);
}

return await response.json();

} catch (e) {
console.error('error:', e);
throw e;
}
};

//return product to home

export const getAllProducts = () => {
return appFerch('/getallpro', 'GET');
};`

API

#

that all code

ionic sphinx
#

@umbral root dumping 1000s of lines of code does not help

#

You need to troubleshoot here. I'm happy to give suggestions but I can't read through all of your code

#

Please do what I indicated above. Call presentPaymentSheet() without using a conditional

umbral root
#

wait wait

#

how can i share to you code

ionic sphinx
#

Did you read what I just wrote?

umbral root
#

i try from 2 days and he not done

umbral root
ionic sphinx
#

Sharing your code, other than the specific relevant part, is not helpful.

#

So please don't do that.

#

Change onPress={() => (total != 0 ? openPaymentSheet() : null)} to onPress={() => (openPaymentSheet}

#

And then test again

umbral root
#

ok wait

#

look

#

i fix it

#

i get LOG:LOG Payment sheet has not started yet.

ionic sphinx
#

Sorry I was missing a closing paranthesis

umbral root
#

no problem

ionic sphinx
#

Should be onPress={() => openPaymentSheet}

#

Okay fixed

#

Try that

umbral root
#

LOG json {"message": "the amount is insufficient :null"}
LOG paymentIntent undefined
LOG ephemeralKey undefined
LOG customer undefined
LOG json {"message": "the amount is insufficient :null"}
LOG Initiated payment sheet successfully
LOG json {"customer": "cus_Q0xBiofbFrqHkR", "ephemeralKey": "ek_test_YWNjdF8xUDhwRkdKZXo3VW4xWWlOLEdBNEc4ZTdRb1dWQWVJRk9NOE0zeWYyNlpBNEZERWY_00IuMhCk81", "paymentIntent": "pi_3PAvGlJez7Un1YiN1azbYqYG_secret_jvdn24J7GFrVUXPiEW3ZMjNWK", "publishableKey": "pk_test_51P8pFGJez7Un1YiNs5HFPM02R2m9AQzqVq5Y0jWyCFqxn56str9fzJ44mJ3gKpScDlViFaxOPSEBGh7RU4VI2arA00Hap7qfJQ"}
LOG paymentIntent pi_3PAvGlJez7Un1YiN1azbYqYG_secret_jvdn24J7GFrVUXPiEW3ZMjNWK
LOG ephemeralKey ek_test_YWNjdF8xUDhwRkdKZXo3VW4xWWlOLEdBNEc4ZTdRb1dWQWVJRk9NOE0zeWYyNlpBNEZERWY_00IuMhCk81
LOG customer cus_Q0xBiofbFrqHkR
LOG Initiated payment sheet successfully

i get this log he says done but nothing happend

ionic sphinx
#

Ah whoops try onPress={openPaymentSheet}

#

Otherwise you do need openPaymentSheet() since it is in the callback

umbral root
#

what you mean?

#

now i get this warn if me click on button

#

?

ionic sphinx
#

Yeah there you go so that is the error you need to fix

#

So what does your openPaymentSheet code look like?

umbral root
#

i told you before i try and nothing score...

ionic sphinx
#

You just sai that when you click you get the above warning?

umbral root
#

yes

ionic sphinx
#

Ah why are you passing clientSecret to presentPaymentSheet()?

#

That shouldn't have any parameters

#

It should just be const { error } = await presentPaymentSheet();