SDKs overview
Billplz offers a range of Software Development Kits (SDKs) and libraries designed to facilitate the integration of its payment gateway services into various applications. These tools abstract the complexities of direct HTTP requests to the Billplz API endpoints, providing developers with language-specific methods and objects for common operations. The available SDKs support popular programming languages, ensuring broader compatibility for different development environments.
Integrating with SDKs can simplify tasks such as creating new bill requests, checking payment statuses, and processing callbacks. By using an SDK, developers can reduce the amount of boilerplate code required and focus on the business logic of their application, while relying on the SDK to handle API authentication, request formatting, and response parsing. Billplz maintains official SDKs for several languages, alongside community-contributed libraries which can offer additional flexibility or specialized features.
Official SDKs by language
Billplz provides officially supported SDKs for key programming languages. These libraries are typically maintained by Billplz to ensure compatibility with the latest API versions and features, offering a reliable path for integration. The table below outlines the official SDKs, their package names, typical installation commands, and their general maturity status within the ecosystem, based on Billplz's own documentation.
| Language | Package/Library Name | Typical Install Command | Maturity |
|---|---|---|---|
| PHP | billplz/billplz-php |
composer require billplz/billplz-php |
Stable |
| Ruby | billplz |
gem install billplz |
Stable |
| Python | billplz-python |
pip install billplz-python |
Stable |
| Java | com.billplz:billplz-java |
Add to pom.xml or build.gradle |
Stable |
| Node.js | billplz-nodejs |
npm install billplz-nodejs |
Stable |
Each official SDK is designed to encapsulate the core functionalities of the Billplz API, including creating bills, checking collections, and managing webhooks. Developers can refer to the specific Billplz developer documentation for detailed usage instructions and examples pertinent to each language.
Installation
The installation process for Billplz SDKs generally follows standard package management practices for each programming language. Below are common installation methods for the official Billplz libraries. Prior to installation, ensure your development environment has the respective package manager configured.
PHP
For PHP projects, Composer is the standard dependency manager. To install the Billplz PHP SDK, navigate to your project directory and execute:
composer require billplz/billplz-php
After installation, Composer's autoloader will make the Billplz classes available in your application.
Ruby
Ruby projects typically use RubyGems. To add the Billplz Ruby gem to your application, run:
gem install billplz
Alternatively, add it to your Gemfile and run bundle install:
# Gemfile
gem 'billplz'
Python
Python packages are managed using pip. Install the Billplz Python SDK by executing:
pip install billplz-python
This command will download and install the library and its dependencies, making it available for import in your Python scripts.
Java
For Java projects, you typically add the Billplz Java SDK as a dependency in your build tool configuration (e.g., Maven or Gradle). For Maven, add the following to your pom.xml:
<dependency>
<groupId>com.billplz</groupId>
<artifactId>billplz-java</artifactId>
<version>1.0.0</version> <!-- Replace with the latest version -->
</dependency>
For Gradle, add to your build.gradle:
implementation 'com.billplz:billplz-java:1.0.0' // Replace with the latest version
Ensure you replace 1.0.0 with the current stable version as specified in the Billplz documentation.
Node.js
Node.js projects use npm or yarn for package management. To install the Billplz Node.js SDK, run:
npm install billplz-nodejs
Or with Yarn:
yarn add billplz-nodejs
This will add the package to your node_modules directory and update your package.json.
Quickstart example
The following example demonstrates a basic integration using the Billplz PHP SDK to create a new bill. This process typically involves initializing the Billplz client with an API key and then calling a method to create a bill with specified parameters, such as amount, email, and description. This example is based on the Billplz API documentation for creating bills.
<?php
require_once 'vendor/autoload.php';
use Billplz\API;
$apiKey = 'YOUR_API_KEY'; // Replace with your actual API key
$collectionId = 'YOUR_COLLECTION_ID'; // Replace with a valid collection ID
// Initialize Billplz API client
$billplz = new API($apiKey);
try {
$bill = $billplz->bill->create(
$collectionId,
'[email protected]', // Payer email
null, // Payer mobile (optional)
1000, // Amount in cents (e.g., RM10.00)
'https://yourwebsite.com/return_url', // Redirect URL after payment
'Test Bill Description',
[
'reference_1_label' => 'Tracking ID',
'reference_1' => 'ORDER-12345',
'callback_url' => 'https://yourwebsite.com/webhook_callback'
]
);
echo "Bill Created Successfully!\n";
echo "Bill ID: " . $bill->id . "\n";
echo "Payment URL: " . $bill->url . "\n";
} catch (Exception $e) {
echo 'Error creating bill: ' . $e->getMessage() . "\n";
}
?>
This snippet demonstrates setting up the client, defining necessary parameters, and handling the response. Similar patterns apply to other SDKs, where you would import the respective library, instantiate a client with your API key, and call the appropriate method for the desired operation. For securing API keys, consider environment variables or a secrets management solution, as recommended by security best practices for API integration, such as those outlined by Google's API client security guidelines.
Community libraries
In addition to the official SDKs, the Billplz ecosystem benefits from community-developed libraries and integrations. These third-party contributions can offer support for languages not officially covered, provide alternative implementations, or integrate Billplz functionalities into specific frameworks or platforms (e.g., e-commerce plugins, content management system modules). While not officially maintained or supported by Billplz, these libraries can be valuable resources for developers seeking specialized solutions.
When considering a community library, it is advisable to evaluate its maintenance status, community activity, and compatibility with the latest Billplz API version. Developers often publish these libraries on public repositories like GitHub or language-specific package indexes (e.g., Packagist for PHP, npm for Node.js). Always review the source code and documentation of third-party libraries before integrating them into production environments to ensure they meet your project's security and reliability requirements. For example, the Mozilla Developer Network provides secure coding guidelines that are applicable when evaluating external dependencies.
Specific community libraries can vary over time. Developers should search relevant package repositories or the Billplz community forums for the most up-to-date list of available third-party integrations. These community efforts reflect the adaptability of the Billplz API and its capability to be integrated into diverse development stacks beyond the officially supported SDKs.