#DeadlyData-requests

1 messages · Page 1 of 1 (latest)

red herald
mortal ridge
#

it just says GET / 404 Not Found

#

i am using ngrok to creeate the public url so my android app can conect to it,

red herald
#

can you share more on what you're trying to do? What are you trying to retrieve here?

mortal ridge
#

I am trying to allow the user to input their card information and then proceed to checkout.

#

i am not sure if im using the right docs tho

red herald
#

you would probably want to follow this guide instead https://stripe.com/docs/payments/quickstart - this is the latest version. Unless you have a specific reason why you would want to use the card element only instead

mortal ridge
#

Sorry sent the wrong url, this is the i am trying to use but whenever i launch my app

#

(the url you sent)

#

but whenever i launch my app i get this error

red herald
#

what is the line of code in your app which is making the GET API request?

mortal ridge
#

i used the fetchPaymentIntent method from the docs

#

so line 61

#

i basically copied everything in the docs from this

#

this is the error i am getting.

red herald
#

i'm not sure if you've changed the url since the last time you've tried it, but the ngrok url and the url in the error message currently doesn't match

#

your ngrok url in the first screenshot starts off with fb2b..., but the url in the error starts off with fe28...

mortal ridge
#

Yes i restarted it this is the current url

#

this is how

#

my payment activity looks

#

the url is updated with the current 1 from that java file

#

oh wait

#

i think i got it fixed

#

their was an error on my end.

#

Sorry, thank you for your time anyway!

red herald
#

np! glad you managed to figure things out

mortal ridge
#

🥲 ! have a goodday!

#

i do have few questions tho, so when the user taps the pay button, add a payment method comes up how do i allow the user to enter their street address as well as update the total?

red herald
#

why do you want to update the total? usually at this point, the total is already "confirmed"

mortal ridge
#

it just says pay(14) i would like to set it to the customers total

#

that they selected

#

/ is in their cart

red herald
#

iirc, the amount to pay is based off the amount passed in when creating the PaymentIntent. Are you using the amount passed into the request to create a PaymentIntent?

mortal ridge
#

i didnt i do have the total stored in a variable called totalCost

#

so where would i like pass the variable in the code?

red herald
#

you would probably want to pass in the total cost in the requestBody

I'm not sure what language you're using to for the server. In general though, you can pass in certain details such as the amount in the request body which you would parse and handle accordingly in your server to create the PaymentIntent.

private void fetchPaymentIntent() {
        final String shoppingCartContent = "{\"items\": [ {\"id\":\"xl-tshirt\"}]}";

        final RequestBody requestBody = RequestBody.create(
            shoppingCartContent,
            MediaType.get("application/json; charset=utf-8")
        );

        Request request = new Request.Builder()
            .url(BACKEND_URL + "/create-payment-intent")
            .post(requestBody)
            .build();
app.post("/create-payment-intent", async (req, res) => {
  const { items } = req.body;

  // Create a PaymentIntent with the order amount and currency
  const paymentIntent = await stripe.paymentIntents.create({
    amount: calculateOrderAmount(items),
    currency: "eur",
    automatic_payment_methods: {
      enabled: true,
    },
  });```
#

you would want to do some kind of validation/calculation on your backend for the amount and items being paid for. It's easy for a customer who knows how to code to edit the amount in your frontend, and the amount being sent on to your backend may then be incorrect.

mortal ridge
#

Okay got it thank you! i will try to implement this later in the day