Skip to content
Longplay
Docs
Browse docs / Merchant execution

Merchant execution

Implement the record_only merchant bridge: requests, responses, errors, result reporting and purchase recovery.

Markdown
API v1Updated

Merchant-native execution#

The execution examples on this page use merchant bridge 3 at POST /integrations/indiana. In record_only mode Longplay returns merchant-native instructions; the merchant owns provider credentials, native orders, fulfilment and consumption. The Longplay API uses protocol 0.10 and accepts no older protocol; its protocol is independent of the merchant bridge version.

  • Configure each App/environment independently. Scope contains no payment-provider account.
  • Managed mode retains Longplay-owned provider execution; record_only uses merchant instructions and normalized merchant facts.
  • Declare only implemented profiles. Trials, discounts, tiers, seats, tax, subscription changes and refunds must match the instruction without dropping terms.

Merchant-prepared quotes#

In record_only mode, the merchant must support the merchant bridge v4 operation.prepare command before Longplay can freeze a quote and produce merchantTerms. Submit the matching merchantConfirmation when confirming the quote.

Preparation uses POST /integrations/indiana with the X-Indiana-Merchant-Bridge-Version: 4 header and bridgeVersion: 4 envelope in both directions. Create the receiver's codec with the Server SDK's createMerchantBridgeProtocol({ manifest, authentication }); use decodeRequest to verify signatures, scope and preparation authority, and encodeResponse to sign the response.

This minimal bridge.describe manifest supports purchase quote preparation. Replace the scope identifiers with those of the current App/environment. Declare preparations in capabilities and include only implemented purchase, subscription_change or refund actions in preparationActions.

preparation.manifest.jsonJSON
{  "bridgeVersion": 4,  "projectId": "44444444-4444-4444-8444-444444444444",  "environmentId": "eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee",  "environment": "sandbox",  "capabilities": [    "preparations"  ],  "catalog": "none",  "billingEvents": [],  "profiles": [],  "checkKinds": [],  "preparationActions": [    "purchase"  ],  "authorizationKinds": [],  "nextActionTypes": [],  "resultEvents": []}
  • operation.prepare computes and returns terms for the saved intent in the signed request; it performs no payment, fulfilment or refund. After the user accepts the terms, merchantConfirmation carries the matching quoteTermsDigest and required consent references and versions.
  • The bridge v3 examples below retain the existing execution and lookup flows. Dispatch preparation requests by version to the v4 codec and preparation handler; copying the v3 handler or changing only its manifest does not implement operation.prepare.

Request and response#

The execution examples below use POST, application/json and X-Indiana-Merchant-Bridge-Version: 3. The strict envelope is bridgeVersion, requestId, scope, command and data; scope contains projectId, environmentId and environment, checked against trusted configuration.

purchase.request.jsonJSON
{  "bridgeVersion": 3,  "requestId": "11111111-1111-4111-8111-111111111111",  "scope": {    "projectId": "44444444-4444-4444-8444-444444444444",    "environment": "sandbox",    "environmentId": "eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee"  },  "command": "purchase.execute",  "data": {    "operationId": "11111111-1111-4111-8111-111111111111",    "customerId": "22222222-2222-4222-8222-222222222222"  }}
purchase.response.jsonJSON
{  "bridgeVersion": 3,  "requestId": "55555555-5555-4555-8555-555555555555",  "command": "purchase.execute",  "scope": {    "projectId": "44444444-4444-4444-8444-444444444444",    "environment": "sandbox",    "environmentId": "eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee"  },  "data": {    "type": "purchase",    "operationId": "11111111-1111-4111-8111-111111111111",    "customerId": "22222222-2222-4222-8222-222222222222",    "merchantExecutionId": "purchase_example",    "merchantOrderId": "order_example",    "paymentStatus": "pending",    "fulfillmentStatus": "not_started",    "recordingStatus": "not_ready",    "checkoutUrl": "https://merchant.example/checkout/order_example",    "checkoutExpiresAt": "2030-01-01T00:30:00.000Z",    "updatedAt": "2030-01-01T00:00:00.000Z",    "problem": null,    "pollAfterMs": 2000  }}

