Paybin
Get your Paybin credentials
To use Paybin sign in, you need to create an OAuth 2.0 Client through your Paybin Portfolio application.
-
Log in to your Paybin Portfolio
-
Navigate to Developer Settings or OAuth Applications section
-
Click "Create OAuth Application" or "New Application"
-
Fill in the required fields:
- Application Name: The name shown to users during authorization
- Redirect URIs: Set to
http://localhost:3000/api/auth/callback/paybinfor local development. For production, set it tohttps://yourdomain.com/api/auth/callback/paybin. If you change the base path of the auth routes, update the redirect URI accordingly.
-
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.
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.
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.
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:
idfromsubclaimnamefromname,preferred_username, oremail(in order of preference)emailfromemailclaimimagefrompictureclaimemailVerifiedfromemail_verifiedclaim