I'm new to stripe and using it to test in a web api .net core 6 project. I can Create Stripe Session Service, but the PaymentIntentId is always null. I believe you need to have the PaymentIntentId when you are trying to do a refund.
Any idea what I'm missing here?
Thanks a lot.
Since version 2022-08-01
A PaymentIntent is no longer created during Checkout Session creation in payment mode.
Instead, a PaymentIntent will be created when the Session is confirmed.
You could either store the Checkout Session id and when you want to refund get the PaymentIntent id by retrieving the Checkout Session, or you could listen to the checkout.session.completed event and then store the PaymentIntent Id. You can read more about the latter here.
Related
Currently have a web app hosted on github pages.
I want to use firebase functions + stripe to handle payments.
I have most things set up and now am calling the method stripe.redirectToCheckout({ sessionId })
However, on a successful payment, I want to update the database but I don't see an option add a callback. It only redirects me to a success/failure page. Im thinking of maybe redirecting back to the webapp but with some queryParams. Then check if query param is there on page load, update DB. But that seems incorrect and people could just then navigate to the specific URL to be added into the database.
How do I achieve what I am trying to do?
You should ideally use Stripe Webhooks. You can create a HTTP function and specify it's URL for the webhook from Stripe Dashboard. So whenever an event (e.g. checkout session completed or failed) triggers the webhook, it'll send the event details to your Cloud Function and there you can update the database as required. There is no client side involved in this so risk is negligible.
Also checkout the Firebase Stripe Extension that might do most of the work for you.
I've been reading over the stripe API and it says to create a paymentIntent as soon as I know the total amount. I can use "useEffect" when the customer loads the checkout page and create a paymentIntent from there, but where should I store the clientSecret to retrieve this paymentIntent if the customer navigates away from checkout and then comes back? In the stripe documents, it says: "You can use the client secret to complete the payment process with the amount specified on the PaymentIntent. Don’t log it, embed it in URLs, or expose it to anyone other than the customer. Make sure that you have TLS on any page that includes the client secret." Is it safe to store the clientSecret in local storage or is there a better option?
When watching the official stripe videos it never mentioned anything about TLS so how do I go about ensuring that I have TLS on the page as well? (My backend is currently through the Next.js api routes) *Edit: I just discovered that when hosting with vercel, they automatically configure SSL on the page for you.
The way I have my flow setup is that the customer will click one button that will first create a paymentIntent and then right after that use confirmCardPayment to confirm the paymentIntent. When reading the docs, it seems like this isn't the best way to have it set up.
Is it safe to store the clientSecret in local storage or is there a better option?
You wouldn't want to store the client secret in a database. You would either (a) create a new Payment Intent and get a new client secret from it, or (b) store the Payment Intent ID and make an API call to retrieve the client secret with it when the customer navigates back to your payment page.
The way I have my flow setup is that the customer will click one button that will first create a paymentIntent and then right after that use confirmCardPayment to confirm the paymentIntent. When reading the docs, it seems like this isn't the best way to have it set up.
This payment flow will work just fine and is recommended in the Stripe documentation (for example here)
Hi I am currently doing project that is creating a payment gateway for my webpage and currently I am using PayPal Smart Button for the payment gateway
For now, I have successfully doing the payment but I am unable to get the data that I decided to use for updating the database. I used the PayPal developer website as reference(code, methods etc.), but it doesn't work. Get Transaction <-- I am not sure where should I put the provided code in a Controller/Model
I am using ASP.NET MVC for my project.
Please help me.
Thank you.
Create two routes that return JSON, one for "Create an order" and one for "Capture an order", documented here: https://developer.paypal.com/docs/business/checkout/server-side-api-calls/#server-side-api-calls
Pair your two routes with Smart Button JS for approval. Here is a demo: https://developer.paypal.com/demo/checkout/#/pattern/server
This way when an order is captured, you'll have an immediate API response on your server with all the transaction details. Update your database then.
A client of mine wants to change payment service provider in his WooCommerce store. He has a few hundred existing subscriptions that need to be transferred to this new PSP. Basically, everything is done in order to do this, except for the configuration in WooCommerce. WooCommerce needs to know to use the new payment plugin's code to renew subscriptions. I know of the existence of this integration method but that's not the issue. That integration allows you to add the required metadata to orders (like credit card tokens) in the WooCommerce UI. That has already been done. I changed the _payment_method post meta of a test subscription to my payment method identifier and I set _requires_manual_renewal identifier to false however, for some reason in the UI it still says Manual Renewal under payment method.
What things do I have to change in the database in order to change the payment method?
I have an asp.net application
The User can purchase items and/or upgrade an existing service. I use PayPal to handle payments.
When the order is placed I put the order details into a table as a record. I also do this so that if the User revisits my page I check a flag in that table to tell them whether payment has been received.
If not received then I display a message on my web page telling them they have requested and upgrade and that we are currently waiting for payment.
I also disable any future purchases for that User so that they do not upgrade twice (or more).
Now, it occurs to me that when the User is redirected to PayPal to make that purchase that a payment could fail or they could close the web page.
In that case then the User would not be able to ever upgrade unless they send me a support email.
What is best practice? Wait for a time period to elapse and if no payment then allow User to try again or stick with the support email route?
If it is best to wait for a period of time what is an acceptable period of time to wait for?
I am using the post back of Form values method to imitate payment to PayPal:
https://www.paypal.com/cgi-bin/webscr
What you can do.
Each time the user is ready to leave your page and move to paypal to pay, you create
Clone of their order
A new unique ID connected with that cloned order.
So, if one order if fail, at any time the user come back is find a new set "Order"+"Unique ID". With that 2 elements can make a final payment.
You may end up with two or tree or more cloned orders, but from my experience because this is what I really do, is rare, and its safe for your customer and you.
Also please note that paypal is accept only one unique id for each order. If one ID is fail, then you must create a new one anyway.
The unique id you send to paypal go to the invoice parametre.
The manual for all parametres is this pdf - PayPal Payments Standard Intergration Guide... and there are more pdf for paypal...