Skip to content

Commit

Permalink
Add refund endpoints and new Checkout options (#124)
Browse files Browse the repository at this point in the history
* feat: add new Checkout color options

* feat: add refund endpoints
  • Loading branch information
brankoconjic authored Sep 5, 2024
1 parent a45785d commit abc2b7e
Show file tree
Hide file tree
Showing 14 changed files with 488 additions and 120 deletions.
5 changes: 5 additions & 0 deletions .changeset/gentle-onions-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lemonsqueezy/lemonsqueezy.js": minor
---

Added options for overriding checkout styles
5 changes: 5 additions & 0 deletions .changeset/old-jobs-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lemonsqueezy/lemonsqueezy.js": minor
---

Added options which allow overriding checkout colors
5 changes: 5 additions & 0 deletions .changeset/red-ears-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lemonsqueezy/lemonsqueezy.js": minor
---

Added new refund endpoints
116 changes: 59 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![NPM version](https://img.shields.io/npm/v/%40lemonsqueezy%2Flemonsqueezy.js?label=&color=%230d9488)](https://www.npmjs.com/package/@lemonsqueezy/lemonsqueezy.js)
[![Functions usage](https://img.shields.io/badge/Wiki-%237c3aed)](https://github.com/lmsqueezy/lemonsqueezy.js/wiki)
[![APIs Count](https://img.shields.io/badge/57_Functions-%232563eb)](https://github.com/lmsqueezy/lemonsqueezy.js/wiki)
[![APIs Count](https://img.shields.io/badge/59_Functions-%232563eb)](https://github.com/lmsqueezy/lemonsqueezy.js/wiki)
[![Weekly downloads](https://img.shields.io/npm/dw/@lemonsqueezy/lemonsqueezy.js)](https://www.npmjs.com/package/@lemonsqueezy/lemonsqueezy.js)
![NPM Downloads](https://img.shields.io/npm/d18m/%40lemonsqueezy%2Flemonsqueezy.js)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Flmsqueezy%2Flemonsqueezy.js.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Flmsqueezy%2Flemonsqueezy.js?ref=badge_shield)
Expand Down Expand Up @@ -86,66 +86,68 @@ For more functions usage, see [Wiki](https://github.com/lmsqueezy/lemonsqueezy.j

<details>
<summary>Click to view</summary>

| Export | min+brotli |
| ------------------------------- | ---------- |
| createDiscount | 991 B |
| createCheckout | 895 B |
| updateSubscriptionItem | 849 B |
| updateSubscription | 841 B |
| listWebhooks | 831 B |
| listDiscountRedemptions | 821 B |
| listLicenseKeyInstances | 820 B |
| listSubscriptionInvoices | 818 B |
| listLicenseKeys | 817 B |
| listOrderItems | 817 B |
| listSubscriptionItems | 817 B |
| listCheckouts | 814 B |
| listDiscounts | 814 B |
| listSubscriptions | 814 B |
| createDiscount | 1.01 kB |
| createCheckout | 888 B |
| updateSubscriptionItem | 856 B |
| updateSubscription | 838 B |
| listCheckouts | 824 B |
| listDiscountRedemptions | 819 B |
| listLicenseKeyInstances | 818 B |
| listSubscriptionInvoices | 816 B |
| listLicenseKeys | 815 B |
| listOrderItems | 815 B |
| listSubscriptionItems | 815 B |
| listUsageRecords | 814 B |
| listVariants | 814 B |
| listCustomers | 813 B |
| listFiles | 813 B |
| listOrders | 813 B |
| listPrices | 813 B |
| listProducts | 813 B |
| listStores | 813 B |
| updateLicenseKey | 813 B |
| createWebhook | 808 B |
| updateWebhook | 793 B |
| generateSubscriptionInvoice | 789 B |
| generateOrderInvoice | 783 B |
| activateLicense | 770 B |
| validateLicense | 770 B |
| deactivateLicense | 764 B |
| listSubscriptions | 812 B |
| listWebhooks | 812 B |
| listCustomers | 811 B |
| listDiscounts | 811 B |
| listFiles | 811 B |
| listOrders | 811 B |
| listPrices | 811 B |
| listProducts | 811 B |
| listStores | 811 B |
| listVariants | 811 B |
| updateLicenseKey | 811 B |
| createWebhook | 806 B |
| issueSubscriptionInvoiceRefund | 796 B |
| issueOrderRefund | 795 B |
| updateWebhook | 792 B |
| generateSubscriptionInvoice | 787 B |
| generateOrderInvoice | 785 B |
| validateLicense | 761 B |
| activateLicense | 760 B |
| deactivateLicense | 759 B |
| createUsageRecord | 724 B |
| getLicenseKeyInstance | 714 B |
| getSubscriptionInvoice | 702 B |
| getDiscountRedemption | 700 B |
| getSubscriptionItem | 700 B |
| getUsageRecord | 700 B |
| getOrderItem | 699 B |
| getLicenseKey | 698 B |
| getOrder | 697 B |
| getPrice | 697 B |
| getStore | 697 B |
| getCheckout | 696 B |
| getCustomer | 696 B |
| getFile | 696 B |
| getProduct | 694 B |
| getWebhook | 694 B |
| getDiscount | 693 B |
| getSubscription | 693 B |
| getVariant | 693 B |
| updateCustomer | 684 B |
| archiveCustomer | 683 B |
| createCustomer | 678 B |
| cancelSubscription | 660 B |
| deleteDiscount | 658 B |
| deleteWebhook | 653 B |
| getSubscriptionItemCurrentUsage | 651 B |
| getAuthenticatedUser | 598 B |
| getDiscountRedemption | 702 B |
| getLicenseKeyInstance | 702 B |
| getSubscriptionInvoice | 699 B |
| getSubscriptionItem | 698 B |
| getUsageRecord | 698 B |
| getOrderItem | 697 B |
| getWebhook | 697 B |
| getLicenseKey | 695 B |
| getCheckout | 694 B |
| getStore | 694 B |
| getSubscription | 694 B |
| getCustomer | 692 B |
| getFile | 692 B |
| getOrder | 692 B |
| getPrice | 692 B |
| getDiscount | 691 B |
| getProduct | 691 B |
| archiveCustomer | 690 B |
| getVariant | 690 B |
| createCustomer | 686 B |
| updateCustomer | 682 B |
| deleteWebhook | 660 B |
| cancelSubscription | 658 B |
| deleteDiscount | 656 B |
| getSubscriptionItemCurrentUsage | 650 B |
| getAuthenticatedUser | 595 B |
| lemonSqueezySetup | 106 B |

</details>
Expand Down
2 changes: 2 additions & 0 deletions src/checkouts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function createCheckout(
preview,
testMode,
} = checkout;

const relationships = {
store: {
data: {
Expand All @@ -53,6 +54,7 @@ export function createCheckout(
},
},
};

const attributes = {
customPrice,
expiresAt,
Expand Down
152 changes: 138 additions & 14 deletions src/checkouts/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,70 @@ type CheckoutOptions = {
*/
skip_trial: boolean;
quantity: number;
/**
* If `true`, use the dark theme
*/
dark: boolean;
/**
* If `false`, hide the "You will be charged..." subscription preview text
*/
subscription_preview: boolean;

/**
* A custom hex color to use for the background of the checkout page.
*/
background_color: string;

/**
* A custom hex color to use for the headings of the checkout page.
*/
headings_color: string;

/**
* A custom hex color to use for the primary text of the checkout page.
*/
primary_text_color: string;

/**
* A custom hex color to use for the secondary text color of the checkout page.
*/
secondary_text_color: string;

/**
* A custom hex color to use for the links on the checkout page.
*/
links_color: string;

/**
* A custom hex color to use for the checkout button. Text within the button will be either white or dark depending on the brightness of your button color.
* A custom hex color to use for the borders on the checkout page.
*/
borders_color: string;

/**
* A custom hex color to use for the checkboxes on the checkout page.
*/
checkbox_color: string;

/**
* A custom hex color to indicate an active state on the checkout page.
*/
active_state_color: string;

/**
* A custom hex color to use for the checkout button.
*/
button_color: string;

/**
* A custom hex color to use for the text within the checkout button.
*/
button_text_color: string;

/**
* A custom hex color to use for the terms and privacy text on the checkout page. Used only on embedded checkouts.
*/
terms_privacy_color: string;

/**
* `Deprecated` If `true`, use the dark theme. Use color options
*/
dark: boolean;
};
type CheckoutData = {
/**
Expand Down Expand Up @@ -242,9 +294,19 @@ type Attributes = {
* - `logo` - If `false`, hide the store logo
* - `desc` - If `false`, hide the product description
* - `discount` - If `false`, hide the discount code field
* - `dark` - If `true`, use the dark theme
* - `subscription_preview` - If `false`, hide the "You will be charged..." subscription preview text
* - `button_color` - A custom hex color to use for the checkout button. Text within the button will be either white or dark depending on the brightness of your button color.
* - `background_color` - A custom hex color to use for the background of the checkout page.
* - `headings_color` - A custom hex color to use for the headings of the checkout page.
* - `primary_text_color` - A custom hex color to use for the primary text of the checkout page.
* - `secondary_text_color` - A custom hex color to use for the secondary text color of the checkout page.
* - `links_color` - A custom hex color to use for the links on the checkout page.
* - `borders_color` - A custom hex color to use for the borders on the checkout page.
* - `checkbox_color` - A custom hex color to use for the checkboxes on the checkout page.
* - `active_state_color` - A custom hex color to indicate an active state on the checkout page.
* - `button_color` - A custom hex color to use for the checkout button.
* - `button_text_color` - A custom hex color to use for the text within the checkout button.
* - `terms_privacy_color` - A custom hex color to use for the terms and privacy text on the checkout page. Used only on embedded checkouts.
* - `dark` - Deprecated. If `true`, use the dark theme. Use color options instead.
*/
checkout_options: CheckoutOptions;
/**
Expand Down Expand Up @@ -392,9 +454,19 @@ export type NewCheckout = {
* - `logo` - If `false`, hide the store logo
* - `desc` - If `false`, hide the product description
* - `discount` - If `false`, hide the discount code field
* - `dark` - If `true`, use the dark theme
* - `subscription_preview` - If `false`, hide the "You will be charged..." subscription preview text
* - `buttonColor` - A custom hex color to use for the checkout button. Text within the button will be either white or dark depending on the brightness of your button color.
* - `background_color` - A custom hex color to use for the background of the checkout page.
* - `headings_color` - A custom hex color to use for the headings of the checkout page.
* - `primary_text_color` - A custom hex color to use for the primary text of the checkout page.
* - `secondary_text_color` - A custom hex color to use for the secondary text color of the checkout page.
* - `links_color` - A custom hex color to use for the links on the checkout page.
* - `borders_color` - A custom hex color to use for the borders on the checkout page.
* - `checkbox_color` - A custom hex color to use for the checkboxes on the checkout page.
* - `active_state_color` - A custom hex color to indicate an active state on the checkout page.
* - `button_color` - A custom hex color to use for the checkout button.
* - `button_text_color` - A custom hex color to use for the text within the checkout button.
* - `terms_privacy_color` - A custom hex color to use for the terms and privacy text on the checkout page. Used only on embedded checkouts.
* - `dark` - Deprecated. If `true`, use the dark theme. Use color options instead.
*/
checkoutOptions?: {
/**
Expand All @@ -421,18 +493,70 @@ export type NewCheckout = {
* If `true`, remove the free trial
*/
skipTrial?: boolean;
/**
* If `true`, use the dark theme
*/
dark?: boolean;
/**
* If `false`, hide the "You will be charged..." subscription preview text
*/
subscriptionPreview?: boolean;

/**
* A custom hex color to use for the background of the checkout page.
*/
backgroundColor?: string;

/**
* A custom hex color to use for the headings of the checkout page.
*/
headingsColor?: string;

/**
* A custom hex color to use for the primary text of the checkout page.
*/
primaryTextColor?: string;

/**
* A custom hex color to use for the secondary text color of the checkout page.
*/
secondaryTextColor?: string;

/**
* A custom hex color to use for the links on the checkout page.
*/
linksColor?: string;

/**
* A custom hex color to use for the checkout button
* A custom hex color to use for the borders on the checkout page.
*/
bordersColor?: string;

/**
* A custom hex color to use for the checkboxes on the checkout page.
*/
checkboxColor?: string;

/**
* A custom hex color to indicate an active state on the checkout page.
*/
activeStateColor?: string;

/**
* A custom hex color to use for the checkout button.
*/
buttonColor?: string;

/**
* A custom hex color to use for the text within the checkout button.
*/
buttonTextColor?: string;

/**
* A custom hex color to use for the terms and privacy text on the checkout page. Used only if `embed` is set to `true`.
*/
termsPrivacyColor?: string;

/**
* `Deprecated` If `true`, use the dark theme. Use color options
*/
dark?: boolean;
};
/**
* An object containing any [prefill](https://docs.lemonsqueezy.com/help/checkout/prefilling-checkout-fields) or [custom data](https://docs.lemonsqueezy.com/help/checkout/passing-custom-data) to be used in the checkout. Possible options include:
Expand Down
8 changes: 7 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ export type {
ListOrdersParams,
GenerateOrderInvoiceParams,
} from "./orders/types";
export { getOrder, listOrders, generateOrderInvoice } from "./orders";
export {
getOrder,
listOrders,
generateOrderInvoice,
issueOrderRefund,
} from "./orders";

// Order Items
export type {
Expand Down Expand Up @@ -116,6 +121,7 @@ export {
getSubscriptionInvoice,
listSubscriptionInvoices,
generateSubscriptionInvoice,
issueSubscriptionInvoiceRefund,
} from "./subscriptionInvoices";

// Subscription Items
Expand Down
Loading

0 comments on commit abc2b7e

Please sign in to comment.