Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

209
Views
Integrating Stripe with React Native

We are trying to integrate Stripe into a react native app using @stripe/stripe-react-native. We followed this tutorial https://www.youtube.com/watch?v=DZlAET7Tgx4 https://www.youtube.com/watch?v=DZlAET7Tgx4 for reference.

Our API call is returning an undefined object. We think it might have to do with the API url but we've tried everything (localhost, ip address of computer, ip address of wifi) and nothing is working. We try to console log within the post method but nothing prints which makes us think it's not being called properly. We have a server running using express. Any help would be greatly greatly appreciated :)

This is our post method:

app.post('/create-payment-intent', async (req, res) => {
  console.log("test place 1")
  try {
    const paymentIntent = await stripe.paymentIntents.create(
      {
        amount: 1099,
        currency: "usd",
        payment_method_types: ["card"],

      }
    );
    const clientSecret = paymentIntent.client_secret;
    res.send({
      clientSecret: clientSecret,
    });
  } catch (e) {
    res.json({ error: e.message });
  }
})

And this is when we call it:

const API_URL = "http://10.49.40.160:8000"

const StripeApp = props => {
  const [email, setEmail] = useState();
  const [cardDetails, setCardDetails] = useState();
  const { confirmPayment, loading } = useConfirmPayment();
  const fetchPaymentIntentClientSecret = async () => {
    const response = await fetch(`${API_URL}/
    create-payment-intent`, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        paymentMethodType: 'card',
        currency: 'usd',
      }),
    });
    const { clientSecret, error } = await response.json();
    return { clientSecret, error };
  }

Thank you so much!

over 4 years ago ยท Santiago Trujillo
1 answers
Answer question

0

Can you verify the API found at the URL you provide is active and will return the expected response? It sounds like you already know that is an issue.

If you are just getting started and not necessarily looking to build something immediately production ready, I have found it useful to have a relatively simple back-end that does the bare minimum you will need to test out development ideas.

Stripe provides the code and and even a deployment tool for a simple mobile back-end. If you follow the deployment instructions it will deploy a basic server to Heroku for free. Just be sure to take note of the url and save that information in your app configuration.

Even if you are not too familiar with Ruby syntax (the server is written in Ruby, web.rb) the functions are minimal enough you can look at the code snippets in Stripe Docs to get an idea of what that code is doing.

Happy coding! ๐Ÿ˜„

over 4 years ago ยท Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!