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
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"
)
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.
generic_trial?(customer)
Returns whether the customer is on a generic trial.
Checks the trial_ends_at
column on the customer.
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")
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")
subscriptions(customer)
Fetches all subscriptions for a customer.
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")