Each HTTP attempt has a new requestId while business identity retains the original operationId. Limits are 16 KiB request and 256 KiB response; refuse redirects and use private, no-store for user responses. A 200/202 carries current facts rather than business completion. The SDK never automatically retries financial execution or opens Checkout.

Authentication and authority#

User commands retain native login and CSRF. authorize binds the native user to the current Customer rather than trusting browser-selected identities. Console/GOP service requests use an environment-bound 32-byte base64url HMAC key kept on backends. A signature grants neither user-session issuance nor arbitrary financial authority.

signature.txtShell
indiana-merchant-bridge:3requestPOST/integrations/indiana<timestamp><exact JSON body>

The signature prefix indiana-merchant-bridge and the path /integrations/indiana are fixed protocol names that keep an earlier internal name for Longplay; use them exactly as shown.

Sign requests and responses separately (response direction is response), with at most 300 seconds clock tolerance. Use signMerchantBridgeMessage / verifyMerchantBridgeMessage and retain old keys for in-flight rotation. Financial commands also require fresh Server SDK operation authority, matching scope, Customer, instruction type and confirmedAt.

Capabilities and commands#

manifest.jsonJSON
{  "bridgeVersion": 3,  "projectId": "44444444-4444-4444-8444-444444444444",  "environmentId": "eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee",  "environment": "sandbox",  "capabilities": [    "session",    "catalog",    "customer_commerce",    "presentation",    "presentation_events",    "purchases",    "operation_status",    "billing_records",    "subscription_changes",    "refunds"  ],  "catalog": "static",  "billingEvents": [    "purchase.completed",    "purchase.closed",    "subscription.observed",    "subscription.change.completed",    "subscription.change.closed",    "invoice.paid",    "refund.updated"  ],  "profiles": [    "purchase.subscription",    "purchase.one_time",    "purchase.prepaid",    "purchase.trial",    "purchase.seats",    "purchase.tiered",    "tax.automatic",    "discount.percent.once",    "discount.percent.repeating",    "discount.percent.forever",    "discount.amount.once",    "discount.amount.repeating",    "discount.amount.forever",    "subscription.cancel.immediate",    "subscription.cancel.renewal",    "subscription.resume",    "subscription.plan.immediate",    "subscription.plan.renewal",    "subscription.seats",    "subscription.quantity",    "subscription.billing_cycle",    "subscription.proration",    "refund.full",    "refund.partial",    "refund.revoke"  ]}
Command authority
commandAuthority
session.createmerchant_user
catalog.readmerchant_catalog_reader
customer.commerce.readmerchant_user
presentation.resolvemerchant_user
presentation.reportmerchant_user
purchase.executemerchant_user
operation.readmerchant_user
subscription.changemerchant_user
refund.executemerchant_refund_authority

Command authority

  • session.create

    Authority
    merchant_user
  • catalog.read

    Authority
    merchant_catalog_reader
  • customer.commerce.read

    Authority
    merchant_user
  • presentation.resolve

    Authority
    merchant_user
  • presentation.report

    Authority
    merchant_user
  • purchase.execute

    Authority
    merchant_user
  • operation.read

    Authority
    merchant_user
  • subscription.change

    Authority
    merchant_user
  • refund.execute

    Authority
    merchant_refund_authority

session.create, catalog.read, customer.commerce.read and presentation.resolve take {}. presentation.report takes {decisionId,eventId}. purchase.execute, operation.read, subscription.change and refund.execute take {operationId,customerId}. bridge.ping echoes challenge and bridge.describe returns declarations without business writes.

Server and browser integration#

