=== Devtonic Payment Gateway for Lemon Squeezy ===
Contributors: hamzaafridi05
Donate link: https://devtonicstudios.com/lemon-squeezy/
Tags: lemon squeezy, lemonsqueezy, woocommerce, payment gateway, checkout
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Accept Lemon Squeezy payments at your WooCommerce checkout. A real payment gateway with automatic order updates and one-click webhook setup.

== Description ==

This plugin adds Lemon Squeezy as a payment method at your WooCommerce checkout. Customers pick Lemon Squeezy, pay on the secure Lemon Squeezy hosted checkout, and come back to your store. The WooCommerce order is updated automatically by webhook. No copying orders between two dashboards.

If your shop runs on WooCommerce and you want Lemon Squeezy to process the payments, this plugin is the bridge between the two.

Because Lemon Squeezy is a merchant of record, it handles sales tax, VAT, and global payment compliance on its side. You sell from your own WooCommerce store, Lemon Squeezy takes care of the tax paperwork.

I built this plugin because I needed it for my own store. I process my own payments through it every day. If it breaks, I feel it first.

Here is the whole thing working, from the checkout to the order being marked paid:

https://www.youtube.com/watch?v=EyC_QIwUhOw

= What the free version does =

* Adds Lemon Squeezy as a real WooCommerce payment gateway (redirect checkout)
* Marks WooCommerce orders paid automatically when the payment goes through
* Payment links stay open for 7 days, so Lemon Squeezy's cart reminder emails bring buyers back to their order
* Syncs refunds made in Lemon Squeezy back to the WooCommerce order
* One-click webhook setup: the plugin registers the webhook on Lemon Squeezy for you
* Every webhook request is verified with an HMAC-SHA256 signature before anything is processed
* Test mode so you can try the whole flow with test cards before going live
* Works with classic checkout and block checkout
* Compatible with WooCommerce High-Performance Order Storage (HPOS)
* Works with simple and variable products, with a Lemon Squeezy variant ID on the product and on each variation

= Pro version =

