The _rental_intent_token is a custom property attached to Shopify order line items that contains crucial information about rental intents in Supercycle. This document explains the structure and purpose of this property. If an item doesn’t have a rental_intent_token Supercycle will not process that item.


Overview

The _rental_intent_token is a JSON serialized token that contains all necessary information to create a rental when a customer purchases an item. This token is generated when customers select rental options in the storefront and is processed when orders are fulfilled.


Common Attributes

A typical _rental_intent_token contains the following attributes:

AttributeTypeDescription
variant_idIntegerID of the variant being rented
available_item_countIntegerNumber of items available for rental
scheduleObjectContains timing information for the rental
purchase_typeStringClass name of the purchase type:
CalendarRental::Purchase, MembershipRental::Purchase, SubscriptionRental::Purchase, Resale::Purchase
purchase_attributesObjectAttributes specific to the purchase type
location_idIntegerOptional ID of the location for fulfillment

Schedule Object

The schedule object contains timing information for the rental lifecycle:

AttributeTypeDescription
prepare_fromISO DateWhen the items reservation will start
fulfill_atISO DateWhen the rental should be fulfilled
rental_startISO DateWhen the rental period begins
rental_endISO DateWhen the rental period ends
receive_atISO DateWhen the item should be received back
restock_byISO DateWhen the items reservation will end
minimum_rental_endISO DateMinimum date for rental end

Rental Method-Specific Attributes

Membership Rental

AttributeTypeDescription
credit_costIntegerNumber of credits required for rental

Calendar Rental

AttributeTypeDescription
selling_plan_idIntegerID of the selling plan associated with rental

Subscription Rental

AttributeTypeDescription
selling_plan_idIntegerID of the subscription selling plan
deposit_variant_idIntegerOptional ID of the deposit variant
create_subscription_contractIntegerOptional ID of selling plan to create contract

How It’s Used

  • Generation: The token is generated when a customer selects rental options in the storefront.
  • Storage: The token is attached to the line item as a custom property named _rental_intent_token.
  • Processing: When an order is processed, the Supercycle decodes the token and creates rentals based on the information it contains.

Rental Creation

The token provides all necessary information to:

  • Select available items
  • Set up the rental schedule
  • Create the appropriate purchase records
  • Handle deposits if required
  • Set up subscriptions if applicable

Code Example

Here’s how a typical _rental_intent_token might look:

{
  "variant_id": 12345,
  "available_item_count": 3,
  "schedule": {
    "fulfill_at": "2023-12-01T12:00:00Z",
    "rental_start": "2023-12-03T12:00:00Z",
    "rental_end": "2023-12-10T12:00:00Z",
    "receive_at": "2023-12-12T12:00:00Z",
    "restock_by": "2023-12-14T12:00:00Z"
  },
  "location_id": 42,
  "purchase_type": "CalendarRental::Purchase",
  "purchase_attributes": {
    "arrival_date": "2023-12-03",
    "return_date": "2023-12-10"
  },
  "selling_plan_id": 789
}