Production-grade Elixir client for the Paysafe API.
Overview
This library provides complete coverage of the Paysafe developer platform:
- Payments API — Payment handles, payments, settlements, refunds, payouts, verifications, and customer/vault management.
- Payment Scheduler API — Plans and subscriptions for recurring billing.
- Applications API — Programmatic merchant onboarding.
- Value Added Services — FX Rates, Customer Identity (KYC), Bank Account Validation, Network Tokenization, Account Updater.
- Webhooks — HMAC-SHA256 verification and typed event parsing.
Configuration
Build a config struct from your credentials:
config = Paysafe.Config.new!(
username: "1001062690",
password: "B-qa2-0-...",
environment: :test,
account_id: "1009688230"
)Or load from config/config.exs:
# config/config.exs
config :paysafe,
username: System.get_env("PAYSAFE_USERNAME"),
password: System.get_env("PAYSAFE_PASSWORD"),
environment: :test,
account_id: "1009688230"
# runtime:
config = Paysafe.Config.from_env!()Quick start — card payment
config = Paysafe.Config.new!(
username: "...",
password: "...",
environment: :test,
account_id: "1009688230"
)
# 1. Create a payment handle
{:ok, handle} = Paysafe.create_payment_handle(config, %{
merchant_ref_num: "order-669170",
amount: 5000,
currency_code: "USD",
payment_type: "CARD",
transaction_type: "PAYMENT",
card: %{
card_num: "4111111111111111",
card_expiry: %{month: 12, year: 2030},
cvv: "123",
holder_name: "Jane Doe"
},
billing_details: %{
street: "123 Main St",
city: "New York",
state: "NY",
country: "US",
zip: "10001"
},
settle_with_auth: true
})
# 2. Use the token in a payment
{:ok, payment} = Paysafe.create_payment(config, %{
merchant_ref_num: "payment-001",
amount: 5000,
currency_code: "USD",
settle_with_auth: true,
payment_handle_token: handle.payment_handle_token
})Payment method coverage
The Payments API supports 30+ payment methods:
- Cards — Visa, Mastercard, Amex, Discover, Debit, Prepaid, Corporate.
- Digital Wallets — Apple Pay, Google Pay, PayPal, Venmo, Skrill, Neteller.
- Bank Transfers — iDEAL, EPS, BLIK, Interac e-Transfer, Mazooma, Pay by Bank.
- Direct Debit — ACH (US), BACS (UK), EFT (CA), SEPA (EU).
- Cash — PaysafeCash.
- Vouchers — PaysafeCard, Openbucks, Multibanco.
- LatAm — SafetyPay (Pix, Boleto, KHIPU, MACH), PagoEfectivo, Rapid Transfer.
- Crypto — Pay with Crypto.
Architecture
- Config validated at construction via
NimbleOptions. - All requests have exponential backoff retry on transient failures.
- Token-bucket rate limiting per account via
ExRated. - Telemetry events on every request (
:paysafe, :request, :start/:stop/:exception). - HMAC-SHA256 webhook verification with constant-time comparison.
All public functions return
{:ok, result} | {:error, %Paysafe.Error{}}.
Summary
Functions
Cancel an authorized (pre-settlement) payment.
Cancel a pending refund.
Cancel a pending settlement.
Cancel a subscription.
Create a customer profile in the vault.
Create a multi-use payment handle (saved instrument) for a customer.
Create a payment using a paymentHandleToken.
Create a payment handle (tokenize a payment instrument).
Create a recurring billing plan.
Issue a refund for a completed payment or settlement.
Create a settlement for an authorized payment.
Create a single-use customer token (SUCT), tokenizing a customer's entire saved profile (cards, addresses, bank mandates) for 900 seconds.
Create a subscription for a customer under a plan.
Create a card verification (zero-value auth check).
Delete a customer profile.
Delete (discontinue) a billing plan.
Retrieve a customer profile.
Retrieve a customer profile by your own merchantCustomerId.
Retrieve a payment by ID.
Retrieve a payment handle by ID.
Retrieve a billing plan by ID.
Retrieve a subscription by ID.
Check if a PaymentHandle requires a customer redirect.
List saved payment handles for a customer.
List payments with optional filters.
List all billing plans.
List subscriptions.
Create an original credit (payout for iGaming merchants).
Parse a verified webhook body.
Re-activate a suspended subscription.
Create a standalone credit (payout for non-iGaming merchants).
Suspend a subscription (billing paused; can be re-activated).
Update a customer profile.
Update a billing plan.
Update a subscription.
Verify the HMAC-SHA256 signature and parse a webhook payload.
Returns the currently configured package version.
Functions
Cancel an authorized (pre-settlement) payment.
Cancel a pending refund.
Cancel a pending settlement.
Cancel a subscription.
Create a customer profile in the vault.
Create a multi-use payment handle (saved instrument) for a customer.
Create a payment using a paymentHandleToken.
See Paysafe.Payments.Payments.create/3 for full parameter docs.
Create a payment handle (tokenize a payment instrument).
See Paysafe.Payments.PaymentHandles.create/3 for full parameter docs.
Create a recurring billing plan.
See Paysafe.Scheduler.Plans.create/3 for full parameter docs.
Issue a refund for a completed payment or settlement.
Pass the settlement ID (or the payment ID, if settle_with_auth was
true on the original payment).
Create a settlement for an authorized payment.
Create a single-use customer token (SUCT), tokenizing a customer's entire saved profile (cards, addresses, bank mandates) for 900 seconds.
Create a subscription for a customer under a plan.
See Paysafe.Scheduler.Subscriptions.create/3 for full parameter docs.
Create a card verification (zero-value auth check).
Delete a customer profile.
Delete (discontinue) a billing plan.
Retrieve a customer profile.
Retrieve a customer profile by your own merchantCustomerId.
Retrieve a payment by ID.
Retrieve a payment handle by ID.
Retrieve a billing plan by ID.
Retrieve a subscription by ID.
@spec handle_action(Paysafe.Types.PaymentHandle.t()) :: {:redirect, String.t()} | :proceed
Check if a PaymentHandle requires a customer redirect.
Returns {:redirect, url} or :proceed.
Example
{:ok, handle} = Paysafe.create_payment_handle(config, params)
case Paysafe.handle_action(handle) do
{:redirect, url} -> redirect(conn, url)
:proceed -> create_payment(config, payment_params)
end
List saved payment handles for a customer.
List payments with optional filters.
List all billing plans.
List subscriptions.
Create an original credit (payout for iGaming merchants).
Parse a verified webhook body.
Re-activate a suspended subscription.
Create a standalone credit (payout for non-iGaming merchants).
Suspend a subscription (billing paused; can be re-activated).
Update a customer profile.
Update a billing plan.
Update a subscription.
Verify the HMAC-SHA256 signature and parse a webhook payload.
See Paysafe.Webhooks.verify_and_parse/3 for full docs.
@spec version() :: String.t()
Returns the currently configured package version.