Overview
All PayMaya SDK clients (PayMayaCheckout, PayWithPayMaya, and PayMayaVault) use a builder pattern for configuration. The builder provides a fluent API to set required and optional parameters before creating the client instance.
Builder Interface
Each client provides aBuilder interface accessible via newBuilder():
Common Methods
These methods are available on all client builders:clientPublicKey()
Your PayMaya public API key
environment()
The target environment (
SANDBOX or PRODUCTION)logLevel()
The logging verbosity level
build()
Builds and returns the configured client instance.The
build() method will throw an exception if required parameters (clientPublicKey and environment) are not set.Vault-Specific Methods
PayMayaVault.Builder includes an additional method:
logo()
Drawable resource ID for custom logo
Complete Examples
Builder Pattern Benefits
- Fluent API: Chain configuration methods for readable code
- Type Safety: Compile-time validation of parameter types
- Immutability: Built clients are immutable once created
- Required Parameters: Build fails if required config is missing
- Optional Parameters: Sensible defaults for optional settings
Best Practices
- Store Client Instance: Create the client once and reuse it throughout your app
- Use BuildConfig: Store API keys in
build.gradleand reference viaBuildConfig
- Environment-Specific Keys: Use different keys for debug/release builds
See Also
- PayMayaCheckout - Checkout client
- PayWithPayMaya - PayWithPayMaya client
- PayMayaVault - Vault client
- PayMayaEnvironment - Environment configuration
- LogLevel - Logging configuration