Resources »

Packages »

Stripe Bot

Introduction

This package creates Stripe Bot for demonstrating integration between Cerb and Stripe’s API.

Configure the Stripe service

If you haven’t already, follow these instructions to configure the Stripe service and add your first connected account.

Import the package

Navigate to Setup » Configure » Import Package.

Paste the following package into the large text box:



{
  "package": {
    "name": "Stripe",
    "cerb_version": "9.1.0",
    "revision": 1,
    "requires": {
      "cerb_version": "9.1.0"
    },
    "configure": {
      "prompts": [
        {
          "type": "chooser",
          "label": "Stripe Account:",
          "key": "stripe_account_id",
          "params": {
            "context": "cerberusweb.contexts.connected_account",
            "single": true,
            "query": "name:stripe"
          }
        }
      ]
    },
    "placeholders": []
  },
  "bots": [
    {
      "uid": "bot_2",
      "name": "Stripe",
      "owner": {
        "context": "cerberusweb.contexts.app",
        "id": 0
      },
      "is_disabled": false,
      "params": {
        "config": null,
        "events": {
          "mode": "all",
          "items": []
        },
        "actions": {
          "mode": "all",
          "items": []
        }
      },
      "image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAAXNSR0IArs4c6QAAEkhJREFUeAHtXPlzHMUVfjOzt7Q6LPm+uA0YY8AG40AIlRASSCgIqSSk8lP+tPyUqlSlQiWpUFBFIAkmgIFwJBgb40OWbEvWZUm7s8cc+b7ubWl2vWuvvAseu6Ytzdn9+vX73tVvBNaZM2dCSVpsJGDHhpOEESWBBJCYKUICSAJIzCQQM3YSC0kAiZkEYsZOYiEJIDGTQMzYSSwkASRmEogZO4mFJIDETAIxYyexkASQmEkgZuwkFpIAEjMJxIydxEISQGImgZixk1hIAkjMJBAzdhILSQCJmQRixk5iIQkgMZNAzNhJLCQBJGYSiBk7iYUkgMRMAjFjJ7GQBJCYSSBm7CQWkgDyzUsgvIn/i5fUNy+eb3YGI3xz5mz2TWz3Nz0glqUBN2cDPwFqfWbexfl8QwAJApEQ/yz864c2+77I0rIts/OhnDtvSyYdyhOPYZKbsH1rgNCth5ARAdAgNFSbz9epzaRlRn/8uS0ffmqL61riVi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57EuBm0SB7+NoHeTxlgSEC1NRBKgwjhAeAhDn2EGe2W5ZQLg4bQk6XvD+ZmgxzjduBvH1n8cEkP7LtCeKCSA9ia//gxNA+i/TnigmgPQkvv4PTgDpv0x7opgA0pP4+j84AaT/Mu2JYgJIT+Lr/+AEkP7LtCeKCSA9ia//gxNA+i/TnigmgPQkvv4PTgDpv0x7opgA0pP4+j84AaT/Mu2JYgJIT+Lr/+AEkP7LtCeKCSA9ia//gxNA+i/TnigmgPQkvv4PTgDpv0x7opgA0pP4+j84AaT/Mu2JYgJIT+Lr/+AEkP7LtCeKCSA9ia//gxNA+i/TnigmgPQkvv4P/j+LTJjCraeNagAAAABJRU5ErkJggg==",
      "behaviors": [
        {
          "uid": "behavior_4",
          "title": "API: Create Coupon",
          "is_disabled": false,
          "is_private": false,
          "priority": 50,
          "event": {
            "key": "event.macro.bot",
            "label": "Custom behavior on bot"
          },
          "variables": {
            "var_customer_id": {
              "key": "var_customer_id",
              "label": "coupon_code",
              "type": "S",
              "is_private": "0",
              "params": {
                "widget": "single"
              }
            },
            "var_duration": {
              "key": "var_duration",
              "label": "duration",
              "type": "D",
              "is_private": "0",
              "params": {
                "options": "forever\r\nonce"
              }
            },
            "var_percent_off": {
              "key": "var_percent_off",
              "label": "percent_off",
              "type": "N",
              "is_private": "0",
              "params": []
            },
            "var_redeem_by": {
              "key": "var_redeem_by",
              "label": "redeem_by",
              "type": "E",
              "is_private": "0",
              "params": []
            }
          },
          "nodes": [
            {
              "type": "action",
              "title": "Execute HTTP Request",
              "status": "live",
              "params": {
                "actions": [
                  {
                    "action": "core.va.action.http_request",
                    "http_verb": "post",
                    "http_url": "https://api.stripe.com/v1/coupons",
                    "http_headers": "",
                    "http_body": "id={{var_customer_id}}&duration={{var_duration}}&percent_off={{var_percent_off}}{% if var_redeem_by %}&redeem_by={{var_redeem_by}}{% endif %}",
                    "auth": "connected_account",
                    "auth_connected_account_id": "{{{stripe_account_id}}}",
                    "options": {
                      "raw_response_body": "1"
                    },
                    "run_in_simulator": "1",
                    "response_placeholder": "_http_response"
                  }
                ]
              }
            }
          ]
        },
        {
          "uid": "behavior_2",
          "title": "API: Get Balance",
          "is_disabled": false,
          "is_private": false,
          "priority": 50,
          "event": {
            "key": "event.macro.bot",
            "label": "Custom behavior on bot"
          },
          "nodes": [
            {
              "type": "action",
              "title": "Execute HTTP Request",
              "status": "live",
              "params": {
                "actions": [
                  {
                    "action": "core.va.action.http_request",
                    "http_verb": "get",
                    "http_url": "https://api.stripe.com/v1/balance",
                    "http_headers": "",
                    "http_body": "",
                    "auth": "connected_account",
                    "auth_connected_account_id": "{{{stripe_account_id}}}",
                    "options": {
                      "raw_response_body": "1"
                    },
                    "run_in_simulator": "1",
                    "response_placeholder": "_http_response"
                  }
                ]
              }
            }
          ]
        },
        {
          "uid": "behavior_3",
          "title": "API: List Charges",
          "is_disabled": false,
          "is_private": false,
          "priority": 50,
          "event": {
            "key": "event.macro.bot",
            "label": "Custom behavior on bot"
          },
          "variables": {
            "var_customer_id": {
              "key": "var_customer_id",
              "label": "customer_id",
              "type": "S",
              "is_private": "0",
              "params": {
                "widget": "single"
              }
            },
            "var_limit": {
              "key": "var_limit",
              "label": "limit",
              "type": "N",
              "is_private": "0",
              "params": []
            },
            "var_created_at": {
              "key": "var_created_at",
              "label": "created_at",
              "type": "E",
              "is_private": "0",
              "params": []
            }
          },
          "nodes": [
            {
              "type": "action",
              "title": "Execute HTTP Request",
              "status": "live",
              "params": {
                "actions": [
                  {
                    "action": "core.va.action.http_request",
                    "http_verb": "get",
                    "http_url": "https://api.stripe.com/v1/charges?limit={{var_limit|default(10)}}{% if customer_id %}&customer={{var_customer_id}}{% endif %}{%if created_at %}&created={{var_created_at}}{% endif %}",
                    "http_headers": "",
                    "http_body": "",
                    "auth": "connected_account",
                    "auth_connected_account_id": "{{{stripe_account_id}}}",
                    "options": {
                      "raw_response_body": "1"
                    },
                    "run_in_simulator": "1",
                    "response_placeholder": "_http_response"
                  }
                ]
              }
            }
          ]
        }
      ]
    }
  ]
}


Click the Import button.

You’ll be prompted to link the Stripe connected account you created earlier.

Click the Import button again.

You should see the following:

Test the integration behaviors

Click on Stripe Bot and then click Behaviors on its card.

Open the card for the API: Create Coupon behavior.

Click on the Simulator button at the top of the card.

Click the Simulate button.

You should see a JSON response saying the coupon was created.

You can use the simulator on the other behaviors to test them as well.

Next steps

At this point you can modify the behaviors to meet your needs. You can use the responses from Stripe’s API in your behaviors.