merchant-receiver.tsTypeScript
import { createLongplayServer, createMerchantBridgeHandler, createMerchantBridgeAuthorityResolver, type LongplayServerOptions, type MerchantBridgeHandlerOptions, type MerchantBridgeHandlers } from "@tinkerlandai/longplay-sdk/server"; // Your app provides its configuration, native login/CSRF check and commerce handlers.type Native = Required<MerchantBridgeHandlers>;declare const serverOptions: LongplayServerOptions;declare const manifest: MerchantBridgeHandlerOptions["manifest"];declare const authentication: MerchantBridgeHandlerOptions["authentication"];declare const authorizeNativeCommand: MerchantBridgeHandlerOptions["authorize"];declare const native: {  createSession: Native["session.create"];  readCatalog: Native["catalog.read"];  readCommerce: Native["customer.commerce.read"];  resolvePresentation: Native["presentation.resolve"];  reportPresentation: Native["presentation.report"];  executePurchase: Native["purchase.execute"];  readOperation: Native["operation.read"];  changeSubscription: Native["subscription.change"];  executeRefund: Native["refund.execute"];}; const longplay = createLongplayServer(serverOptions);export const POST = createMerchantBridgeHandler({  manifest,  authentication,  authorize: authorizeNativeCommand,  resolveOperationAuthority: createMerchantBridgeAuthorityResolver(longplay),  handlers: {    "session.create": native.createSession,    "catalog.read": native.readCatalog,    "customer.commerce.read": native.readCommerce,    "presentation.resolve": native.resolvePresentation,    "presentation.report": native.reportPresentation,    "purchase.execute": native.executePurchase,    "operation.read": native.readOperation,    "subscription.change": native.changeSubscription,    "refund.execute": native.executeRefund,  },});// Native handlers durably reserve the original operation before external effects.// readOperation returns found or not_received and never starts an operation.

The resolver uses readSubscriptionOperation / readSubscriptionUpdate / readRefund and accepts only returned Longplay authority, never permission inferred from browser quotes or local status. Native handlers retain login, CSRF, durable unique execution reservation and provider idempotency; the SDK lookup is not a concurrency lock.

Browser createMerchantBridge uses native login and sends the current Customer's original operation. Call reset() on logout/account switch. Server Keys, HMAC secrets and refund-administration authority stay out of browsers.

Connection checks#

Console performs signed Ping, discovery and available catalog reads. Capability/profile declarations establish configuration coverage, not payment, fulfilment, refund or recovery success. Verify user/service authority, same-operation concurrency, unknown results, late facts and scope isolation against the deployed receiver.

Issue a Customer session#

session.shShell
curl --fail-with-body --request POST "$MERCHANT_ORIGIN/integrations/indiana" \  --header 'Content-Type: application/json' \  --header 'X-Indiana-Merchant-Bridge-Version: 3' \  --header "Cookie: $MERCHANT_COOKIE" \  --header "Origin: $MERCHANT_ORIGIN" \  --header "X-CSRF-Token: $MERCHANT_CSRF_TOKEN" \  --data '{"bridgeVersion":3,"requestId":"11111111-1111-4111-8111-111111111111","scope":{"projectId":"44444444-4444-4444-8444-444444444444","environment":"sandbox","environmentId":"eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee"},"command":"session.create","data":{}}'
session.response.jsonJSON
{  "bridgeVersion": 3,  "requestId": "55555555-5555-4555-8555-555555555555",  "command": "session.create",  "scope": {    "projectId": "44444444-4444-4444-8444-444444444444",    "environment": "sandbox",    "environmentId": "eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee"  },  "data": {    "nativeUserId": "88888888-8888-4888-8888-888888888888",    "session": {      "customerId": "22222222-2222-4222-8222-222222222222",      "sessionId": "66666666-6666-4666-8666-666666666666",      "accessToken": "gg_ct_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",      "refreshToken": "gg_rt_yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy",      "expiresAt": "2030-01-01T01:00:00.000Z",      "refreshExpiresAt": "2030-01-02T00:00:00.000Z"    }  }}
presentation.response.jsonJSON
{  "bridgeVersion": 3,  "requestId": "55555555-5555-4555-8555-555555555555",  "command": "presentation.resolve",  "scope": {    "projectId": "44444444-4444-4444-8444-444444444444",    "environment": "sandbox",    "environmentId": "eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee"  },  "data": {    "nativeUserId": "88888888-8888-4888-8888-888888888888",    "presentation": {      "customerId": "22222222-2222-4222-8222-222222222222",      "decisionId": "99999999-9999-4999-8999-999999999999",      "offeringVersionId": "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",      "paywallVersionId": "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb",      "variant": "a"    }  }}

