Detailed guidance on how to integrate Corrily with a payment gateway.
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.
If you have granted Corrily automated access to your payment gateway’s webhook events, as explained in the previous section, you can stop here.
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.
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.
See the following docs for more guidance on building a webhook server for your particular payment gateway:
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:
The following sections detail which events you need to handle, depending on your payment gateway.
Braintree::WebhookNotification::Kind::SubscriptionCanceled
Braintree::WebhookNotification::Kind::SubscriptionExpired
Braintree::WebhookNotification::Kind::SubscriptionTrialEnded
Braintree::WebhookNotification::Kind::SubscriptionWentActive
Braintree::WebhookNotification::Kind::SubscriptionWentPastDue
Use Corrily’s Create subscription and Update subscription REST API endpoints to send the data from your webhook server to Corrily.
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.
The following tables explain how to map your payment gateways status values to Corrily’s values.
Stripe’s value | Corrily’s value |
---|---|
incomplete | pending |
incomplete_expired | pending |
trialing | trialing |
active | active |
past_due | active |
canceled | canceled |
unpaid | canceled |
Chargebee’s value | Corrily’s value |
---|---|
future | pending |
in_trial | trialing |
active | active |
non_renewing | canceled |
paused | canceled |
canceled | canceled |
Chargebee’s value | Corrily’s value |
---|---|
future | pending |
in_trial | trialing |
active | active |
expired | canceled |
canceled | canceled |
Braintree’s value | Corrily’s value |
---|---|
Active | active |
Canceled | canceled |
Expired | canceled |
PastDue | active |
Pending | pending |
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 refers to one-time charge events as invoice events.
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.
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.
Braintree::WebhookNotification::Kind::SubscriptionChargedSuccessfully
Braintree::WebhookNotification::Kind::SubscriptionChargedUnsuccessfully
Use Corrily’s Create charge and Update charge REST API endpoints to send the invoice data from your webhook server to Corrily.
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.
The following tables explain how to map your payment gateways status values to Corrily’s values.
Stipe’s value | Corrily’s value |
---|---|
draft | pending |
open | pending |
paid | succeeded |
uncollectible | failed |
void | failed |
Chargebee’s value | Corrily’s value |
---|---|
in_progress | pending |
success | succeeded |
voided | failed |
failure | failed |
timeout | failed |
needs_attention | failed |
Recurly’s value | Corrily’s value |
---|---|
pending | pending |
processing | pending |
success | succeeded |
chargeback | succeeded |
error | failed |
declined | failed |
Braintree’s value | Corrily’s value |
---|---|
Braintree::WebhookNotification::Kind::SubscriptionChargedSuccessfully | succeeded |
Braintree::WebhookNotification::Kind::SubscriptionChargedUnsuccessfully | failed |