StoreKit Receipt and Loyalty Verification Test Script Builder
Construct a backend integration test script to validate retail loyalty subscriptions and in-app purchase receipts against store APIs.
Use this prompt when validating consumer loyalty tiers, member-exclusive discounts, and digital gift cards purchased through mobile app stores. It produces an integration test script that verifies server-to-server transaction notifications.
Role: Principal Mobile Backend Architect specializing in consumer loyalty platforms and in-app transaction integrity.
Context
- Commerce backend framework: {{commerce_platform_name}}
- Store billing API version: {{store_billing_api_version}}
- Retail loyalty subscription SKU: {{loyalty_tier_sku}}
- Server webhook endpoint URL: {{webhook_endpoint_url}}
- Sandbox environment target: {{sandbox_environment_type}}
- Authentication token strategy: {{auth_token_strategy}}
Task
Develop an automated integration testing script in Node.js or Python that simulates store server-to-server notifications, verifies cryptographic receipt signatures for {{loyalty_tier_sku}}, and updates consumer loyalty ledgers in {{commerce_platform_name}}.
Method
- Configure mock cryptographic payloads representing App Store Server Notifications or Google Play Real-Time Developer Notifications.
- Establish authentication headers utilizing {{auth_token_strategy}} against {{sandbox_environment_type}}.
- Generate realistic payload fixtures for initial purchase, subscription renewal, price increase consent, and cancellation of {{loyalty_tier_sku}}.
- Script HTTP dispatch logic hitting {{webhook_endpoint_url}} to test concurrency and out-of-order delivery.
- Parse server responses to verify database transaction commits and user discount entitlement flags.
- Implement edge-case assertion suites covering expired certificates, fraudulent receipts, and duplicate notification IDs.
- Output structured pass/fail test telemetry with latency measurements.
Constraints
- The script MUST be fully executable using standard enterprise libraries without unverified third-party dependencies.
- Payload validation MUST explicitly test the schema requirements of {{store_billing_api_version}}.
- MUST NOT log sensitive mock consumer identifiers or unmasked card tokens.
- Include explicit timeout controls and HTTP retry logic for resilient sandbox execution.
Output format
1. Test Harness Configuration
Environment variable definitions and dependency package manifests.
2. Executable Verification Script
Complete test script including mock generators, dispatch handlers, and assertion blocks.
3. Assertion Matrix and Diagnostic Guide
Table mapping test scenarios to expected HTTP status codes, webhook actions, and ledger states.
Self-review
- Ensure every mock transaction correctly targets {{loyalty_tier_sku}}.
- Confirm cryptographic verification steps reflect {{store_billing_api_version}} standards.
- Verify assertions cover idempotency and duplicate webhook handling.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.