Paybin

Get your Paybin credentials

To use Paybin sign in, you need to create an OAuth 2.0 Client through your Paybin Portfolio application.

  1. Log in to your Paybin Portfolio

  2. Navigate to Developer Settings or OAuth Applications section

  3. Click "Create OAuth Application" or "New Application"

  4. Fill in the required fields:

    • Application Name: The name shown to users during authorization
    • Redirect URIs: Set to http://localhost:3000/api/auth/callback/paybin for local development. For production, set it to https://yourdomain.com/api/auth/callback/paybin. If you change the base path of the auth routes, update the redirect URI accordingly.
  5. After creation, copy the Client ID and Client Secret to your environment variables. Keep these credentials secure.

Configure the provider

To configure the provider, you need to import the provider and pass it to the social_providers option of the auth instance.

config/auth.rb
require "better_auth"

auth = BetterAuth.auth(
secret: ENV.fetch("BETTER_AUTH_SECRET"),
base_url: ENV.fetch("BETTER_AUTH_URL", "http://localhost:3000"),
social_providers: {
paybin: BetterAuth::SocialProviders.paybin(
  client_id: ENV.fetch("PAYBIN_CLIENT_ID"),
  client_secret: ENV.fetch("PAYBIN_CLIENT_SECRET")
)
}
)

Sign In with Paybin

To sign in with Paybin, call auth.api.sign_in_social on your Ruby auth instance, where the provider should be set to paybin.

server.rb
response = auth.api.sign_in_social(
body: {
provider: "paybin",
callback_url: "/dashboard",
error_callback_url: "/login",
disable_redirect: true
}
)

redirect_url = response.fetch(:url)

Additional Configuration

Scopes

By default, Paybin provider requests the following scopes: openid, email, and profile. You can customize the scopes based on your application's needs.

For a complete list of available scopes and their descriptions, see the Paybin OIDC Scopes Documentation.

config/auth.rb
require "better_auth"

auth = BetterAuth.auth(
  secret: ENV.fetch("BETTER_AUTH_SECRET"),
  base_url: ENV.fetch("BETTER_AUTH_URL", "http://localhost:3000"),
  social_providers: {
    paybin: BetterAuth::SocialProviders.paybin(
      client_id: ENV.fetch("PAYBIN_CLIENT_ID"),
      client_secret: ENV.fetch("PAYBIN_CLIENT_SECRET"),
      scopes: ["openid", "email", "profile"]
    )
  }
)

User Profile Mapping

Paybin returns user information in the ID token following OpenID Connect standards. The provider automatically extracts:

  • id from sub claim
  • name from name, preferred_username, or email (in order of preference)
  • email from email claim
  • image from picture claim
  • emailVerified from email_verified claim

On this page