Introduction

In this guide we'll walk through the process of linking Cerb to Stripe. You'll be able to use Stripe's full API from bots in Cerb to automate whatever you need.

Get your API keys from the Stripe dashboard

Visit the Stripe API keys settings page.

Make a note of your Secret Key for the next step.

Create the Stripe service in Cerb

Navigate to Search » Connected Services.

Click the (+) icon in the top right of the list.

Select Stripe.

Enter your Secret Key.

Click the Create button.

Use the connected account in automations

You can use the connected account you just created to access Stripe's API from automations in Cerb. This is typically accomplished using the http.request command and selecting the connected account in the authentication field.

List customers

start:
  http.request/subs:
    output: http_response
    inputs:
      method: GET
      url: https://api.stripe.com/v1/customers
      authentication: cerb:connected_account:stripe
    on_success:
      set:
        response@json: {{http_response.body}}
        http_response@json: null

List subscriptions

start:
  http.request/subs:
    output: http_response
    inputs:
      method: GET
      url: https://api.stripe.com/v1/subscriptions
      authentication: cerb:connected_account:stripe
    on_success:
      set:
        response@json: {{http_response.body}}
        http_response@json: null
start:
  http.request/link:
    output: http_response
    inputs:
      method: POST
      url: https://api.stripe.com/v1/payment_links
      headers:
        Content-Type: application/x-www-form-urlencoded
      authentication: cerb:connected_account:stripe
      body:
        line_items:
          0:
            price: price_1234567890abcdefghijkl
            quantity: 1
    on_success:
      set:
        response_body@json: {{http_response.body}}
      return:
        url: {{response_body.url}}

Create a subscription

start:
  http.request/subscription:
    output: http_response
    inputs:
      method: POST
      url: https://api.stripe.com/v1/subscriptions
      headers:
        Content-Type: application/x-www-form-urlencoded
      authentication: cerb:connected_account:stripe
      body:
        customer: cus_1234567890abcdefghijkl
        items:
          0:
            price: price_1234567890abcdefghijkl

Create an invoice

start:
  http.request/invoice:
    output: http_response
    inputs:
      method: POST
      url: https://api.stripe.com/v1/invoices
      headers:
        Content-Type: application/x-www-form-urlencoded
      authentication: cerb:connected_account:stripe
      body:
        customer: cus_1234567890abcdefghijkl
        subscription: sub_1234567890abcdefghijkl

Bot

You can import the Stripe Bot package for a working example.