Skip to main content
Back to Prompt Library
implementation

Build the application

Inspect the original prompt language first, then copy or adapt it once you know how it fits your workflow.

Linked challenge: Build a Buyer App Cancellation Fee and Refund Explainer

Format
Code-aware
Lines
71
Sections
11
Linked challenge
Build a Buyer App Cancellation Fee and Refund Explainer

Prompt source

Original prompt text with formatting preserved for inspection.

71 lines
11 sections
No variables
1 code block
## Build
Analyze post-order cancellation requests across open commerce network messages to determine applicable merchant restock fees and logistics penalties. Compile clear refund breakdown receipts for buyer app customer advocates.

## User
E-commerce customer service lead

## Workflow
1. Parse cancellation timestamps, fulfillment progress states, and cancellation policy terms from mock Beckn order files.
2. Determine whether the cancellation occurred before or after merchant dispatch or courier pickup.
3. Calculate refundable order amounts, non-refundable logistics allowances, and merchant restocking withholdings.
4. Generate an itemized refund breakdown receipt with clear policy rationales for buyer review.

## Interface
Support agent portal showing order timeline milestones, cancellation window meters, and generated refund breakdowns.

## Data
Construct synthetic mock orders with progressive fulfillment stages and standardized cancellation policies in JSON.
Starter examples below are synthetic. They are not downloaded records.

## Source
[Beckn protocol specifications](https://raw.githubusercontent.com/beckn/protocol-specifications/master/README.md)
Adopts Beckn core post-order cancellation and order update specifications to process order stage metadata.

## Tools
pydantic-ai, fastapi, pytest.
Validates state machine transitions and numeric refund fee calculations with strict schema enforcement.
Lightweight model supporting structured JSON schema outputs and mathematical deduction reasoning.

## Deliverables
Submit runnable source, pinned dependencies, setup commands, a working interface, example outputs, and a recorded end-to-end demo. Include tests and an action log.

## Acceptance
- Enforces zero cancellation penalty for pre-dispatch cancellations within grace periods.
- Applies documented logistics deductions when cancellation happens after courier pickup.
- Outputs complete itemized financial summaries without executing actual payment gateway reversals.

## Starter Examples
```json
[
  {
    "input": {
      "order_id": "ORD-7719",
      "order_state": "Packed",
      "item_subtotal": 1500,
      "delivery_fee": 100,
      "cancellation_time_minutes_after_order": 15,
      "merchant_grace_period_minutes": 30
    },
    "expected_output": {
      "refund_eligible": true,
      "item_refund": 1500,
      "delivery_fee_refund": 100,
      "total_refund_inr": 1600,
      "cancellation_penalty": 0,
      "reason": "Cancelled within merchant grace period prior to carrier dispatch."
    }
  },
  {
    "input": {
      "order_id": "ORD-7720",
      "order_state": "Out_For_Delivery",
      "item_subtotal": 2200,
      "delivery_fee": 150,
      "cancellation_time_minutes_after_order": 120,
      "merchant_grace_period_minutes": 30
    },
    "expected_output": {
      "refund_eligible": true,
      "item_refund": 2200,
      "delivery_fee_refund": 0,
      "total_refund_inr": 2200,
      "cancellation_penalty": 150,
      "reason": "Cancelled post-dispatch; courier fulfillment fee forfeited per policy."
    }
  }
]
```

## Safety
Simulates refund rules and policy calculations without touching live payment rails or bank balances.
Use mock external writes. Require human review before any real deployment.

Adaptation plan

Keep the source stable, then change the prompt in a predictable order so the next run is easier to evaluate.

Keep stable

Hold the task contract and output shape stable so generated implementations remain comparable.

Tune next

Update libraries, interfaces, and environment assumptions to match the stack you actually run.

Verify after

Test failure handling, edge cases, and any code paths that depend on hidden context or secrets.