项目作者: ballerina-platform

项目描述 :
The Ballerina connector to perform operations on Stripe online payment system.
高级语言: Ballerina
项目地址: git://github.com/ballerina-platform/module-ballerinax-stripe.git
创建时间: 2020-05-18T09:54:53Z
项目社区:https://github.com/ballerina-platform/module-ballerinax-stripe

开源协议:Apache License 2.0

下载


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.

  1. import ballerinax/stripe;

Step 2: Instantiate a new connector

Create a stripe:ConnectionConfig object with API token, and initialize the connector.

  1. configurable string secretKey = ?;
  2. stripe:ConnectionConfig configuration = {
  3. auth: {
  4. token: secretKey
  5. }
  6. };
  7. stripe:Client stripe = check new (configuration);

Step 3: Invoke the connector operation

Now, utilize the available connector operations.

Create a new customer

  1. stripe:customers_body newCustomer = {
  2. name: "John Doe",
  3. email: "john.doe@sample.com",
  4. address: {
  5. city: "Colombo",
  6. country: "Sri Lanka"
  7. }
  8. };
  9. stripe:Customer customerDetails = check stripe->/customers.post(newCustomer);

List all customers

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

    1. export packageUser=<Username>
    2. export packagePAT=<Personal access token>

Build options

Execute the commands below to build from the source.

  1. To build the package:

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

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

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

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

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

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

    1. ./gradlew clean build -PpublishToLocalCentral=true
  8. Publish the generated artifacts to the Ballerina Central repository:

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