All Projects → sikanhe → Stripe Elixir

sikanhe / Stripe Elixir

Licence: mit
Stripe API client for Elixir

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to Stripe Elixir

Stripy
Micro wrapper for Stripe's REST API.
Stars: ✭ 49 (-25.76%)
Mutual labels:  stripe-api, stripe
stripe-scala
Scala library for the Stripe API
Stars: ✭ 33 (-50%)
Mutual labels:  stripe, stripe-api
stripe-course
Stripe Payments In Practice - Build your own online ecommerce store and subscription membership website
Stars: ✭ 31 (-53.03%)
Mutual labels:  stripe, stripe-api
Stripe Rs
Moved to https://github.com/wyyerd/stripe-rs.
Stars: ✭ 16 (-75.76%)
Mutual labels:  stripe-api, stripe
Vue Stripe Elements
A Vue 2 component collection for StripeElements
Stars: ✭ 498 (+654.55%)
Mutual labels:  stripe-api, stripe
MERN-Ecommerce
An E-commerce app built using MERN stack. It has 4 social login options and implements email verification as well. Stripe and Paypal payment gateways are implemented.
Stars: ✭ 50 (-24.24%)
Mutual labels:  stripe, stripe-api
Stripe Demo Connect Roastery Saas Platform
Roastery demo SaaS platform using Stripe Connect
Stars: ✭ 33 (-50%)
Mutual labels:  stripe-api, stripe
TradeByte
💸 TradeByte - Stocks Trading Simulation WebApp
Stars: ✭ 30 (-54.55%)
Mutual labels:  stripe, stripe-api
Stripe Connect Rocketrides
Sample on-demand platform built on Stripe: Connect onboarding for pilots, iOS app for passengers to request rides.
Stars: ✭ 426 (+545.45%)
Mutual labels:  stripe-api, stripe
Stripe Webhook Monitor
Stripe Webhook Monitor provides a real-time feed and graph of Stripe events received via webhooks. 📈✨
Stars: ✭ 356 (+439.39%)
Mutual labels:  stripe-api, stripe
stripe
Stripe integration with Magento 2
Stars: ✭ 58 (-12.12%)
Mutual labels:  stripe, stripe-api
Pinax Stripe
a payments Django app for Stripe
Stars: ✭ 650 (+884.85%)
Mutual labels:  stripe-api, stripe
pinax-stripe-light
a payments Django app for Stripe
Stars: ✭ 670 (+915.15%)
Mutual labels:  stripe, stripe-api
nuxt-stripejs
💳 NuxtJS module for Stripe.js which loads only when required and w/ retry mechanism
Stars: ✭ 17 (-74.24%)
Mutual labels:  stripe, stripe-api
stripe-graphql
[WIP] 🚧🚧🚧 😎 Community-driven Stripe GraphQL API with superpowers.
Stars: ✭ 53 (-19.7%)
Mutual labels:  stripe, stripe-api
procesa-pagos-con-laravel
Código fuente resultado del curso "Procesa pagos con Laravel y las mejores plataformas de pagos"
Stars: ✭ 38 (-42.42%)
Mutual labels:  stripe, stripe-api
Stripe
Stripe library for Vapor
Stars: ✭ 151 (+128.79%)
Mutual labels:  stripe-api, stripe
React Express Stripe
💰 Minimal Boilerplate for Stripe used in React and Express. Charge payments from your customers with this project.
Stars: ✭ 209 (+216.67%)
Mutual labels:  stripe-api, stripe
Nest-Js-Boiler-Plate
Nest Js Boilerplate with JWT authentication, CRUD functions and payment gateways.
Stars: ✭ 14 (-78.79%)
Mutual labels:  stripe, stripe-api
Stripity stripe
An Elixir Library for Stripe
Stars: ✭ 597 (+804.55%)
Mutual labels:  stripe-api, stripe

Stripe Build Status

Stripe API client for Elixir. Documentation

  • Everything except for Relay features are complete and tested.
  • Looking for more contributors/maintainers for this project, currently need help with documentation.

Installation

  1. Add stripe to your list of dependencies in mix.exs:
def deps do
  [{:stripe, "~> 0.8.0", hex: :stripe_elixir}]
end
  1. (Pre-Elixir 1.4) Ensure stripe is started before your application:
def application do
  [applications: [:stripe]]
end
  1. Make sure your stripe secret_key is added to your config file:
config :stripe, :secret_key, <YOUR_SECRET_KEY>
  1. Alternatively, you can also set the secret key as an environment variable:
export STRIPE_SECRET_KEY=<YOUR_SECRET_KEY>

Basic Usage

This lib closely follows the official Ruby Client API.

  • Stripe.{RESOURCE}.create
  • Stripe.{RESOURCE}.retrieve
  • Stripe.{RESOURCE}.update
  • Stripe.{RESOURCE}.list

Returns {:ok, RESPONSE_BODY} when the request is successful.

{:error, %ERROR_STRUCT{}} tuples are returned when there is a request/api error.
See all error types at https://stripe.com/docs/api/ruby#errors

Some Basic Examples

Create a customer:

{:ok, %{"id" => "cus_asdfghjkl"} =
    Stripe.Customer.create(email: "[email protected]")

Note that either KeywordLists or Maps with either String or Atom keys are acceptable for arguments and options. So all of the following would also work:

Stripe.Customer.create(%{email: "[email protected]"})
Stripe.Customer.create(%{"email" => "[email protected]"})
Stripe.Customer.create([{"email", "[email protected]"}])

Retrieve that customer:

{:ok, customer} = Stripe.Customer.retrieve("cus_asdfghjkl")

Update the customer:

{:ok, %{"metadata" => %{"somedata" => "somevalue"}}} =
  Stripe.Customer.update("cus_asdfghjkl", metadata: [somedata: "somevalue"])

Delete the customer:

{:ok, %{"deleted" => true}} = Stripe.Customer.delete("cus_asdfghjkl")

Stripe Connect

To perform a Direct Charge on a connected stripe account, simply pass :stripe_account as an option

Stripe.Charge.create([customer: "cus_asdfghjkl", amount: 400], stripe_account: "acct_sOMeAcCountId")

Generate a Connect authorization url via Stripe.Connect.authorize_url/1.

Stripe.Connect.authorize_url([
  redirect_uri: <OPTIONAL CALLBACK URL>,
  state: <OPTIONAL CSRF TOKEN>,
  client_id: <OPTIONAL STRIPE PLATFORM CLIENT ID>
])

Options:

  • redirect_uri: An optional callback url after authorization succeeds.
  • state: You can protect your request from CSRF attacks by passing a csrf token.
  • client_id: You can pass in an optional client_id to be used for this url. Defaults to STRIPE_CLIENT_ID environment variable or config :stripe, :client_id config value.

Handling Webhooks

Stripe uses webhooks to notify your web app with events. Stripe.Webhook provides construct_event/3 to authenticate the requests, which can be useful in plugs.

payload = # HTTP content body (e.g. from Plug.Conn.read_body/3)
signature = # 'Stripe-Signature' HTTP header (e.g. from Plug.Conn.get_req_header/2)
secret = # Provided by Stripe

case Stripe.Webhook.construct_event(payload, signature, secret) do
  {:ok, event} ->
    # Return 2XX
  {:error, %Stripe.SignatureVerificationError{}} ->
    # Return non-2XX and handle error
end

The default tolerance is 5 minutes (300 seconds as per official libraries). If your app is rejecting requests because the tolerance is too low, consider passing a higher number to construct_event/4.

Stripe.Webhook.construct_event(payload, signature, secret, 600)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].