Create EDD Refund


Records a refund for an Easy Digital Downloads order, either the whole order or chosen items and amounts, the way the Refund button on the order screen does: EDD adds a refund record, marks the order refunded or partially refunded, takes away download access to fully refunded items and reduces the store's earnings. This cannot be undone, so it needs confirm set to true. By default no money moves: the refund is recorded in EDD only and the result says to return the money at the payment gateway. Set refund_at_gateway to also send the money back through Stripe, PayPal or Square when the order was paid through one of them. The customer is emailed only when notify_customer is true. Add-ons react as they do to a refund made in the admin. Get order and order item IDs from mosmcp/edd-list-orders.

Also known as: refund an order, give money back, refund a purchase, partial refund, money back.

Property Value
Ability slug mosmcp/edd-create-refund
Wire tool name mosmcp__edd-create-refund
Category Easy Digital Downloads (mosmcp-edd)
Plan Pro

 

Required access

Requirement Value
Capability edit_shop_payments
Minimum default role Shop Accountant (Easy Digital Downloads)
Annotations readOnly: false · destructive: true · idempotent: false · openWorld: true

 

Input schema

Field Type Required Default Description
order_id integer (min 1) Yes — The ID of the order to refund, as returned by mosmcp/edd-list-orders.
items object[] — For a partial refund: the items to refund and, optionally, how much of each. Leave out to refund the whole order, fees included.
items[].order_item_id integer (min 1) Yes — The order item ID, from the items of mosmcp/edd-list-orders.
items[].amount number (min 0) — How much to give back for this item, tax included, in the order's currency. Leave out to refund everything still left on it.
items[].quantity integer (min 1) — How many of the units bought this refund covers, for an item bought more than once. Defaults to every unit not yet refunded.
note string — Optional reason, saved as a note on the refund for the store's records. Not sent to the customer.
refund_at_gateway boolean false Also send the money back through the payment gateway (Stripe, PayPal or Square), as ticking "Refund charge" does in the admin. Only true when the person has asked for the money to be returned, not just recorded. Ignored for an order on hold for a payment dispute, as in EDD's admin, since the gateway may already have returned the money.
notify_customer boolean false Send the customer EDD's refund email, if the store has it switched on. Defaults to false: nobody is emailed.
confirm boolean false Must be true. A refund cannot be reversed in EDD.

 

Output schema

Field Type Required Description
refund_id integer Yes The ID of the refund record EDD created.
refund_number string
order_id integer Yes
order_status string The order's status now: refunded or partially_refunded.
currency string
amount number Yes The amount refunded, tax included.
subtotal number
tax number
items object[] The order items this refund covers.
items[].order_item_id integer
items[].name string
items[].amount number
fully_refunded boolean
still_refundable number How much of the order could still be refunded.
gateway string The payment gateway the order was paid through.
gateway_refund string (one of completed, not_requested, not_supported, failed, unconfirmed) Yes What happened at the gateway: "completed" (the gateway confirmed the money was sent back), "not_requested" or "not_supported" (recorded in EDD only: the money still has to be returned at the gateway), "failed" (the gateway reported an error) or "unconfirmed" (the gateway gave no answer). After "failed" or "unconfirmed", check the gateway before refunding there, so the customer is not refunded twice; the notes say what to do.
customer_notified boolean
refund_url string
order_url string
notes string[]

 

Example

Sample prompt
Refund EDD order 1052 in full and send the money back through Stripe.

Example request (json)

{
  "jsonrpc": "2.0",
  "id": 625,
  "method": "tools/call",
  "params": {
    "name": "mosmcp__edd-create-refund",
    "arguments": {
      "input": {
        "order_id": 1052,
        "refund_at_gateway": true,
        "confirm": true
      }
    }
  }
}

Example response (json)

{
  "jsonrpc": "2.0",
  "id": 625,
  "result": {
    "isError": false,
    "structuredContent": {
      "refund_id": 1060,
      "refund_number": "1052-R-1",
      "order_id": 1052,
      "order_status": "refunded",
      "currency": "USD",
      "amount": 178,
      "subtotal": 178,
      "tax": 0,
      "items": [
        {
          "order_item_id": 2210,
          "name": "WordPress Theme Starter — Agency licence",
          "amount": 149
        },
        {
          "order_item_id": 2211,
          "name": "Lightroom Preset Pack",
          "amount": 29
        }
      ],
      "fully_refunded": true,
      "still_refundable": 0,
      "gateway": "Stripe",
      "gateway_refund": "completed",
      "customer_notified": false,
      "refund_url": "https://example.com/wp-admin/edit.php?post_type=download&page=edd-payment-history&view=view-refund-details&id=1060",
      "order_url": "https://example.com/wp-admin/edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=1052",
      "notes": [
        "Stripe confirmed the refund: the money is on its way back to the customer."
      ]
    }
  }
}

 

Edge cases / errors

  • Without confirm set to true → mosmcp_confirmation_required; the message says what will be refunded.
  • An order already refunded in full → mosmcp_edd_order_already_refunded; a pending or failed order, or one past the refund window the account cannot override → mosmcp_edd_order_not_refundable.
  • An item amount above what is left of it → mosmcp_edd_refund_amount_invalid; an order_item_id not on the order → mosmcp_edd_order_item_not_found; an item listed twice → mosmcp_edd_order_item_repeated.
  • By default no money moves (gateway_refund "not_requested") and a note says to refund at the gateway. refund_at_gateway works only for Stripe, PayPal and Square orders with a stored transaction ID; otherwise gateway_refund is "not_supported". A partial refund leaves fees out.

 


<< Previous Next >>
Create Download EDD Sales Report

For more information about the Secure MCP Server for WordPress plugin, explore the following resources:

Product Overview | Pricing | Try for Free | Documentation

If you have any questions regarding plugin configuration, pricing plans or licensing, please contact us or mail us at aisupport@xecurify.com.