Everything in the free plugin keeps working forever. The [Pro version](https://devtonicstudios.com/lemon-squeezy/) adds what bigger stores need:

* Subscriptions: renewals, pauses, cancellations and expiry synced to the WooCommerce order from Lemon Squeezy's 10 subscription events, no separate subscriptions plugin required (it also works with WooCommerce Subscriptions)
* Orders with several items: every item with its price on Lemon Squeezy's receipt email, and an option to show your store logo at checkout instead of one product's picture
* Skip the Checkout Page: for digital products, buyers go from the cart straight to Lemon Squeezy
* License keys delivered onto the WooCommerce order and order emails automatically
* Overlay checkout: customers pay in a popup without leaving your site
* Refunds processed straight from the WooCommerce order screen
* One-click product sync with a variant dropdown on every product
* Moving up from this free plugin: Pro brings your settings and product links over by itself, and orders already sent to Lemon Squeezy are still marked paid

= Requirements =

* WooCommerce 6.0 or newer
* PHP 7.4 or newer
* An SSL certificate (HTTPS), required for webhooks
* A free Lemon Squeezy account with at least one product

== External services ==

This plugin connects to the Lemon Squeezy API to process payments. It is not possible to use the plugin without this connection.

* When a customer checks out, the plugin sends the order total, order number, the customer's billing email, name, and billing country, state, and postcode to api.lemonsqueezy.com to create the checkout session. The customer is then redirected to a checkout page hosted by Lemon Squeezy.
* When you click "Register Webhook" or "Test Connection" in the admin, the plugin calls api.lemonsqueezy.com with your API key.
* Lemon Squeezy sends webhook notifications back to your site when orders are created or refunded.

This service is provided by Lemon Squeezy LLC: [terms of service](https://www.lemonsqueezy.com/terms), [privacy policy](https://www.lemonsqueezy.com/privacy).

== Installation ==

1. Install and activate the plugin (WooCommerce must be active).
2. Go to WooCommerce, then Settings, then Payments, then Lemon Squeezy.
3. Paste your API key and Store ID from your Lemon Squeezy dashboard (Settings, then API).
4. Go to WooCommerce, then Lemon Squeezy, and click "Register Webhook on Lemon Squeezy".
5. Edit a product and enter its Lemon Squeezy variant ID in the General tab.
6. Keep Test Mode on, make a test purchase with card 4242 4242 4242 4242, and check the order updates.
7. Turn off Test Mode to accept live payments.

The whole setup takes about 5 minutes.

== Frequently Asked Questions ==

= How is this different from the official Lemon Squeezy plugin? =

The official Lemon Squeezy plugin provides a standalone storefront that works independently of WooCommerce. This plugin serves a different purpose: it adds Lemon Squeezy as a payment method inside your existing WooCommerce store, so your orders and products stay in WooCommerce.

= Does it support subscriptions? =

Recurring subscription sync is a Pro feature. The free version handles one-time payments. In Pro, all 10 of Lemon Squeezy's subscription webhook events are synced to the WooCommerce order, with no separate subscriptions plugin needed.

= Does it deliver license keys? =

License key delivery onto orders and emails is a Pro feature.

= Does it work with variable products? =

Yes. Put the Lemon Squeezy variant ID on the product, and on each variation if they map to different Lemon Squeezy variants. A variation with no ID of its own falls back to the one on the parent product.

= An order has several items. Why does Lemon Squeezy's receipt show one product? =

Lemon Squeezy has no cart. One checkout pays for one product, so the plugin sends the whole WooCommerce order as one payment: one Lemon Squeezy product (the one linked to the biggest line in the order) at the order total. The buyer pays once, and your WooCommerce order keeps every item.

The Lemon Squeezy checkout page lists the items. The receipt email Lemon Squeezy sends after the payment shows that one product at the order total, with a short thank you note.

The Pro version lists every item with its price on that receipt email, so the buyer can see what they paid for.

= Do my orders stay in WooCommerce? =

Yes. That is the whole point. Orders are created and updated in your own WooCommerce database. If you ever stop using Lemon Squeezy, your order history stays with you.

= Is the webhook secure? =

Yes. Every webhook request must carry a valid HMAC-SHA256 signature. Requests with a missing or invalid signature are rejected with a 401 before any data is touched.

= Does this plugin charge any fees? =

No. The plugin is free. Lemon Squeezy charges its own payment processing fees on their side.

= Is LemonSqueezy the same as Lemon Squeezy? =

Yes, the same company. They write it as two words, Lemon Squeezy. Plenty of people type LemonSqueezy as one word, so if that is how you searched, this is the right plugin.

== Screenshots ==

1. Lemon Squeezy as a payment method at the WooCommerce checkout.
2. Gateway settings: API key, store ID, test mode and checkout language.
3. The Lemon Squeezy admin page with one-click webhook registration.
4. A WooCommerce order updated automatically after payment.
5. The Lemon Squeezy variant ID field on a product.
6. The same field on each variation of a variable product.

== Changelog ==

= 1.0.2 =
* Fix - The Pay button on Lemon Squeezy's checkout now has the color you chose in your own Lemon Squeezy design (Design, then Checkout, in Lemon Squeezy). Until now the plugin sent its own purple with every checkout, and that purple covered your color.
* New - The settings pages now show what the Pro version adds, each in the place Pro has it, greyed out with a Pro badge. Nothing in the free plugin changes or stops working.
* Tweak - On the payment settings, the words on the Save button are easier to read, and the choices in the lists are short enough to show whole on a phone.
* New - For developers: the lsgw_button_color filter now starts empty, which keeps your Lemon Squeezy design. A color it returns goes with a text color that reads on it, white or near-black, because Lemon Squeezy keeps the button text white on any color. The new lsgw_button_text_color filter sets the text color yourself. Both receive the order.
* Fix - If Lemon Squeezy ever refuses a button color, the checkout is made again without it, so the buyer can still pay.

= 1.0.1 =
* Fix - The button in Lemon Squeezy's cart reminder emails opened an error page. When a buyer leaves the checkout without paying, Lemon Squeezy can send reminder emails over the next three days, and their button opens the payment link the plugin made for the order. That link stopped working after 30 minutes. It now works for 7 days.
* New - A buyer who pays an old link after the order was already paid is not recorded as a second sale. The order stays as it is and gets a note naming the second Lemon Squeezy order, so you can refund it there. That refund is noted on the order without touching the order's own payment.
* Fix - A payment Lemon Squeezy delivered twice, for example a retry, was recorded twice. It is now recorded once.
* Fix - A paid order is no longer moved back to on hold or failed by another Lemon Squeezy order for it.
* Note - An unpaid order that WooCommerce cancelled in the meantime is marked paid as usual when the buyer pays from a reminder.
* New - For developers: the lsgw_checkout_expiry_seconds filter now defaults to 7 days and also receives the order.
* Fix - On a phone, a long button on the plugin's own page (WooCommerce, then Lemon Squeezy) stuck out of its box.
* Tested with WooCommerce 11.2.

= 1.0.0 =
* First release.
* Lemon Squeezy payment gateway with redirect checkout.
* Automatic order updates via signed webhooks (order created, order refunded).
* One-click webhook registration.
* Test mode, HPOS compatibility, classic and block checkout support.

== Upgrade Notice ==

= 1.0.2 =
The Pay button on Lemon Squeezy's checkout now shows the color from your own Lemon Squeezy design instead of the plugin's purple.

= 1.0.1 =
Payment links now work for 7 days, so Lemon Squeezy's cart reminder emails bring buyers back to their order instead of an error page.

= 1.0.0 =
First release.
