Awesome
Ballerina Stripe connector
Stripe is a leading online payment processing platform that simplifies the handling of financial transactions over the Internet. Stripe is renowned for its ease of integration, comprehensive documentation, and robust API that supports a wide range of payment operations including credit card transactions, subscription management, and direct payouts to user bank accounts.
The Ballerina Stripe Connector allows developers to interact with the Stripe REST API V1, enabling seamless integration of Stripe’s extensive payment processing capabilities into Ballerina applications. This connector facilitates the automation of various payment-related operations such as charge creation, customer management, billing, and direct payouts. By leveraging the Ballerina Stripe Connector, developers can build secure and scalable payment solutions that enhance the e-commerce capabilities of their applications.
Setup guide
To use the Ballerina Stripe connector, you must have a Stripe account and an API token for authentication. Follow the steps below to set up the connector with your Stripe account. If you don't have an account, you can create one by visiting Stripe Sign Up page and completing the registration process.
Step 1: Log in to Stripe
- Sign in to your Stripe dashboard.
Step 2: Go to the developer portal
-
Click on the Developers button in the top-right corner.
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-stripe/main/docs/setup/resources/stripe-dashboard.png alt="Stripe dashboard" style="width: 70%;">
Step 3: Retrieve the secret key
-
Go to API keys section in the nav-bar.
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-stripe/main/docs/setup/resources/stripe-developer-portal.png alt="Stripe dashboard" style="width: 70%;">
-
Retrieve the Secret key.
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-stripe/main/docs/setup/resources/stripe-api-keys.png alt="Stripe dashboard" style="width: 70%;">
Note: If you need to have more granular permissions for the keys, you could setup and use
Restricted keys
.
Quickstart
To begin using the Stripe
connector in your Ballerina application, you'll need to follow these steps:
Step 1: Import the connector
First, import the ballerinax/stripe
package into your Ballerina project.
import ballerinax/stripe;
Step 2: Instantiate a new connector
Create a stripe:ConnectionConfig
object with API token, and initialize the connector.
configurable string secretKey = ?;
stripe:ConnectionConfig configuration = {
auth: {
token: secretKey
}
};
stripe:Client stripe = check new (configuration);
Step 3: Invoke the connector operation
Now, utilize the available connector operations.
Create a new customer
stripe:customers_body newCustomer = {
name: "John Doe",
email: "john.doe@sample.com",
address: {
city: "Colombo",
country: "Sri Lanka"
}
};
stripe:Customer customerDetails = check stripe->/customers.post(newCustomer);
List all customers
stripe:CustomerResourceCustomerList availableCustomers = check stripe->/customers;
Examples
The ballerinax/stripe
connector provides practical examples illustrating usage in various scenarios. Explore these examples, covering various Stripe functionalities.
-
Manage Stripe payments - Manage business payments with Stripe.
-
Manage one-time charges - Manage one-time charges with Stripe.
Build from the source
Setting up the prerequisites
-
Download and install Java SE Development Kit (JDK) version 17. You can download it from either of the following sources:
Note: After installation, remember to set the
JAVA_HOME
environment variable to the directory where JDK was installed. -
Download and install Ballerina Swan Lake.
-
Download and install Docker.
Note: Ensure that the Docker daemon is running before executing any tests.
-
Export Github Personal access token with read package permissions as follows,
export packageUser=<Username> export packagePAT=<Personal access token>
Build options
Execute the commands below to build from the source.
-
To build the package:
./gradlew clean build
-
To run the tests:
./gradlew clean test
-
To build the without the tests:
./gradlew clean build -x test
-
To run tests against different environments:
./gradlew clean test -Pgroups=<Comma separated groups/test cases>
-
To debug the package with a remote debugger:
./gradlew clean build -Pdebug=<port>
-
To debug with the Ballerina language:
./gradlew clean build -PbalJavaDebug=<port>
-
Publish the generated artifacts to the local Ballerina Central repository:
./gradlew clean build -PpublishToLocalCentral=true
-
Publish the generated artifacts to the Ballerina Central repository:
./gradlew clean build -PpublishToCentral=true
Contribute to Ballerina
As an open-source project, Ballerina welcomes contributions from the community.
For more information, go to the contribution guidelines.
Code of conduct
All the contributors are encouraged to read the Ballerina Code of Conduct.
Useful links
- For more information go to the
stripe
package. - For example demonstrations of the usage, go to Ballerina By Examples.
- Chat live with us via our Discord server.
- Post all technical questions on Stack Overflow with the #ballerina tag.