hookwright 2.3.1 → 2.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +9 -8
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -24,7 +24,7 @@ var init_package = __esm({
24
24
  "package.json"() {
25
25
  package_default = {
26
26
  name: "hookwright",
27
- version: "2.3.1",
27
+ version: "2.3.3",
28
28
  description: "Build real, signed e-commerce webhooks from a live Shopify catalogue \u2014 interactive terminal UI, no backend",
29
29
  keywords: [
30
30
  "webhook",
@@ -1826,12 +1826,12 @@ var COMMON_FIELDS3 = [
1826
1826
  { source: "request.smart_exchange", target: "smartExchange" },
1827
1827
  { source: "request.order.name", target: "order.name" },
1828
1828
  { source: "request.order.id", target: "order.id" },
1829
- { source: "request.line_items[].original_product.title", target: "product.details", required: true, note: "the first PAID line names the caption; freebies rank last" },
1830
- { source: "request.line_items[].original_product.image.src", target: "product.image" },
1831
- { source: "request.line_items[].original_product.price", target: "product.totalPrice", note: "summed across the lines, times quantity; a zero marks a freebie" },
1832
- { source: "request.line_items[].original_product.sku", target: "product.sku" },
1829
+ { source: "request.line_items[].original_product.title", target: "returnProduct.details", required: true, note: "the first PAID line names the caption; freebies rank last" },
1830
+ { source: "request.line_items[].original_product.image.src", target: "returnProduct.image" },
1831
+ { source: "request.line_items[].original_product.price", target: "returnProduct.totalPrice", note: "summed across the lines, times quantity; a zero marks a freebie" },
1832
+ { source: "request.line_items[].original_product.sku", target: "returnProduct.sku" },
1833
1833
  { source: "request.line_items[].reason", target: "reason" },
1834
- { source: "request.line_items[].quantity", target: "product.quantity" },
1834
+ { source: "request.line_items[].quantity", target: "returnProduct.quantity" },
1835
1835
  { source: "request.line_items[].presentment_price.actual_amount", target: "pricing.totalPrice" },
1836
1836
  { source: "request.line_items[].presentment_price.currency", target: "pricing.currency" },
1837
1837
  { source: "request.line_items[].return_fee.price_set.presentment_money.amount", target: "pricing.returnFee" },
@@ -1895,6 +1895,7 @@ function buildPayload6(ctx) {
1895
1895
  const qty = def.requestType === "exchange" ? repl?.quantity ?? sel?.quantity ?? 1 : sel?.quantity ?? 1;
1896
1896
  const originalPrice = money2(sel?.variant?.price ?? 0);
1897
1897
  const exchangePrice = money2(repl?.variant?.price ?? 0);
1898
+ const refundedAmount = def.requestType === "exchange" ? Math.max(money2((originalPrice - exchangePrice) * qty), 0) : money2(originalPrice * qty);
1898
1899
  return {
1899
1900
  id: Number(sel?.variant?.id ?? sel?.product?.id ?? 0),
1900
1901
  refund: {
@@ -1903,8 +1904,8 @@ function buildPayload6(ctx) {
1903
1904
  meta: { discount_code: ctx.couponCode ?? `RP${String(now.getTime()).slice(-7)}` },
1904
1905
  status: def.status === "requested" ? "pending" : "refunded",
1905
1906
  refunded_amount: {
1906
- shop_money: { amount: originalPrice, currency_code: currency },
1907
- presentment_money: { amount: originalPrice, currency_code: currency }
1907
+ shop_money: { amount: refundedAmount, currency_code: currency },
1908
+ presentment_money: { amount: refundedAmount, currency_code: currency }
1908
1909
  },
1909
1910
  refunded_at: at,
1910
1911
  comment: null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hookwright",
3
- "version": "2.3.1",
3
+ "version": "2.3.3",
4
4
  "description": "Build real, signed e-commerce webhooks from a live Shopify catalogue — interactive terminal UI, no backend",
5
5
  "keywords": [
6
6
  "webhook",