Integrating with Purchases

SureCart abstracts away many of the complexities of integrating with a purchase. This is done by extending our integration PHP class and providing the necessary functionality for a purchase's life-cycle events. A purchase's lifecycle events include created, invoked and revoked.

Why do we use a "Purchase"?

We abstract away many of the complexities that can come with integrating with an e-commerce platform. Instead of needing to keep track of subscription changes, refunds, and any other types of actions that can affect "access" to a purchase, we abstract them to a [Purchase] model.

In short, you do not need to know or even understand how the entire SureCart system works. Instead, you can use a declarative approach and declare what you want to do when a purchase is created, invoked, or revoked.

When is a purchase "created"?

A purchase is created the first time a customer completes an order, or when a person upgrades or downgrades a subscription.

When is a purchase "revoked"?

A purchase can be revoked either manually by the Merchant or automatically. A purchase can be manually revoked if it is a one-time purchase. The merchant will see a "Revoke" button next to the purchase in the Merchant's admin panel.

A purchase can also be automatically revoked. This can happen when a subscription is canceled or expired, but it can also occur when a customer changes their subscription plan, through an upgrade or downgrade, for instance. While a new purchase will be created, the old purchase will be revoked.

πŸ“˜

While Merchants can manually revoke access to a one-time product purchase, they cannot manually revoke a purchase that is tied to a subscription. Instead, they must cancel the subscription, which will then revoke the purchase.

This is a safeguard to prevent a subscription from running without giving a customer access to something.

When is a purchase "invoked"?

A purchase is 'invoked' when a purchase has been previously revoked and then un-revoked. This is useful when a merchant wants to trigger a specific action when a purchase is reinstated, but not necessarily when it is first created.

A great example of this is a welcome email. Typically, you only want to send a welcome email the first time someone purchases a product, not when it is reinstated after being revoked.

πŸ“˜

Merchants cannot manually invoke a purchase tied to a canceled subscription. Instead, they must have the customer make a new purchase to create a new subscription.