Skip to main content

API Quick-start Documentation

Basic API Documentation for WeeConnectPay, used mostly by new integration.

Updated over 6 months ago

References



Clover Glossary

Clover Resources

UUID

The UUID is a 13 character alphanumerical string with letters in all caps that represents the resource internally with Clover for Merchant, Employee, App, Order, Item, Tax, Payment, Refund, etc.

Clover has a tendency to mix IDs and UUIDs and call them both IDs in their own interface and documentation.

Merchants have both a Clover Merchant UUID (13 character alphanumerical) and a Clover Merchant ID (20* digits). Clover calls both of these "Merchant ID".

For the sake of the clarity of this documentation, for the UUID we will always be refering to the 13 digit alphanumerical values unless explicitly specified.

Clover Employee

In the scope of this documentation, the Clover Employee is the logged in user. A Clover Employee is a resource with a relation to the Merchant being worked with.

It can be the merchant Owner or one of its admins, it still remains a Clover Employee resource.

Clover Merchant

In the scope of this documentation, the Clover Merchant is the resource representing a business or franchise within Clover. Some businesses have a single Clover Merchant set up for multiple locations and some have individual Clover Merchants set up for each location.

The Merchant is not the primary resource that represents a user. A user(Clover Employee) has privilege levels to a merchant (such as employee, admin or owner – and the permissions inside can be edited) but is never permanently linked to it. The owner can change, the employee can get fired and kicked out. Employees can also have certain permissions revoked. This can lead to situations where an API key is invalidated. Plan accordingly.


Clover Documentation

Clover App

In the scope of this documentation, the Clover App is what an integration type (such as WooCommerce) will use to act on behalf of the Clover Merchant.

Each integrator has their own App.

The Clover Merchant must authorize the permissions asked for by the Clover App in order for the Clover App to act on their behalf. Should the app be uninstalled through the Clover Market, all API keys will be invalidated.

Clover PAKMS Key Public

In the scope of this documentation, the Clover PAKMS key represents the public key to use in the front-end to tokenize the credit card. This key does not represent a session. It represents a relation between 2 models:

  • A Clover App

  • A Clover Merchant

The key will always stay the same for each set of Clover App + Clover Merchant within an environment.

Clover API Key Private/Secret

In the scope of this documentation, the Clover API Key represents a session (valid or not) with some contextual data.

  • A Clover App

  • A Clover Merchant

  • A Clover Employee

An API key is given at the end of the user authentication and the previous key for the same set of Clover App + Clover Merchant + Clover Employee is instantly invalidated.

Since the authentication is done through WeeConnectPay, we take care of creating the API keys and soft-deleting/invalidating the old API keys as they are generated. This means that as long as you use our API, you will not have to worry about keeping track of which Clover API key is active, it will simply use the active one every time.

This key should never be exposed.

Every time a call to the Clover API is made, the authorization for each of the related models is verified.

Clover API Rate Limiting

Rate limits

Rate limits are set for the number of new API requests your apps can make per second.

Level

Per-second rate limit

Per app

50

Per token / API Key

16

Concurrent rate limits

In addition to rate limiting, we maintain concurrent rate limiting to better control multiple retry requests to CPU-intensive API endpoints. Concurrent rate limits are set for the number of in-progress API requests your apps can make at the same time.

Level

Concurrent rate limit

Per app

10

Per token / API Key

5

For instance, if the concurrent rate limit has been set to five, you can make up to five running API requests at the same time. While the server is responding to these five requests, a sixth request will return to a 429 HTTP Too Many Requests error message.

Those rate limits can be increased through us with a request to Clover.

The rate limits for API Keys manually generated in the Clover Merchant dashboard are MUCH lower than what is documented.


Clover Order

In the scope of this documentation, the Clover Order is a resource that represents an order. The order is left in an “open” status until it is either paid, partially paid(unsupported in ecommerce), refunded, partially refunded or cancelled/closed.

The Clover Order belongs to the Clover Merchant. It also is related to the Clover Employee that entered it, but any Clover Employee with sufficient rights can pay or refund it as long as they have access to those permissions within the merchant it belongs to.

A Clover order can have zero or more items.

There is a new way to make orders that gives us a lot more flexibility, including custom tax support that is one of our priorities on our road map.

Clover Item

