#cetnix2chicago_api

1 messages ยท Page 1 of 1 (latest)

midnight pewterBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1258040649802973206

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

karmic solar
#

hi there!

snow marten
#

hi

karmic solar
snow marten
#

I did it already but it seems not that what I want.
I want to confirmPayment with my public key in my unit test (what usually the phone device, webbrowser or any other client does).

#

There i can just mock or setup an own stripe web server

karmic solar
#

I did it already but it seems not that what I want.
can you clarify what you did exactly and why it's not what you want?

snow marten
#

"See the following section to learn how you can generate a simulated error object." I dont want to simulate anything .. I just want to make the calls from my unit test which usually make the frontend (with clientSecret and private key)

#

I dont know but maybe its not possible to integrate something like "stripe.js" in java/backend to confirm the payment in the backend

#

Just a short question:
Is it possible to make a payment in the backend. For example: When I provide the test credit card information, this will be used to confirm the paymentIntent?

karmic solar
#

I'm sorry I'm confused. if you want an automated test that fills the Payment Element with a card information to then confirm the PaymentIntent on the frontent, then this is not possible as mentioned in the link I shared above.

#

but it's possible to create and confrm a PaymentIntent from the backend if needed.

snow marten
#

Okay but to confirm the PaymentIntent i need to provide Card informations, Public Key and clientSecret. Right?

karmic solar
#

you mean to confirm the PaymentIntent on the frontend? yes. which is not possible to do with automated testing.

snow marten
#

I dont know if this picture is still up-to-date. But I need to make the frontend part (left side: 1-3) on the backend.

karmic solar
#

you are using Tokens? this is a very old integration that you shouldn't be using.

#

instead use PaymentIntent with PaymentMethod

midnight pewterBOT
snow marten
#

Yes Im using PaymentIntent. This picture was just to symbolize the communication. As I understood:

  1. Backend creates PaymentIntent. And returning the clientToken to the frontend: paymentIntent.getClientSecret()
  2. The frontend has integrated the public key and using this clientToken to communicate directly with Stripe.
  3. The frontend can inform the backend, that he paid and he backend will ask stripe if this happend OR a webhook will tell to the backend that a payment has be done.

So the frontend communicates with the backend and in next step with stripe. I want to have point 2 in my unit test and I dont know if this is possible. But in my case the "frontend" is not the frontend, it will be all done in unit test.

uncut zenith
#

Hello
No, that's not something that you can emulate in your automated tests. Front-end in this case uses Stripe.js and invokes functions that talk to Stripe APIs.

We generally discourage running automated tests against our APIs. You should mock the data instead

snow marten
#

Like:

String clientSecret = restCall("localhost:8080/pay")

pay(clientSecret)

boolean isPaid = restCall("localhost:8080/isPaid/{myProductId}")

uncut zenith
snow marten
#

Okay.. So It should be mocked .. alright

uncut zenith
#

Yup

snow marten
#

Yes i have seen

#

But yes i was looking for something like "stripe.js" for java or unit-tests

#

Alright i got it... Mocking makes also less requests to your server ๐Ÿ˜‰

uncut zenith
#

Yup!

snow marten
#

got it... Thank you

#

Have a nice day!