manuel-rubio

manuel-rubio

After a while I got the time to publish this first (and incomplete, sorry) library for Paypal v2 which is including at this moment orders and payments.

It’s now battle tested and I can ensure it’s working perfectly for the funcionts that are implemented however, I’ll be adding more parts of the API and publishing new improvements and fixes (if any). Don’t hesitate to use it or even help with documentation, testing, or adding what you need for it.

https://github.com/altenwald/paypal

Showing Posts 1 to 2

manuel-rubio

manuel-rubio OP

Hi everyone! :waving_hand:

I’m happy to announce the release of paypal v0.2.0 on Hex.pm
paypal | Hex !

This release brings a long-awaited feature requested by the community,
along with significant modernization, improved security, and a revamped
HTTP stack.
──────

:sparkles: Highlights in v0.2.0

1. Full PayPal Subscriptions & Billing Plans API

As requested, we now have first-class support for PayPal’s recurring
billing and subscriptions ecosystem:

• Catalog Products (Paypal.Subscription.Product): Create, show, list, and
update digital, physical, or service products.
• Billing Plans (Paypal.Subscription.Plan): Define recurring billing cycles,
setup fees, trial periods, and pricing schemes.
• Subscriptions Lifecycle (Paypal.Subscription): Create subscriptions,
retrieve details, update, revise plans/quantities, suspend, reactivate,
cancel, capture outstanding balances, and list transaction histories.

# 1. Create a Product
{:ok, product} = Paypal.Subscription.Product.create(%{
  name: "Video Streaming Pro",
  type: :service,
  description: "Monthly subscription for video streaming",
  category: "SOFTWARE"
})

# 2. Create a Billing Plan
{:ok, plan} = Paypal.Subscription.Plan.create(%{
  product_id: product.id,
  name: "Monthly Pro Plan",
  description: "Standard monthly billing plan",
  status: :active,
  billing_cycles: [
    %{
      frequency: %{"interval_unit" => "MONTH", "interval_count" => 1},
      tenure_type: :regular,
      sequence: 1,
      total_cycles: 0,
      pricing_scheme: %{
        "fixed_price" => %{"currency_code" => "USD", "value" => "15.00"}
      }
    }
  ],
  payment_preferences: %{
    auto_bill_outstanding: true,
    setup_fee_failure_action: :cancel,
    payment_failure_threshold: 3
  }
})

# 3. Create a Subscription
{:ok, subscription} = Paypal.Subscription.create(%{
  plan_id: plan.id,
  subscriber: %{
    name: %{given_name: "Jane", surname: "Doe"},
    email_address: "jane.doe@example.com"
  },
  application_context: %{
    brand_name: "My SaaS",
    locale: "en-US",
    return_url: "https://example.com/subscription/return",
    cancel_url: "https://example.com/subscription/cancel"
  }
})

──────

2. Migration to Req & Security Improvements

• Switched from Tesla to Req https://github.com/wojtekmach/req: Streamlined
HTTP client configuration, cleaner error handling, and robust Finch pooling
out-of-the-box.
• Dependencies & Security: All dependencies have been audited and updated
(mix_audit clean with 0 vulnerabilities).
──────

3. Modern Elixir & Quality Standards

• Elixir & OTP support: Minimum requirements updated to Elixir ~> 1.17 and
OTP 27+.
• Code Quality & Type Safety:
• 100% clean mix check pipeline (compiler with --warnings-as-errors,
Credo, and strict Dialyzer type specs).
• 100% documentation coverage verified with Doctor.
• Test coverage exceeding 95% with full unit and Bypass integration
suites.
• License: Clarified under the standard MIT License.
──────

:package: Links & Documentation

• Hex.pm: paypal | Hex
• HexDocs: Paypal v0.2.0 — Documentation
• GitHub: GitHub - altenwald/paypal: Paypal implementation for Elixir · GitHub

Feedback, issues, and contributions are very welcome!

manuel-rubio

manuel-rubio OP

paypal is a PayPal REST API v2 & Subscriptions API client built on Req. v0.3.0 is out, fixing a real decoding bug plus a packaging gap.

Fixed

  • Paypal.Order.show/1 and .capture/1 crashed on any order with a completed capture. PayPal returns disbursement_mode as a plain string ("INSTANT"/"DELAYED"), but the schema declared it as :map, so Ecto.embedded_load raised ArgumentError decoding a real response. It’s now a proper enum.
  • seller_protection and seller_receivable_breakdown on a capture were untyped maps. They’re now real structs (Paypal.Order.PurchaseUnit.SellerProtection, ...SellerReceivableBreakdown), so you get capture.seller_receivable_breakdown.paypal_fee.value instead of digging through string keys.

Also

  • Paypal.Case (the Req.Test-based mocking helpers used to test against this library) is now shipped inside the Hex package itself, not just the git repo – no more need to point at GitHub in mix.exs just to get test support.
{:paypal, "~> 0.3.0"}

Docs: Paypal v0.3.0 — Documentation
Source: GitHub - altenwald/paypal: Paypal implementation for Elixir · GitHub

Thanks for any bug reports / PRs!

— All posts loaded —

Where Next? Top

Trending in Announcing Top

restlessronin
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub. Docs are at OpenaiEx User Gu...
152 12366 136
New
type1fool
WebAuthnLiveComponent WebAuthnComponents See this post about renaming the package. Passwordless authentication for Phoenix LiveView app...
New
GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
ahamez
Hi everyone, I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with ...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
kip
I’ll shortly be launching Text, a nascent text analysis library. Current functionality In this early version (not ready for prime time) ...
New

Other Trending Topics Top

budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New
Null-logic-0
What IDE or editor are you using for Elixir development? Personally, I use Zed, and I really like it, but sometimes I wish there were a ...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews