Skip to content

Latest commit

 

History

History
executable file
·
148 lines (103 loc) · 3.38 KB

README.md

File metadata and controls

executable file
·
148 lines (103 loc) · 3.38 KB

coupon

Overview

The Coupon resource represents a discount that can be applied to a customer's invoice. Coupons can be applied to a customer's invoice either by the customer or by the Orb API.

Available Operations

archive

This endpoint allows a coupon to be archived. Archived coupons can no longer be redeemed, and will be hidden from lists of active coupons. Additionally, once a coupon is archived, its redemption code can be reused for a different coupon.

Example Usage

import orb
from orb.models import operations

s = orb.Orb(
    security=shared.Security(
        api_key_auth="",
    ),
)


res = s.coupon.archive('quod')

if res.coupon is not None:
    # handle response

create

This endpoint allows the creation of coupons, which can then be redeemed at subscription creation or plan change.

Example Usage

import orb
from orb.models import shared

s = orb.Orb(
    security=shared.Security(
        api_key_auth="",
    ),
)

req = shared.CouponInput(
    discount=shared.Discount(
        amount_discount='quod',
        applies_to_price_ids=[
            'totam',
            'porro',
        ],
        discount_type=shared.DiscountType.PERCENTAGE,
        percentage_discount=0.15,
        trial_amount_discount='dolorum',
        usage_discount=1182.74,
    ),
    duration_in_months=720633,
    id='a928fc81-6742-4cb7-b920-5929396fea75',
    max_redemptions=613064,
    redemption_code='iure',
    times_redeemed=902349,
)

res = s.coupon.create(req)

if res.status_code == 200:
    # handle response

fetch

This endpoint retrieves a coupon by its ID. To fetch coupons by their redemption code, use the List coupons endpoint with the redemption_code parameter.

Example Usage

import orb
from orb.models import operations

s = orb.Orb(
    security=shared.Security(
        api_key_auth="",
    ),
)


res = s.coupon.fetch('quidem')

if res.coupon is not None:
    # handle response

list

This endpoint returns a list of all coupons for an account in a list format.

The list of coupons is ordered starting from the most recently created coupon. The response also includes pagination_metadata, which lets the caller retrieve the next page of results if they exist. More information about pagination can be found in the Pagination-metadata schema.

Example Usage

import orb
from orb.models import operations

s = orb.Orb(
    security=shared.Security(
        api_key_auth="",
    ),
)


res = s.coupon.list('architecto', False)

if res.coupons is not None:
    # handle response

list_subscriptions

This endpoint returns a list of all subscriptions that have redeemed a given coupon as a paginated list, ordered starting from the most recently created subscription. For a full discussion of the subscription resource, see Subscription.

Example Usage

import orb
from orb.models import operations

s = orb.Orb(
    security=shared.Security(
        api_key_auth="",
    ),
)


res = s.coupon.list_subscriptions('ipsa')

if res.subscriptions is not None:
    # handle response