After authenticating the native user, the backend calls Longplay createCustomerSession and returns its accessToken/refreshToken pair only to that user. Merchants do not mint Longplay tokens; Customer and Server-Key authority remain separate. Longplay provides accepted targeting and pinned Offering/Paywall; report actual presentation with a stable eventId.

Native catalog#

catalog.shShell
curl --fail-with-body --request POST "$MERCHANT_ORIGIN/integrations/indiana" \  --header 'Content-Type: application/json' \  --header 'X-Indiana-Merchant-Bridge-Version: 3' \  --header "X-Indiana-Bridge-Key-Id: $MERCHANT_BRIDGE_KEY_ID" \  --header "X-Indiana-Bridge-Signature: $MERCHANT_BRIDGE_SIGNATURE" \  --data '{"bridgeVersion":3,"requestId":"11111111-1111-4111-8111-111111111111","scope":{"projectId":"44444444-4444-4444-8444-444444444444","environment":"sandbox","environmentId":"eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee"},"command":"catalog.read","data":{}}'
catalog.response.jsonJSON
{  "bridgeVersion": 3,  "requestId": "55555555-5555-4555-8555-555555555555",  "command": "catalog.read",  "scope": {    "projectId": "44444444-4444-4444-8444-444444444444",    "environment": "sandbox",    "environmentId": "eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee"  },  "data": {    "revision": "catalog-7",    "updatedAt": "2030-01-01T00:00:00.000Z",    "provider": "merchant",    "items": [      {        "merchantProductId": "credits_1500",        "productVersionId": "33333333-3333-4333-8333-333333333333",        "name": "1500 credits",        "kind": "credit_pack",        "merchantPriceId": "native-price-1500",        "currency": "usd",        "amountMinor": 2500,        "interval": "one_time",        "intervalCount": 1,        "includedCredits": "1500",        "creditReset": "none",        "creditPolicyId": "native-credit-pack-v1",        "available": true      }    ]  }}

Catalog provider is merchant; merchantPriceId is an opaque native reference. Bind ProductVersion and Price explicitly. Amounts use minor currency units and catalog currency uses three lowercase letters. Credit packs use one_time and creditReset=none; subscriptions use month/year. creditPolicyId identifies native grant/expiry rules without authorizing duplicate grants.

Execute a confirmed purchase#

purchase.shShell
curl --fail-with-body --request POST "$MERCHANT_ORIGIN/integrations/indiana" \  --header 'Content-Type: application/json' \  --header 'X-Indiana-Merchant-Bridge-Version: 3' \  --header "Cookie: $MERCHANT_COOKIE" \  --header "Origin: $MERCHANT_ORIGIN" \  --header "X-CSRF-Token: $MERCHANT_CSRF_TOKEN" \  --data '{"bridgeVersion":3,"requestId":"11111111-1111-4111-8111-111111111111","scope":{"projectId":"44444444-4444-4444-8444-444444444444","environment":"sandbox","environmentId":"eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee"},"command":"purchase.execute","data":{"operationId":"11111111-1111-4111-8111-111111111111","customerId":"22222222-2222-4222-8222-222222222222"}}'
  • Confirm the original Longplay operation using attach intent=confirm; the receiver cannot infer confirmation from a browser mutation.
  • Read fresh authority. Initial execution requires confirmedAt, initialExecutionAllowed=true, an unexpired instruction and support for every required profile.
  • Match operationId, Customer, configuration/connection revisions, Price lines, quantities, amounts, discounts, trial and tax; map the merchant provider on the backend.
  • A durable unique key covers App, environment, Customer and operationId. Reserve before provider calls and retain the same provider idempotency key; concurrency/redelivery returns the original execution.

Read the original execution#

