Skip to content

Stripe offers payment processing software and application programming interfaces for e-commerce websites and mobile applications.

License

Notifications You must be signed in to change notification settings

ballerina-platform/module-ballerinax-stripe

Repository files navigation

Ballerina Stripe connector

Build Trivy GraalVM Check GitHub Last Commit GitHub Issues

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

  1. Sign in to your Stripe dashboard.

Step 2: Go to the developer portal

  1. Click on the Developers button in the top-right corner.

    Stripe dashboard

Step 3: Retrieve the secret key

  1. Go to API keys section in the nav-bar.

    Stripe dashboard
  2. Retrieve the Secret key.

    Stripe dashboard

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: "[email protected]",
    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.

  1. Manage Stripe payments - Manage business payments with Stripe.

  2. Manage one-time charges - Manage one-time charges with Stripe.

Build from the source

Setting up the prerequisites

  1. 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.

  2. Download and install Ballerina Swan Lake.

  3. Download and install Docker.

    Note: Ensure that the Docker daemon is running before executing any tests.

  4. 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.

  1. To build the package:

    ./gradlew clean build
  2. To run the tests:

    ./gradlew clean test
  3. To build the without the tests:

    ./gradlew clean build -x test
  4. To run tests against different environments:

    ./gradlew clean test -Pgroups=<Comma separated groups/test cases>
  5. To debug the package with a remote debugger:

    ./gradlew clean build -Pdebug=<port>
  6. To debug with the Ballerina language:

    ./gradlew clean build -PbalJavaDebug=<port>
  7. Publish the generated artifacts to the local Ballerina Central repository:

    ./gradlew clean build -PpublishToLocalCentral=true
  8. 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

About

Stripe offers payment processing software and application programming interfaces for e-commerce websites and mobile applications.

Resources

License

Stars

Watchers

Forks

Packages