(discounts)
Work with discounts.
Discounts - Paddle Developer Center https://paddle.stoplight.io/docs/next-gen-billing/entities/discounts
Creates a new discount.
If successful, your response includes a copy of the new discount entity.
import { Paddle } from "Paddle";
import { CurrencyCode2, Type } from "Paddle/sdk/models/shared";
async function run() {
const sdk = new Paddle({
security: {
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
},
});
const result = await sdk.discounts.create({
amount: "486.59",
description: "Multi-tiered motivating standardization",
expiresAt: new Date("2024-10-12T07:20:50.52Z"),
id: "dsc_01gv5kpg05xp104ek2fmgjwttf",
restrictTo: [
"string",
],
type: Type.FlatPerSeat,
});
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
shared.DiscountCreate | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
Promise<operations.CreateDiscountResponse>
Error Object | Status Code | Content Type |
---|---|---|
errors.SDKError | 4xx-5xx | / |
Returns a discount using its ID.
import { Paddle } from "Paddle";
async function run() {
const sdk = new Paddle({
security: {
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
},
});
const result = await sdk.discounts.get({
discountId: "dsc_01gt218xfk7yztpvgmcazkes83",
});
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.GetDiscountRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
Promise<operations.GetDiscountResponse>
Error Object | Status Code | Content Type |
---|---|---|
errors.GetDiscountResponseBody | 404 | application/json |
errors.SDKError | 4xx-5xx | / |
Returns a paginated list of discounts. Use the query parameters to page through results.
By default, Paddle returns discounts that are active
. Use the status
query parameter to return discounts that are archived or expired.
import { Paddle } from "Paddle";
import { StatusDiscount } from "Paddle/sdk/models/shared";
async function run() {
const sdk = new Paddle({
security: {
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
},
});
const result = await sdk.discounts.list({
code: "BLACKFRIDAY",
});
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.ListDiscountsRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
Promise<operations.ListDiscountsResponse>
Error Object | Status Code | Content Type |
---|---|---|
errors.SDKError | 4xx-5xx | / |
Updates a discount using its ID.
If successful, your response includes a copy of the updated discount entity.
import { Paddle } from "Paddle";
import { CurrencyCode2, DiscountType, SchemaStatusDiscount } from "Paddle/sdk/models/shared";
async function run() {
const sdk = new Paddle({
security: {
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
},
});
const result = await sdk.discounts.update({
discount: {
expiresAt: new Date("2024-10-12T07:20:50.52Z"),
id: "dsc_01gv5kpg05xp104ek2fmgjwttf",
restrictTo: [
"string",
],
},
discountId: "dsc_01gt218xfk7yztpvgmcazkes83",
});
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.UpdateDiscountRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
Promise<operations.UpdateDiscountResponse>
Error Object | Status Code | Content Type |
---|---|---|
errors.UpdateDiscountResponseBody | 404 | application/json |
errors.SDKError | 4xx-5xx | / |