operation.shShell
curl --fail-with-body --request POST "$MERCHANT_ORIGIN/integrations/indiana" \  --header 'Content-Type: application/json' \  --header 'X-Indiana-Merchant-Bridge-Version: 3' \  --header "Cookie: $MERCHANT_COOKIE" \  --header "Origin: $MERCHANT_ORIGIN" \  --header "X-CSRF-Token: $MERCHANT_CSRF_TOKEN" \  --data '{"bridgeVersion":3,"requestId":"11111111-1111-4111-8111-111111111111","scope":{"projectId":"44444444-4444-4444-8444-444444444444","environment":"sandbox","environmentId":"eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee"},"command":"operation.read","data":{"operationId":"11111111-1111-4111-8111-111111111111","customerId":"22222222-2222-4222-8222-222222222222"}}'
operation.response.jsonJSON
{  "bridgeVersion": 3,  "requestId": "55555555-5555-4555-8555-555555555555",  "command": "operation.read",  "scope": {    "projectId": "44444444-4444-4444-8444-444444444444",    "environment": "sandbox",    "environmentId": "eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee"  },  "data": {    "lookup": "found",    "operationId": "11111111-1111-4111-8111-111111111111",    "customerId": "22222222-2222-4222-8222-222222222222",    "execution": {      "type": "purchase",      "operationId": "11111111-1111-4111-8111-111111111111",      "customerId": "22222222-2222-4222-8222-222222222222",      "merchantExecutionId": "purchase_example",      "merchantOrderId": "order_example",      "paymentStatus": "succeeded",      "fulfillmentStatus": "applied",      "recordingStatus": "accepted",      "checkoutUrl": null,      "checkoutExpiresAt": "2030-01-01T00:30:00.000Z",      "updatedAt": "2030-01-01T00:05:00.000Z",      "problem": null,      "pollAfterMs": null    },    "readAt": "2030-01-01T00:05:00.000Z"  }}

operation.read is strictly read-only and returns lookup=found or not_received. found contains the original execution; not_received has execution=null and cannot create an operation or trigger another charge. Report payment, native fulfilment and Longplay recording separately. Checkout belongs only to an unfinished original purchase.

Native commercial state#

commerce.shShell
curl --fail-with-body --request POST "$MERCHANT_ORIGIN/integrations/indiana" \  --header 'Content-Type: application/json' \  --header 'X-Indiana-Merchant-Bridge-Version: 3' \  --header "Cookie: $MERCHANT_COOKIE" \  --header "Origin: $MERCHANT_ORIGIN" \  --header "X-CSRF-Token: $MERCHANT_CSRF_TOKEN" \  --data '{"bridgeVersion":3,"requestId":"11111111-1111-4111-8111-111111111111","scope":{"projectId":"44444444-4444-4444-8444-444444444444","environment":"sandbox","environmentId":"eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee"},"command":"customer.commerce.read","data":{}}'
commerce.response.jsonJSON
{  "bridgeVersion": 3,  "requestId": "55555555-5555-4555-8555-555555555555",  "command": "customer.commerce.read",  "scope": {    "projectId": "44444444-4444-4444-8444-444444444444",    "environment": "sandbox",    "environmentId": "eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee"  },  "data": {    "customerId": "22222222-2222-4222-8222-222222222222",    "revision": "12",    "observedAt": "2030-01-01T00:00:00.000Z",    "subscriptions": [      {        "merchantSubscriptionId": "sub_example",        "merchantProductId": "starter_month",        "productVersionId": null,        "status": "active",        "currentPeriodStartsAt": "2030-01-01T00:00:00.000Z",        "currentPeriodEndsAt": "2030-02-01T00:00:00.000Z",        "cancelAtPeriodEnd": false,        "scheduledChange": null      }    ],    "purchaseHistory": {      "complete": true,      "hasPaidPurchase": true,      "lastPaidAt": "2030-01-01T00:00:00.000Z"    },    "balances": [      {        "bucketId": "credit_pack_order_example",        "key": "creation_credits",        "available": "1500",        "expiresAt": null,        "nextResetAt": null      }    ]  }}

Return current native subscriptions, purchase history and balance tranches. Incomplete history cannot establish first-purchase eligibility. Clear snapshots on account change; the business backend continues authorizing access and consumption. Synchronize facts to Longplay only through trusted backends.

Changes, refunds and recovery#

subscription.change and refund.execute use the same fresh authority, original-operation lookup and durable idempotency. Follow cancellation/resumption/plan/seats/quantity/billing-cycle/proration instructions; report scheduled separately from applied. Refunds bind the original Invoice, amount, currency and entitlement policy, including required subscription cancellations.

