הזמנה ששולמה ב-Lemon Squeezy הופכת למסמך, והחזר הופך לחשבונית זיכוי.
חשוב לפני שמתחילים: Lemon Squeezy היא merchant of record. היא המוכרת ללקוח הקצה וגובה את המס בשמה. התייעצו עם רואה החשבון אם וכיצד להפיק מסמך על כל הזמנה לפני שמפעילים את החיבור.
התקנה (5 דקות)#
- ב-Lemon Squeezy: Settings → Webhooks → הוספת Webhook (+).
- ב-Callback URL הדביקו את כתובת ה-Webhook שמוצגת אצלכם במסך החיבור.
- בחרו Signing secret (מחרוזת אקראית משלכם, 6 עד 40 תווים) והדביקו אותה גם בשדה הסוד בחיבור.
- סמנו את האירועים
order_createdו-order_refundedושמרו. - בחרו סוג מסמך ולחצו על "שליחת הזמנת בדיקה".
הערה: האירוע כולל רק את הפריט הראשון של ההזמנה (first_order_item). בהזמנה עם כמה פריטים המסמך יציג את הראשון, והסכום הכולל תמיד שווה לסכום ששולם.
Developer reference#
Endpoint: POST /api/billing/ecommerce/lemonsqueezy/<hookId>
Auth: X-Signature = HMAC-SHA256 of the raw body with the signing secret, hex ({ kind: "hmac", header: "x-signature", encoding: "hex" }). Docs: https://docs.lemonsqueezy.com/help/webhooks/signing-requests. Event name from meta.event_name (also the X-Event-Name header): https://docs.lemonsqueezy.com/help/webhooks/webhook-requests. Order attributes: https://docs.lemonsqueezy.com/api/orders/the-order-object
| Event | Result |
|---|---|
order_created with attributes.status = "paid" | document |
order_refunded | credit note |
| anything else (subscriptions, licenses…) | 200 {skipped} |
| Lemon Squeezy field | Document |
|---|---|
data.id | externalId, apiIdentifier = lemonsqueezy-<id> |
user_name, user_email | customer (fallback לקוח/ה) |
first_order_item.product_name (+ variant_name unless "Default"), quantity | the line |
total (cents = agorot, no scaling) | payment row and the line gross |
subtotal, discount_total | shown as a document discount only when prices are tax-inclusive (or tax is 0) and subtotal − discount = total; otherwise the line carries the gross total |
tax | document VAT rate (nearest 18% / 17%, else statutory) |
currency | uppercased; non-ILS needs an exchange rate (recorded as error) |
test_mode | marked "(test mode)" in the document comment |
Refunds: the event has no refund id, so the id is <order id>:<refunded_amount> (stable on redelivery). status = refunded credits the whole document; partial_refund credits the cumulative refunded_amount, so a second partial refund on the same order needs a manual credit note.
Test with curl:
HOOK="https://<your-host>/api/billing/ecommerce/lemonsqueezy/<hookId>"
SECRET="your-signing-secret"
BODY='{"meta":{"event_name":"order_created"},"data":{"type":"orders","id":"9001","attributes":{"order_number":1,"user_name":"אורי לוי","user_email":"[email protected]","currency":"ILS","subtotal":20000,"discount_total":0,"tax":3600,"total":23600,"tax_inclusive":false,"status":"paid","created_at":"2026-09-20T10:15:30.000000Z","first_order_item":{"product_name":"מדריך PDF","variant_name":"Default","price":20000,"quantity":1}}}}'
SIG=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$SECRET" -hex | sed 's/^.* //')
curl -i -X POST "$HOOK" -H "Content-Type: application/json" -H "X-Event-Name: order_created" -H "X-Signature: $SIG" -d "$BODY"Troubleshooting#
- 401 invalid signature: ה-Signing secret בחיבור שונה מזה שהגדרתם ב-Webhook (הם צריכים להיות זהים אות באות).
- 401 secret is not configured: עדיין לא הדבקתם Signing secret.
- 404 unknown hook: כתובת ה-Webhook לא הועתקה במלואה.
- הזמנה לא הופקה (skipped): הסטטוס אינו
paid, או שהאירוע אינוorder_created/order_refunded. - הזמנה בסטטוס blocked או dormant: מגבלת החבילה או מודול החיוב כבוי. אפשר להפיק ידנית מיומן ההזמנות.
- זיכוי בסטטוס error: ההזמנה המקורית לא הופקה אצלנו, ולכן אין מסמך לזכות.