Skip to content

Latest commit

 

History

History

README.md

Examples

The ballerinax/paypal.subscriptions connector provides practical examples illustrating usage in various scenarios. Explore these examples, covering use cases like creating and listing subscription plans, and monitoring and managing subscription status.

  1. Create and list plans - Create a subscription plan and list all available plans for subscription-based services.
  2. Monitor and manage subscription status - Retrieve a subscription's status and suspend or reactivate it based on its current state.
  3. Manage Premium Subscription - Create a subscription plan, enroll a customer, and retrieve subscription details for a premium membership.

Prerequisites

  1. Generate PayPal credentials to authenticate the connector as described in the Setup guide.

  2. For each example, create a Config.toml file with the related configuration. Here's an example of how your Config.toml file should look:

    clientId = "<your_client_id>"
    clientSecret = "<your_client_secret>"
    productId = "<your_product_id>"  # Required for create-and-list-plans, manage-premium-subscription
    subscriptionId = "<your_subscription_id>"  # Required for monitor-and-manage-subscription

Running an Example

Execute the following commands to build an example from the source:

  • To build an example:

    bal build
  • To run an example:

    bal run

Building the examples with the local module

Warning: Due to the absence of support for reading local repositories for single Ballerina files, the Bala of the module is manually written to the central repository as a workaround. Consequently, the bash script may modify your local Ballerina repositories.

Execute the following commands to build all the examples against the changes you have made to the module locally:

  • To build all the examples:

    ./build.sh build
  • To run all the examples:

    ./build.sh run