After a lost response or provider timeout, recover the same operationId. RESULT_UNKNOWN requires retryable=false and recovery=recover_operation. Do not create a new purchase, automatically retry financial effects or infer nonexecution from pending. Closing the page only stops waiting; reconcile and deliver late facts from the original confirmed execution.

Record merchant facts#

Verify native provider results and durably retain normalized facts alongside settlement/recovery, then call recordMerchantEvent with a Server Key holding billing:write. Longplay uses /api/v1/merchant/events/record and current X-Indiana-Protocol rather than the bridge envelope. Merchant records require no Stripe objects or provider secrets.

record-merchant-event.request.jsonJSON
{  "eventId": "native:purchase:order_example",  "type": "purchase.completed",  "occurredAt": "2030-01-01T00:00:00.000Z",  "operationId": "11111111-1111-4111-8111-111111111111",  "customerId": "22222222-2222-4222-8222-222222222222",  "merchantOrderId": "order_example",  "paymentStatus": "paid",  "invoice": {    "merchantInvoiceId": "invoice_example",    "currency": "USD",    "subtotalMinor": 2500,    "discountMinor": 0,    "taxMinor": 0,    "totalMinor": 2500,    "paidMinor": 2500,    "periodStartsAt": null,    "periodEndsAt": null,    "lines": [      {        "merchantLineId": "line_example",        "priceId": "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",        "quantity": 1,        "subtotalMinor": 2500,        "discountMinor": 0,        "taxMinor": 0,        "totalMinor": 2500,        "periodStartsAt": null,        "periodEndsAt": null      }    ]  },  "subscription": null}
record-merchant-event.response.jsonJSON
{  "requestId": "55555555-5555-4555-8555-555555555555",  "scope": {    "projectId": "44444444-4444-4444-8444-444444444444",    "environment": "sandbox"  },  "record": {    "id": "77777777-7777-4777-8777-777777777777",    "eventId": "native:purchase:order_example",    "source": "merchant",    "providerVerified": false,    "outcome": "activated"  }}
Event set
ScenariotypeRule
Purchasepurchase.completedOriginal confirmed operation, order and reconciled Invoice/subscription; paid purchases require the full Invoice.
Closed purchasepurchase.closedfailed, expired or canceled without fabricated success.
Subscriptionsubscription.observedMonotonic revision, complete items, valid period and hasDiscounts. A null operationId records a native subscription whose items are recurring Prices.
Changesubscription.change.completedOriginal operation; scheduled requires scheduledFor while applied has no scheduled time.
Change closedsubscription.change.closedOriginal change failed, expired or canceled before applying; keeps the subscription and optional unpaid Invoice reference.
Paymentinvoice.paidComplete Invoice lines, amounts and periods. A renewal names its native subscription; a one-time native payment, such as a credit pack or automatic top-up, uses null.
Refundrefund.updatedStable refund reference, positive amount, currency and actual state. A native refund uses a null operationId and names its Invoice with merchantInvoiceId; a later failed reverses the accepted refund. Card dispute funds are reported as a native refund under the dispute reference: withdrawn as succeeded, reinstated as failed.

Event set

  • Purchase

    type
    purchase.completed
    Rule
    Original confirmed operation, order and reconciled Invoice/subscription; paid purchases require the full Invoice.
  • Closed purchase

    type
    purchase.closed
    Rule
    failed, expired or canceled without fabricated success.
  • Subscription

    type
    subscription.observed
    Rule
    Monotonic revision, complete items, valid period and hasDiscounts. A null operationId records a native subscription whose items are recurring Prices.
  • Change

    type
    subscription.change.completed
    Rule
    Original operation; scheduled requires scheduledFor while applied has no scheduled time.
  • Change closed

    type
    subscription.change.closed
    Rule
    Original change failed, expired or canceled before applying; keeps the subscription and optional unpaid Invoice reference.
  • Payment

    type
    invoice.paid
    Rule
    Complete Invoice lines, amounts and periods. A renewal names its native subscription; a one-time native payment, such as a credit pack or automatic top-up, uses null.
  • Refund

    type
    refund.updated
    Rule
    Stable refund reference, positive amount, currency and actual state. A native refund uses a null operationId and names its Invoice with merchantInvoiceId; a later failed reverses the accepted refund. Card dispute funds are reported as a native refund under the dispute reference: withdrawn as succeeded, reinstated as failed.
