Bling.Paddle.Customers (bling_paddle v0.2.0)

Link to this section Summary

Functions

Returns a payment link for a subscription to be redirected to or used in the Paddle widget.

Generate a Paddle payment link.

Returns whether the customer is on a generic trial.

Returns whether or not the customer is subscribed, and that it is valid.

Fetches a single subscription for a customer by subscription name.

Fetches all subscriptions for a customer.

Returns true if the customer is on a generic trial or if the specified subscription is on a trial.

Link to this section Functions

Link to this function

create_subscription(customer, opts)

Returns a payment link for a subscription to be redirected to or used in the Paddle widget.

You can pass any valid parameter the Paddle api is expecting as a keyword option:

https://developer.paddle.com/api-reference/3f031a63f6bae-generate-pay-link

examples

Examples

# simple
url = create_subscription(
  customer,
  product_id: "abcd"
)

# multiple subscriptions
url = create_subscription(
  customer,
  name: "swimming",
  product_id: "abcd"
)

# extra api options
url = create_subscription(
  customer,
  product_id: "abcd",
  trial_days: 10,
  coupon_code: "something"
)
Link to this function

generate_pay_link(customer, opts)

Generate a Paddle payment link.

If you are wanting to create a subscription, use Bling.Paddle.Customers.create_subscription/2 instead to ensure the proper passthrough parameters are being set.

You can pass any valid parameter the Paddle api is expecting as a keyword option:

https://developer.paddle.com/api-reference/3f031a63f6bae-generate-pay-link

Uses email, country, and postcode keys from map returned in your MyApp.Bling.paddle_customer_info(customer) function.

Link to this function

generic_trial?(customer)

Returns whether the customer is on a generic trial.

Checks the trial_ends_at column on the customer.

Link to this function

subscribed?(customer, opts \\ [])

Returns whether or not the customer is subscribed, and that it is valid.

examples

Examples

# checks if the customer is subscribed to the default subscription
Bling.Paddle.Customers.subscribed?(customer)

# checks if the customer is subscribed to a specific subscription
Bling.Paddle.Customers.subscribed?(customer, name: "pro")
Link to this function

subscription(customer, opts \\ [])

Fetches a single subscription for a customer by subscription name.

examples

Examples

# gets subscription with name "default"
subscription = Bling.Paddle.Customers.subscription(customer)

# gets subscription with specific name
subscription = Bling.Paddle.Customers.subscription(customer, name: "pro")
Link to this function

subscriptions(customer)

Fetches all subscriptions for a customer.

Link to this function

trial?(customer, opts \\ [])

Returns true if the customer is on a generic trial or if the specified subscription is on a trial.

examples

Examples

# checks trial_ends_at on customer and "default" subscription
Bling.Paddle.Customers.trial?(customer)

# checks trial_ends_at on customer and "swimming" subscription
Bling.Paddle.Customers.trial?(customer, name: "swimming")