In the scope of this documentation, the Clover Item is an item with a set quantity, price per unit. Clover Items can be used from the Clover Merchant’s inventory by using the Clover Item UUID, or the UUID can be left blank and a UUID will be given to it and it will be considered a custom item.

Clover Tax Rate

In the scope of this documentation, the Clover Tax is a set tax predefined in the Clover Merchant dashboard (or added through the API). It can be left blank on orders to set it as “tax included” or defined by a Clover Tax Rate UUID, a Tax Rate Amount + Tax Rate Name or Tax Rate Percentage + Tax Rate Name.

The Tax Rate UUID and the combinations of Tax Rate Amount/Percentage + Tax Rate Name need to match a Tax Rate that already exists in the Clover Merchant account before using them

There has been quite a lot of changes over the year related to taxes. The previous limitations for ecommerce that need to support dynamic taxes led us to create our items with tax included in our current integrations. This is something on our priority list.

Clover Payment

In the scope of this documentation, the Clover Payment is the resource that represents a payment to a Clover Order.

Clover Refund

Clover Refunds are a way to partially or totally refund a Clover Payment.

Payments are refundable, but it will not reflect on the invoice what was refunded if done this way. Should you want to have a returned item reflected for the merchant, you should instead use Clover Returns by returning items being refunded.

Clover Return

Clover Returns is very similar to Clover Refund. It does not seem to have its own model within the Clover Model structure as it creates a Clover Refund. The key difference here is that a Clover Return is linked to a Clover Order instead of a Clover Payment like the Clover Refund normally is.

This means that, when using the Clover Return, the Clover Order will know and will display to the customer and merchant which item was refunded.

There is currently a bug in the Clover API preventing partial refunds of single items. We are closely working with the Clover engineering team to get this sorted fast.


Clover Environments

SANDBOX

Used for testing, development and anything that is not ready for production.

PRODUCTION

  • Used for live production.

  • All transactions are real


WeeConnectPay Glossary

Integration

An integration is the central model used to connect WeeConnectPay to an external service. It allows to preserve the Clover relational context using a unique ID (UUIDv4 format).

Each integration has a type and a back-end. Those 2 relations are polymorphic to their own tables. For example; the WooCommerce integrations have an integration type of woocommerce and an integration back-end of wordpress.

In the scope of this documentation, when we refer to an integration, we do not mean the integration type, but rather the individual unique integration represented by a UUID (IE: A single WooCommerce instance on a specific website).

We will work with integrators to add the tables for their own integration type and integration back-end to allow WeeConnectPay to find or create unique integrations when pre-authenticating.

WeeConnectPay API Key - JWT

Our API Key is a JWT. We do not store the API Key for security reason, we can only generate and validate them. The JWT has custom claims that shows what it represents :

  • Clover Merchant UUID

  • Clover App UUID

  • Clover Employee UUID

  • WeeConnectPay Integration UUID

If there is a reasonable need for it that cannot be satisfied otherwise, more JWT custom claims could be added for integrators.

This key should never be exposed as it allows the full range of permissions of the authorized Clover App over the Clover Merchant it represents.

Each API Call done to our API on authenticated endpoints will automatically use the context of the data in the JWT to interact with our models and the Clover API for the requested actions if there is any.


WeeConnectPay Environments

DEV

  • Has its own Clover App in the Clover Sandbox environment

  • We will also create an app for integrators

  • Connects to a local dev specific app that we can customize for various local tests

  • The callback URL for Oauth2 is set to a local project

    • Every WeeConnectPay developer has this project pointing at the same URL with their hosts file

STAGING

  • Has its own Clover App in the Clover Sandbox environment

  • We will also create an app for integrators

  • Connect to an app that reflects 1:1 the production app

PRODUCTION

  • Has its own Clover App in the Clover Production environment

  • All transactions are real



Onboarding

Partner Onboarding

Mostly for use by WeeConnectPay.

  1. Merchant creation in sandbox

  2. App creation in sandbox for Dev

  3. App creation in sandbox for Staging

  4. Need the emails of each dev that will be used to log in to add them as admin employee to that sandbox merchant.

Merchant Authentication

Overview

WeeConnectPay currently only authenticates integrations of the WooCommerce type. However, we build the API in a way that allows it to support all types of integrations with very few changes.

Integration

The terms we will be referring to here are Integration type which is the platform being integrated. In our examples it will be WooCommerce. When we mention an Integration we really refer to the unique instance of WooCommerce we are using the API with. In other words, a single online ecommerce shop.

That chart shows the Pre-authentication and Authentication for WooCommerce

Step 1: Pre-authentication

Every integration has its own Integration ID with WeeConnectPay. An Integration ID is a UUIDv4 value that represents a unique instance of an Integration. To authenticate with WeeConnectPay, you need an Integration ID for each unique instance you are authenticating with.

The one thing that will change here for upcoming integrations is the unique values that determine what is a unique instance of an Integration. For WooCommerce it is the wpdb and site_url values of the wordpress instance hosting the WooCommerce being worked with.

For WooCommerce, this logic happens when activating the plugin, as well as when the authentication page is loaded.

This allows us to validate that the authentication is still valid or has not expired.

Step 2: Actual authentication

We use OAuth2 with Clover to authenticate merchants. The authentication flow is as follows.

What it looks like to the Clover Employee?

  1. Login button clicked

  2. The user is redirected to Clover Login screen and logs in with their credentials

If the browser does not already have a valid active session in the specific Clover Environment

  1. If the Clover Employee has more than 1 merchant, it will ask them to select the one they are authenticating with, otherwise the Clover Employee will not see this step

  2. If the Clover Merchant has not yet authorized the Clover App, they will be asked to do so

Only a merchant Admin can authorize a Clover App to act on their behalf. We have no way to check for permissions at this point as the Clover Employee is not done authenticating.

  1. If the Clover Merchant has not yet installed the app, they will be prompted to select the app subscription in the Clover App Market

  2. The user is redirected to the integration they first started the authentication with and it shows them logged in

What it actually is?

  • Preauthentication data already has happened at this point. It means that WeeConnectPay already knows where to redirect a user once they finish authenticating using the Integration ID

  • Login link to WeeConnectPay clicked

Context data (including Integration ID) is passed as a URL query in the link.

  • Clover OAuth2 URL is built based on the context and data passed to the earlier link

  • The user is redirected to the built URL

  • The user is now on Clovers login screen and logs in with their credentials

If the browser does not already have a valid active session in the specific Clover Environment.

  • If the Clover Employee has more than 1 merchant, it will ask them to select the one they are authenticating with, otherwise the Clover Employee will not see this step

  • If the Clover Merchant has not yet authorized the Clover App, they will be asked to do so

Only a merchant Admin can authorize a Clover App to act on their behalf. We have no way to check for permissions at this point as the Clover Employee is not done authenticating.

  • Once the merchant has been selected the OAuth2 flow continues by using the callback with the contextual data we built at the beginning


URL query parameters

By default Clover Employee has only one Clover Merchant or the Clover Merchant UUID was passed as a parameter or by user interaction.

  • WeeConnectPay receives the Callback with the URL query parameters for the Clover Merchant UUID, Clover Employee UUID, Clover App (called client) UUID, OAuth2 code and Integration ID passed earlier to know the unique integration this came from

  • WeeConnectPay uses this information to finish authenticating the Clover Employee using the OAuth2 flow

We obtain a Clover API token valid for 1 year with this.

We will make the switch to refresh token eventually.

  • WeeConnectPay then does API calls using the Clover API key to gather the appropriate data needed for processing orders, payments, etc.

This builds all the Clover relational data needed to work with the Clover API using only the Integration ID.

  • WeeConnectPay sends a hash to a specific endpoint to let the Integration know that they have finished authenticating and can request the authentication data, including the API key using that hash

  • The Integration makes an API call to the WeeConnectPay API with the hash to finish authenticating

  • WeeConnectPay answers with the data required for the Integration and this data can be customized for the integrator's needs

The most important part here is the WeeConnectPay API key. A JWT token that contains custom claims that identify the token as belonging to a specific merchant, employee, app and integration id.

  • The user is redirected to the (now logged in) Integration


Authentication Notes

  • A Merchant UUID can be passed to the authentication link in order to pre-select the merchant for the Clover Employee

This can help prevent user errors during re-authentications.

  • If the browser the Oauth2 is being done on has a currently active session with Clover, it will not ask them to log in, it will simply select this employee

  • Data can be passed as URL parameters during the entire Oauth2 flow (we use the Integration ID like this)

Please let us know if you would like to pass more information from the beginning of the flow to the callback at the end. We can customize the call for your integration type to allow for specific values to be passed.

This means that the following values become relational to the logged in user

  • Clover Merchant UUID

  • Clover Employee UUID

  • Clover App UUID

  • WeeConnectPay Integration UUID

That schema explain the WooConnectPay backend relations used for integration

Merchant Authorization

During the authentication

  • To prevent hijacking of integrations, if an integration has successfully logged in through OAuth2 once, the integration will be bound to that merchant

The employee logging in can change, but only the merchant that has logged in can log in the integration afterwards.

  • Other than a few cases of multi-merchant human errors, this has not caused any issue yet

We have a procedure in place to unlink the relationship between the integration and the merchant to let another merchant log in if it is a human error. For example. the Clover Employee logged his West Edmonton location on the Calgary website by mistake.

The rest of the time

Since we do not store a lot of data other than the Clover UUIDs required for linking data during API calls to Clover, a lot of the Authorization is done by the Clover Merchant on the Clover Dashboard.

From there, they can decide who is allowed to do what. Since there is a lot of granularity here, we opted for simplicity and do the API calls to Clover and rely on Clover to tell us if a call is unauthorized. If it is the case, it will be logged using Sentry and we can tackle the issue as it comes up.

Should there be any scenario you can reproduce in the sandbox where this is problematic, we will be happy to adapt. Sentry is also set up for the sandbox environment for testing purposes.

We store the read and write permissions for the Clover API keys and as such can be used to expand the current authorization protocols should there be any need. See https://weeconnectpay.atlassian.net/wiki/spaces/WCP/pages/261816325

  • Since we also store the Clover Merchant ID, Clover Employee ID, Clover App ID and WeeConnectPay Integration ID in the JWT as secure and verifiable JWT custom claims, they can also be used to expand the current authorization protocols should there be any need.

  • We can also easily add other custom claims of your liking to the JWT to allow authorization on the integration side. The JWT / API Key can be validated at any time against our validation endpoint.

Card-Not-Present/Ecommerce Order Overview

This section reflects the WooCommerce type integration. WooCommerce has its own way of doing things and is highly customizable. As such, by doing an integration in your own systems, a lot of this information may not be relevant. I will do my best to highlight the bare minimum that always apply regardless of the integration type.

The current implementation of WooCommerce does the checkout process in 3 steps:

  • Clover Customer Creation

  • Clover Order Creation

  • Clover Payment Creation

Each subsequent step uses IDs from the previous one. IE: A Clover Order is created with a Clover Customer UUID, a Clover Payment is created with the resulting Clover Order UUID we receive from creating it and a tokenized card.

Clover Customer Creation

Minimum requirements:

  • An email address (string)

A Clover Customer UUID will be received when creating one.

There is little incentive to keeping track of Clover Customers as Clover will automatically merge customers on their end to keep a relevant customer purchase history, even if they change email or change credit card. The important part here is to have the Clover Customer UUID ready when creating the Clover Order.

Clover Order Creation

Minimum requirements:

  • An email address, or a Clover Customer UUID that represents a Clover Customer, which must have an email address assigned to it. (string)

  • The currency the order is in; (string)

Conditional requirements:

  • If there is items added to it each item object must contain

    • An item amount (int64)

Due to limitations of the Clover API when we built WeeConnectPay for WooCommerce, each item is set to the amount of 1. This was a workaround for a previous lack of support for dynamic taxes. This has changed and is not recommended for any future integration as this workaround is no longer needed. Please talk to our lead developer about more information regarding this previous design choice. It is well documented internally.

  • If the order is being shipped / there is shipping information

    • A city – Can include district, suburb, town, or village. (string)

    • Address line 1 – Can include the street address, PO box, or company name. (string)

    • Postal Code – Postal or ZIP code of the customer's address. (string)

    • State – Can include county, province, or region. (string)

    • Name – Name of the customer (string)

Clover Payment(Charge) Creation

Minimum requirements:

  • Amount (int64) – Charge amount in cents. If the charge request includes tax, this value must be the sum of any item prices and any tax or tip.
    For example, if the item cost = $10 and the tax is $1, the amount is 1100 cents ($11).
    Format: cents

  • The currency the payment is in; (string)

  • Source – Payment source to charge, such as a tokenized card or an alternate tender (string)

Did this answer your question?