Non-financial results
ScenariotypeRule
Fulfilmentfulfillment.updatedNative fulfilment progress of an original dispatched operation; an unfinished fulfilment keeps the operation pending.
Native benefitsbenefit.claimed / benefit.closed / benefit.updatedA native benefit issuance (resource, unit, quantity, expiry), a definite outcome that it was never issued, and its later state; the original issuance is kept.
Auto top-up authorizationauthorization.updatedThe actual state of a native auto_topup authorization; consent or revocation creates no payment.
Native usage and balanceusage.observed / balance.observedA native consumption or reversal (a reversal names its recorded original), and a merchant-owned balance reading; neither is spendable in Longplay or replaces an entitlement check.
Coupon redemptioncoupon.redeemedCoupon use that did not go through a Longplay operation: carry grantId plus productVersionId and subscriptionId, or merchandiseId. Accepted in any payment execution mode.

Non-financial results

  • Fulfilment

    type
    fulfillment.updated
    Rule
    Native fulfilment progress of an original dispatched operation; an unfinished fulfilment keeps the operation pending.
  • Native benefits

    type
    benefit.claimed / benefit.closed / benefit.updated
    Rule
    A native benefit issuance (resource, unit, quantity, expiry), a definite outcome that it was never issued, and its later state; the original issuance is kept.
  • Auto top-up authorization

    type
    authorization.updated
    Rule
    The actual state of a native auto_topup authorization; consent or revocation creates no payment.
  • Native usage and balance

    type
    usage.observed / balance.observed
    Rule
    A native consumption or reversal (a reversal names its recorded original), and a merchant-owned balance reading; neither is spendable in Longplay or replaces an entitlement check.
  • Coupon redemption

    type
    coupon.redeemed
    Rule
    Coupon use that did not go through a Longplay operation: carry grantId plus productVersionId and subscriptionId, or merchandiseId. Accepted in any payment execution mode.

recordMerchantEvent is the single entry for merchant results. Except coupon.redeemed, these events are accepted only in record_only environments. Non-financial results create no Invoice, revenue, spendable balance or platform usage. They follow the same eventId replay and conflict rules: an identical fact under one revision is a duplicate, and an older revision is stale.

Native facts record real transactions that Longplay did not start. They record money and subscriptions and are never attributed to a Funnel Run. Never send native facts for an order, subscription, Invoice or refund that a Longplay operation created; use that operation's events. A native subscription records subscription facts only, without a holding or balance. Record a subscription before its Invoices, and an Invoice before its refunds. An older observation of the same refund does not change money.

Use an ISO occurredAt observation time. Retries retain both eventId and exact facts. Invoice lines retain Price, quantity, debit/credit amounts, discount, tax and period; sums reconcile with the Invoice and paidMinor equals totalMinor. Native subscriptions include every unique Price item.

A durable outbox delivers at least once with stable event IDs and follows upstream recovery/Retry-After. Retain permanent conflicts for resolution. providerVerified=false records merchant provenance; a receipt substitutes for neither native fulfilment nor Longplay operation completion. Reread actual state on both sides.

Errors and recovery#

bridge-error.jsonJSON
{  "bridgeVersion": 3,  "requestId": "55555555-5555-4555-8555-555555555555",  "command": "purchase.execute",  "scope": {    "projectId": "44444444-4444-4444-8444-444444444444",    "environment": "sandbox",    "environmentId": "eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee"  },  "error": {    "code": "MERCHANT_BRIDGE_TERMS_CHANGED",    "message": "The quoted Price no longer matches the native catalog.",    "retryable": false,    "recovery": "refresh_catalog"  }}

Preserve structured code, retryable and recovery. Stop dispatch on missing confirmation, scope mismatch, expiry or missing capability and resolve the cause. RESULT_UNKNOWN/RECOVERY_REQUIRED recover only the original operation. Longplay authentication failures indicate backend configuration rather than user logout; retain Longplay's own recording error envelope.

Related: SDK·Payment connections