The easiest and recommended way to notify Corrily of subscription and charge events is to grant Corrily automated access to your payment gateway’s webhook events. Email api@corrily.com to get started.

If you’re using Stripe and would like to get your Corrily integration started now, click the Connect with Stripe button to grant Corrily read-only access to your Stripe subscription and charge events.

If for whatever reason you cannot or do not want to grant Corrily automated access, you can manually notify Corrily instead.

Manually notify Corrily of subscription and charge events

Only required when automated access is not an option

If you have granted Corrily automated access to your payment gateway’s webhook events, as explained in the previous section, you can stop here.

“Charge” events is a generic term in this guide

In this guide we use the word “charge” to refer to a non-recurring payment. Different payment gateways use different words for this concept. When reading your payment gateway’s documentation, “charge” may not be the word you’re looking for.

The basic workflow

  • You set up your own webhook server
  • Your webhook server receives subscription and charge events from your payment gateway
  • Your webhook server extracts only the data that Corrily needs and sends it to Corrily via the subscription and charge REST API endpoints

Corrily needs to be notified of subscription AND charge events

Corrily needs to know about charge events because charge events are much closer to realized revenue than subscription events. In other words, charges are more like a realized commitment to pay, whereas subscription events are more like an intent to pay. Getting both signals helps Corrily’s AI models provide more optimal prices for you.

Build a webhook server

See the following docs for more guidance on building a webhook server for your particular payment gateway:

Stripe

Chargebee

Recurly

Braintree

Handle subscription events

Payment gateways emit webhook events over the entire subscription lifecycle. Keeping Corrily up-to-date on important events helps Corrily determine optimal prices for your customers. Examples of important events include:

  • Signing up for a trial
  • Converting to a paying customer
  • Switching to a higher or lower price
  • Canceling a subscription

The following sections detail which events you need to handle, depending on your payment gateway.

Stripe

Chargebee

Recurly

Braintree

Send subscription data to Corrily

Use Corrily’s Create subscription and Update subscription REST API endpoints to send the data from your webhook server to Corrily.

Handle subscription discounts

If you are providing a discount to a user, you should send Corrily the price that the user paid. You should not try to represent the discount with multiple calls to the Corrily API.

Map your payment gateway’s subscription statuses to Corrily’s values

The following tables explain how to map your payment gateways status values to Corrily’s values.

Stripe
Stripe’s valueCorrily’s value
incompletepending
incomplete_expiredpending
trialingtrialing
activeactive
past_dueactive
canceledcanceled
unpaidcanceled
Chargebee
Chargebee’s valueCorrily’s value
futurepending
in_trial trialing
activeactive
non_renewingcanceled
pausedcanceled
canceledcanceled
Recurly
Chargebee’s valueCorrily’s value
futurepending
in_trial trialing
activeactive
expiredcanceled
canceledcanceled

Braintree

Braintree’s valueCorrily’s value
Activeactive
Canceledcanceled
Expiredcanceled
PastDueactive
Pendingpending

Handle charge events

Keeping Corrily up-to-date on important charge events helps Corrily confirm that the price it generated for a visitor was optimal. For example, a new subscription is a slight signal that a price was optimal. When the customer allows their card to be charged for the subscription, that’s further confirmation that the price was optimal.

The following sections detail which charge events you need to handle, depending on your payment gateway.

Stripe

Stripe refers to one-time charge events as invoice events.

Why not use Stripe charges instead?

Stripe invoice events are closer to payments for individual subscriptions than Stripe charges are. In Stripe, charges pay for invoices which may contain payments for more than just a single subscription. If however it’s easier for you to handle charges, you can also look to handle Stripe’s charge.captured, charge.refunded, charge.updated, and charge.succeeded events.

Chargebee

On payment events (which pay for subscriptions) Chargebee sends your webhook server transaction, customer, and subscription objects. The transaction object contains the amount that was paid (or refunded, depending on the transaction type). The transaction object contains the data that needs to be passed to Corrily.

Recurly

Braintree

Send charge data to Corrily

Use Corrily’s Create charge and Update charge REST API endpoints to send the invoice data from your webhook server to Corrily.

Handle charge discounts

If you are providing a discount to a user, you should send Corrily the price that the user paid. You should not try to represent the discount with multiple calls to the Corrily API.

Map your payment gateway’s charge statuses to Corrily’s values

The following tables explain how to map your payment gateways status values to Corrily’s values.

Stripe
Stipe’s valueCorrily’s value
draftpending
openpending
paidsucceeded
uncollectiblefailed
voidfailed
Chargebee
Chargebee’s valueCorrily’s value
in_progresspending
successsucceeded
voidedfailed
failurefailed
timeoutfailed
needs_attentionfailed
Recurly
Recurly’s valueCorrily’s value
pendingpending
processingpending
successsucceeded
chargebacksucceeded
errorfailed
declinedfailed
Braintree
Braintree’s valueCorrily’s value
Braintree::WebhookNotification::Kind::SubscriptionChargedSuccessfullysucceeded
Braintree::WebhookNotification::Kind::SubscriptionChargedUnsuccessfullyfailed