Hasimbola

Hasimbola

Add stripe for payment in Phoenix site

Hello everyone, I would like to add stripe in my project to make payments,

Could someone help me please?

Thanks! :smiley:

Most Liked

arrowsmith

arrowsmith

Hi Hasimbola,

It’s hard to give advice without knowing more about what specifically you’re trying to do. Do you need people to make one-off payments, or subscriptions? Is there a range of products they can choose from? What happens after they pay - does it create a user account? Grant access to a specific part of the site? Send them an email with the product attached?

The simplest approach is to use a Stripe-hosted checkout page: Accept a payment | Stripe Documentation

The flow would work roughly like this:

  • Users visit a path on your site e.g. /checkout.
  • On the backend you generate a Checkout object using the stripity_stripe package, which contains a URL. You redirect them to this URL.
  • They’ll see a Stripe-hosted page where they can enter their payment information etc.
  • On successful payment, they’ll be redirected back to a URL on your site e.g. /checkout_complete which will have a session_id param.
  • You use this session_id param to pull information from Stripe about the checkout session and what they purchased - you can use this this to update your site accordingly e.g. grant them access to the product.

Remember that anyone can type /checkout_complete into their address bar so you can’t trust this URL blindly. You need to pull information from Stripe using your API keys to verify that people have actually paid.

You probably also want to set up a webhook endpoint so that Stripe can send you information about all activity on your account e.g. subscription cancellations and renewals. Again, you need to verify this endpoint so you can be sure that the requests are actually coming from Stripe and not from an attacker - Stripe’s docs have information about how to do this.

Other than that I can’t really give any more advice without knowing more about the details of what you want to do, but I hope that helps.

EDIT: wait, I only just noticed that this thread is from 2022. Oh well, I hope someone still finds the above helpful.

crova

crova

I recently integrated Stripe on an application I’m working on and Stripity Stripe was pretty straightforward to use and had all we needed.
Even if you’re using Stripe checkout (which I also recommend) you can easily create the session with Stripity Stripe.

To OP: your question is to vague. What exactly you need help with on the integration?

karlosmid

karlosmid

Hi! The first thing to check is not related to Elixir. Is Stripe available in your country?

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
nobody
How to bind a phoenix app to a specific ip address? could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
mgjohns61585
Could someone help me? I’m making my first elixir program, number guessing game. I can’t figure out how to convert the user’s guess from ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36352 110
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31265 143
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43757 214
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement