Skip to content
Guide

Connect your product as a project.

In Efespay every SaaS product is a project: it has its own key, webhook endpoint, checkout branding, customers and subscriptions, while payments still come together under one business. This guide describes the contract between a project and Efespay.

The API and test environment are in pre-pilot preparation. Live mode opens once the business application is approved.

Project model

A project is not a separate account: connections, rates, routing, risk rules and the team belong to the business. The project carries its own identity and records on top of them.

Business, connections and projects
Business (e.g. Aksungur Yazılım)
├─ provider connections (pc_…: iyzico, Stripe, PayTR, bank virtual POS, test)
└─ projects (prj_…: CasaX, Mühür Mail, PergePOS …)
     ├─ branding (name, logo, colour, support, website and policy links)
     ├─ allowed connections (empty = all of the business's connections)
     ├─ API keys (efp_test_… / efp_live_…, bound to the project)
     ├─ webhook endpoints
     └─ customers, saved cards, payments, refunds, subscriptions, events
  • The money flow does not change: funds settle to the account of the connection the project uses; Efespay never holds money.
  • A project is independent of mode: the same prj_… id is used in test and live, and records are kept apart by mode.
  • A project-bound key sees only that project's records, and every record it writes belongs to that project. A business-wide (project-less) key sees every project and may pass project: "prj_…" when opening a session.
  • A customer's external_reference is unique within a project: the same value in two projects is two different customers. Order references and Idempotency-Key values are also unique per project.
  • If the project has selected connections (connections), routing only uses those; the others are excluded in the routing decision with the reason project.
  • Checkout branding comes from the project; any field left empty falls back to the business's checkout settings. Allowed return addresses are the union of the project's and the business's allowed addresses.
  • Every /v1 object carries project_id: "prj_…" | null, and so does the event envelope.
  • Revenue that does not go through Efespay (in-app store purchases, bank transfer, cash, manual assignment) is reported to the project as a record only (Payments taken outside Efespay); it does not mix with the money flow or provider figures.

What the project does

Taking payments for a product through Efespay takes five steps. The sections below cover each one.

What the project does
StepNote
1.EFESPAY_API_KEY (a project-bound secret key) and EFESPAY_WEBHOOK_SECRET on your serverThe key never goes into a browser or mobile app. You create both on the project's page in the dashboard; each is shown only once.
2.Save your order or subscription as pending, then call POST /v1/payment-sessionsorder_reference is your own record's id; send an Idempotency-Key.
3.Open the returned url in a new tabNo iframe; see Checkout in a new tab.
4.On your POST /api/webhooks/efespay endpoint, verify the signature, deduplicate the event and update the recordThe webhook is the single source of truth; see Webhooks.
5.On the return page (success_url), ask your server about the session and call the same completion functionIf the webhook is late, the user does not wait; both paths lead to the same idempotent function.

The webhook handler and the return page call the same completion function. It finds the order by order_reference, checks the amount and currency, and does nothing if the order is already complete.

Payment session

A session is opened with POST /v1/payment-sessions (scope payment_sessions:write). The general fields are in the developer documentation; the fields added for projects are here.

Payment session with a basket (project-bound key)
curl https://api.efespay.com/v1/payment-sessions \
  -H "Authorization: Bearer $EFESPAY_API_KEY" \
  -H "Idempotency-Key: order-65f0c1-1" \
  -H "Content-Type: application/json" \
  -d '{
    "order_reference": "order-65f0c1",
    "currency": "TRY",
    "description": "Mühür Mail credits",
    "line_items": [
      { "name": "1,000 credits", "quantity": 2, "unit_amount_minor": 45000 },
      { "name": "Priority support", "description": "One month", "quantity": 1, "unit_amount_minor": 20000 }
    ],
    "customer": { "external_reference": "merchant_65f0c1", "name": "Örnek A.Ş.", "email": "muhasebe@ornek.com" },
    "success_url": "https://muhurmail.com/app/billing/return?session_id={SESSION_ID}",
    "cancel_url": "https://muhurmail.com/app/billing"
  }'

# amount_minor is omitted: it is the sum of line_items (110000 = ₺1,100.00).
Session fields added for projects
FieldRule
kindpayment (default), subscription (see Subscriptions) or setup. setup saves a card without a charge: Efespay opens a subscription's card update session with this kind, and your product can use it to have a card added without taking a payment (Saved cards).
line_itemsLines shown as a basket on the checkout page, at most 50. Display only; they are not sent to the provider.
success_urlWhere the customer returns after a successful payment. Must be on an allowed address (400 return_url_not_allowed). The {SESSION_ID} and {PAYMENT_ID} placeholders are filled in.
cancel_urlAddress for cancel, expired or cancelled sessions; same rules. If either address is omitted, return_url is used in its place.
projectOnly meaningful with a business-wide key. With a project-bound key a different project returns 400 project_mismatch; an unknown project returns 400 project_not_found, an archived one 409 project_archived.

Basket line (line_items)

Basket line (line_items)
FieldRequiredDescription
nameRequiredLine name, up to 120 characters.
descriptionOptionalShort description, up to 255 characters.
quantityRequiredQuantity, 1–9999.
unit_amount_minorRequiredUnit amount in minor units (0 or more).
  • If amount_minor is omitted it is the sum of the lines; if given, it must equal that sum (400 line_items_amount_mismatch).
  • It cannot be combined with marketplace items (400 line_items_with_items); an invalid line returns 400 invalid_line_items with param pointing at the line.
  • If locale is omitted, the project's default language is used.
Response: payment_session (201)
{
  "id": "ps_…",
  "object": "payment_session",
  "kind": "payment",
  "status": "open",
  "url": "https://efespay.com/pay/ps_…",
  "payment_id": "pay_…",
  "project_id": "prj_…",
  "amount_minor": 110000,
  "line_items": [
    {
      "name": "1,000 credits",
      "description": null,
      "quantity": 2,
      "unit_amount_minor": 45000,
      "amount_minor": 90000
    },
    {
      "name": "Priority support",
      "description": "One month",
      "quantity": 1,
      "unit_amount_minor": 20000,
      "amount_minor": 20000
    }
  ],
  "success_url": "https://muhurmail.com/app/billing/return?session_id=ps_…",
  "cancel_url": "https://muhurmail.com/app/billing",
  "subscription_id": null,
  "subscription": null,
  "expires_at": "2026-11-22T11:00:00.000Z"
}
  • Fields the response adds for projects: kind, project_id, line_items, success_url, cancel_url, subscription_id, subscription.
  • Opening a session also opens its payment: payment_id (pay_…) is set in the first response; payment endpoints and events match on it.
  • success_url and cancel_url are the effective addresses with placeholders filled in.
  • subscription_id is set on a subscription session once the payment succeeds; on a card update session it is set from the start.
  • subscription carries the terms of a subscription start session ({ interval, interval_count, amount_minor, plan_reference, quantity }); on other sessions it is null.
  • Lifetime: an unpaid session stays open for 60 minutes by default (expires_at); expires_in_minutes changes this to anything from 5 to 10080 minutes. Subscription sessions that Efespay opens stay open for 60 minutes (card update) or 7 days (the billing job's period payment).
  • Once expires_at has passed, the page does not start a payment. The reconciliation job (every 5 minutes) marks the session and its payment expired, the order lock is released, and payment.expired is published for the session's pending payment even if the customer never started paying. If the customer is on the provider's page at that moment, that attempt settles first.
  • metadata is copied to the payment (the payment object and payment.* events); it is not copied to the subscription.
  • Amounts are gross: the total charged to the customer, tax included. Efespay has no tax field; the VAT breakdown and the invoice are your product's job (line_items are display only).

Closing an open session

POST /v1/payment-sessions/{id}/cancel (body { reason? }, scope payments:cancel; the same as POST /v1/payments/{id}/cancel, Idempotency-Key recommended) returns the payment_session with status: "cancelled". A session whose payment has not started, or whose last attempt was declined, is closed, the order lock is released (a new session can be opened with the same order_reference) and payment.cancelled is published. A session that cannot be closed returns 409:

Closing a session
POST /v1/payment-sessions/ps_…/cancel
Idempotency-Key: cancel-order-65f0c1
{ "reason": "Customer started a new checkout" }

→ { "id": "ps_…", "object": "payment_session", "status": "cancelled", … }
409 codes when closing a session
CodeMeaning and what to do
payment_already_succeededThe session has been paid (or is authorised); this endpoint does not void. Complete your record; to give the money back, use /v1/payments/{id}/cancel or /refunds with payment_id.
payment_not_cancellableThe session is already closed (cancelled, expired): treat it as closed.
payment_in_progressThe customer is on the provider's page right now; Efespay asked the provider and the payment can still go through. Try again a little later.
payment_uncertainThe result of the last attempt is unknown; wait for the payment.succeeded or payment.failed event.
session_managed_by_subscriptionThis is the payment session of a subscription period (a card update request returns the same session); closing it would leave the period unpaid. Use the same session or cancel the subscription.
  • Recommended pattern: before opening a new session for the same purchase, close the previous one; otherwise both sessions could be paid in two tabs.
  • If closing returns 200 or payment_not_cancellable, open the new session. If it returns payment_already_succeeded, do not open a new session; complete the previous one. If it returns payment_in_progress or payment_uncertain, tell the customer "your payment is being processed".
  • If a late success arrives from the provider for a closed session, the payment still becomes succeeded (late_success: true) and payment.succeeded is published: the business refunds it.

How the checkout page behaves

  • The page carries the project's name, logo and colour, and lists the basket lines when there are any.
  • After a successful payment it shows a receipt summary and a "Back to ‹Project›" button; if success_url is set, it goes there automatically after 5 seconds.
  • The "Cancel" link on the payment form leads to cancel_url. The session stays open; close it with POST /v1/payment-sessions/{id}/cancel if you want to.
  • An expired or cancelled session also offers the way back to cancel_url.
  • When a card is declined (payment.failed) the session stays open; the customer retries in the same session (same payment, new attempt).

The browser returning to success_url is not proof of payment. Learn the status from GET /v1/payment-sessions/{id} or the webhook.

Order reference formats

For the sessions and charges your product opens, order_reference is the value you give. Payments that Efespay opens use the formats below (<id> is the subscription id after sub_):

Order reference formats
PaymentOrder reference
Subscription start (checkout page, period 1)The value your product gave
Period payment: the billing job, and the overdue-period, reactivation and early-renewal sessions of a card update requestSUB-<id>-<period> (periods start at 1; the payment's subscription_period)
Proration chargeSUB-<id>-ADJ-<n> (subscription_period: null, metadata.kind: "proration")
Card update (kind: "setup", amount 0; no payment events)SUB-<id>-CARD-<8 characters>

To route an event, rely on subscription_id rather than the format: it is set on every payment linked to a subscription.

Checkout in a new tab

The Efespay checkout page is never placed in an iframe. Your product opens it in a new tab and follows the result from its own server.

  1. On click, open an empty tab before the request: window.open("", "_blank"). That way the popup blocker lets it through.
  2. Your server saves the record as pending, opens the session and returns url; set the tab's location to url. If anything fails, close the tab.
  3. The main tab switches to a "Payment opened in a new tab" state and polls your own server every 2–3 seconds (or waits for a socket event).
  4. success_url is a small return page in your product: it has your server verify the session, tells the main tab via BroadcastChannel("efespay-checkout"), says "You can close this tab" and tries window.close().
Main tab: starting the payment
// Main tab: the "Pay" button handler
async function startCheckout(planId) {
  // 1. Open the tab before the request, inside the click, so the popup blocker allows it
  const tab = window.open("", "_blank");
  try {
    // 2. Your server saves the order as pending and opens the Efespay session
    const res = await fetch("/api/billing/checkout", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ planId }),
    });
    if (!res.ok) throw new Error("checkout_failed");
    const { url } = await res.json();
    tab.location.href = url;
  } catch (error) {
    tab?.close();
    throw error;
  }
  // 3. Show "Payment opened in a new tab" and poll your own server every 2–3 seconds
  showWaitingState();
}

// 4. The return page tells this tab that the payment is confirmed
new BroadcastChannel("efespay-checkout").onmessage = (event) => {
  if (event.data?.type === "completed") refreshBilling();
};
Return page (success_url)
// success_url page: /app/billing/return?session_id={SESSION_ID}
const sessionId = new URLSearchParams(location.search).get("session_id");

// Your server calls GET /v1/payment-sessions/{id} and runs the same idempotent
// completion function as the webhook handler.
const res = await fetch(`/api/billing/confirm?session_id=${encodeURIComponent(sessionId)}`);
const { paid } = await res.json(); // your own response shape

if (paid) {
  new BroadcastChannel("efespay-checkout").postMessage({ type: "completed", sessionId });
}
// The page also says "You can close this tab"; browsers may refuse window.close()
window.close();

Mobile apps have no purchase screen (store rules); the app shows the subscription read-only.

Subscriptions

Efespay charges the saved card each period itself; on a connection that cannot save cards with a guarantee (iyzico), it opens the subscription through the provider's own subscription API and mirrors the provider's charges (engine: "provider", Engine differences). The plan catalogue, trials and entitlements stay in the project; Efespay is only told "charge this customer this amount at this interval".

Starting a subscription

Subscription session
POST /v1/payment-sessions
{
  "kind": "subscription",
  "order_reference": "sub-65f0c1…-1",
  "amount_minor": 108000,
  "currency": "TRY",
  "description": "Mühür Mail Standart — aylık",
  "line_items": [{ "name": "Standart paket", "quantity": 10, "unit_amount_minor": 10800 }],
  "customer": { "external_reference": "merchant_65f0c1…", "name": "Örnek A.Ş.", "email": "muhasebe@ornek.com" },
  "subscription": { "interval": "month", "interval_count": 1, "plan_reference": "standart-monthly", "quantity": 10 },
  "success_url": "https://muhurmail.com/app/billing/return?session_id={SESSION_ID}",
  "cancel_url": "https://muhurmail.com/app/billing"
}
Subscription session fields
FieldRule
amount_minorThe amount charged now: the first period, total including tax.
subscription.amount_minorAmount for the following periods. Defaults to the session amount; set it when the first period is discounted or prorated.
subscription.intervalinterval_countday, week, month or year, plus the interval count (interval_count: at most 365 days, 52 weeks, 12 months or 5 years).
subscription.plan_referenceYour product's own plan key (up to 100 characters). Efespay does not interpret it; it comes back on the object and in events.
subscription.quantityInformational quantity (seats, branches; 1–100000, default 1). The amount is always the total.
subscription.retry_daysfinal_actionmax_chargesmetadataRetry days for a failed period, cancel or pause after the last retry, maximum number of charges and free-form metadata.
subscription.replacesOptional sub_…: this subscription replaces that one (an interval change, e.g. monthly to yearly). Checked when the session is opened: same project (unknown or another project's subscription is 404 subscription_not_found), same customer (409 subscription_replace_customer_mismatch), not cancelled, not ended and not already replaced by another subscription (409 subscription_replace_not_live); param: "subscription.replaces".
customer.external_referenceRequired (400 customer_reference_required). The customer is matched by this value within the project.
  • There are no instalments: installment_options may only be [1] (400 installments_not_allowed).
  • capture: "manual" and marketplace items are not available (400 invalid_subscription, param: "capture" or "items"). An error in the subscription field also returns 400 invalid_subscription, with param naming the field (subscription.interval …).
  • At least one of the project's connections must be able to carry the subscription: a connection that saves the card with a guarantee (the Efespay test provider, Stripe; Efespay charges) or an iyzico connection with provider-managed subscriptions enabled (iyzico charges, Efespay mirrors; currency TRY, USD or EUR, first period amount equal to subscription.amount_minor; Engine differences). If there is neither, 409 payment_method_unavailable.
  • The payment only goes through these connections; if both kinds are available, the connection Efespay charges through is preferred.
  • The checkout page shows the amount, the interval and that the customer can cancel at any time. The customer cannot pay without ticking the versioned consent (card saving and the subscription authorisation sentence; the two versions are recorded separately).
  • Efespay has no trial period: a trial without a card is your product's own record; when it ends, you open the subscription session.
  • On a successful payment the subscription (sub_…) is created in the same transaction. This payment is its first period (subscription_id, subscription_period: 1, period_start / period_end); current_period_start is now and current_period_end is the next period date.
  • The session's metadata is copied to the first payment, and subscription.metadata to the subscription (and to later period payments).
  • Events arrive in this order: payment.succeeded, payment_method.created, subscription.created. subscription.created is published after the card is saved and carries payment_method_id.
  • If a late success arrives for an expired or cancelled session, no subscription is created: payment.succeeded arrives with an empty subscription_id, and the business refunds it.

Subscription object

Subscription object
FieldMeaning
project_idThe subscription's project (prj_…); period payments are opened in this project too.
customer_idcustomer_external_referencecus_… and the customer's id within the project (the session's customer.external_reference): you can find your own tenant or account from the event without storing anything beforehand. Updated if the customer's reference changes.
plan_referencequantityThe values your product sent.
metadataThe subscription session's subscription.metadata (for a subscription created with POST /v1/subscriptions, the body's metadata); copied to period payments.
current_period_startcurrent_period_endBounds of the last paid period. Grant access until current_period_end.
cancel_at_period_endcancel_atCancellation is scheduled for the end of the period.
pause_reasonrequested, payment_failed or payment_method_unavailable.
payment_method_idnull if the card could not be saved; the subscription becomes paused at the next period (payment_method_unavailable). On an engine: "provider" subscription it is always null (the card is with the provider), so it never pauses for this reason.
pending_changeA change waiting on a proration charge whose result is unknown; null otherwise. Shape: { <changed fields>, proration: { amount_minor, payment_id, status: "uncertain" }, requested_at }. For a change session, proration.status is requires_payment or applying, with session_id and retry: { attempts, last_error, next_attempt_at } | null as well.
engineoriginWho charges the periods: efespay or provider (provider-managed; Engine differences), and how the subscription was created (checkout or api).
capabilitiesThe engine's capabilities: { charge_now, change_session, interval_change, pause, undo_cancel, off_session_charge } (Engine differences). Branch on these, not on the provider's name. They do not depend on the state; the state is still checked when the operation runs.
replacesreplaced_byreplacement_cancelThe link between a subscription and its replacement. If replaced_by is set and the subscription is still live, its cancellation could not be confirmed at the provider: replacement_cancel: { attempts, last_error, next_attempt_at }; Efespay retries until it is confirmed.
change_failureThe last change that was paid for but could not be applied: { reason, payment_id, amount_minor, changes, failed_at }; null otherwise (subscription.change_failed).
What subscription statuses mean in your product
EfespayIn your product
activeActive; access until current_period_end.
past_dueThe payment failed and is being retried. Access continues for your product's grace period.
pausedCharging stopped (no card, or retries exhausted). Ask the customer for a new card.
cancelledendedFinished. Access ends at current_period_end.

Changes and cancellation

Plan upgrade and cancellation at period end
POST /v1/subscriptions/sub_…
Idempotency-Key: upgrade-65f0c1-15
{ "amount_minor": 162000, "quantity": 15, "plan_reference": "standart-monthly", "proration": "charge_now" }

POST /v1/subscriptions/sub_…/cancel
{ "at_period_end": true, "reason": "Moved to the free plan" }
Subscription change fields
FieldRule
amount_minorquantityplan_referencedescriptionmetadatapayment_methodPartial update (POST /v1/subscriptions/{id}, scope subscriptions:write): fields you leave out do not change. metadata is replaced as a whole: the object you send takes the place of the old one and is not merged; {} or null clears it.
intervalinterval_countThe interval can only change with proration: "charge_now"; the period anchor moves to now.
cancel_at_period_endtrue schedules cancellation at period end, false withdraws it.
prorationnone (default): the object (amount_minor, quantity, plan_reference) changes immediately and subscription.updated is published, but the new price applies from the next period's charge; there is no charge or refund for the paid period. Your product decides when entitlements (plan features) change. charge_now: the difference is charged to the saved card right away; Idempotency-Key is required.
  • The calculation is in minor units, as integers. Same interval: difference = max(0, round((new − old) × remaining_time / period_length)). Rounding is half up, times are in milliseconds, and "period" is the last paid period.
  • Below 100 minor units nothing is charged and the change is still applied. Downgrades (new ≤ old) are not refunded; the new amount applies from the next period.
  • Interval change: credit = floor(old × remaining_time / period_length), charge = max(0, new − credit); the new period starts now. Charges below 100 minor units are skipped here too; retry_days longer than the new period are dropped.
  • The charge is a payment: subscription_id set, subscription_period: null, metadata.kind: "proration", order reference SUB-<id>-ADJ-<n>. It is only made on an active subscription with no unpaid period; otherwise 409 subscription_state_invalid.
  • The response is the subscription object with proration: { amount_minor, payment_id, status } (status: none, succeeded or uncertain). If nothing was charged, amount_minor: 0 and payment_id: null.
  • If the card declines, nothing changes: 402 proration_payment_failed. The body is { error: { code, message, request_id, failure: { code, message, provider_code }, payment } }; payment is the failed proration payment.
  • If the result is unknown, the change waits as pending_change. Meanwhile a new change returns 409 subscription_change_pending, and the period charge waits too. If reconciliation finds the charge successful the change is applied, otherwise it is dropped; subscription.updated is published either way.
  • If another write (the billing job or another request) wins at the same moment, the result is 409 subscription_state_invalid and nothing changes.
  • A provider-managed subscription (engine: "provider") has no charge_now, no interval change, no payment_method change, no undoing a cancellation and no pause or resume: Engine differences.

When the difference cannot be charged right away

  • When charge_now is not possible (the engine lacks it, or there is no card), the error body tells you the way forward: error.fallback is "change_session" for the same interval and "replace" for an interval change. subscription_proration_unsupported also carries error.capabilities.
  • The one recommended pattern: try charge_now, then fall back to one of the two routes below according to the hint. Both routes work the same on both engines.

Change session

POST /v1/subscriptions/{id}/change-session (scope subscriptions:write, Idempotency-Key recommended) takes { amount_minor?, quantity?, plan_reference?, description?, metadata?, success_url?, cancel_url?, locale? }. An interval field returns 400 change_session_interval_unsupported (fallback: "replace"); an empty body returns 400 subscription_change_empty.

Change session (with a difference)
POST /v1/subscriptions/sub_…/change-session
Idempotency-Key: upgrade-65f0c1-15
{
  "amount_minor": 162000,
  "quantity": 15,
  "plan_reference": "standart-monthly",
  "success_url": "https://muhurmail.com/app/billing/return?session_id={SESSION_ID}",
  "cancel_url": "https://muhurmail.com/app/billing"
}

→ 201 {
  "subscription": { "id": "sub_…", "pending_change": { … } },
  "session": { "id": "ps_…", "object": "payment_session", "kind": "payment", "url": "https://efespay.com/pay/ps_…" },
  "proration": { "amount_minor": …, "payment_id": "pay_…", "status": "requires_payment" }
}
  • The difference is calculated the same way as charge_now for the same interval.
  • If there is no difference (a downgrade, the same amount, less than 100 minor units, or no paid period), the change is applied immediately, like proration: "none": 200 { subscription, session: null, proration: { amount_minor: 0, payment_id: null, status: "none", reason } }, where reason is downgrade, no_amount_change, below_minimum or no_paid_period.
  • If there is a difference, the response is 201 { subscription, session, proration: { amount_minor, payment_id, status: "requires_payment" } }. session is a hosted one-off payment session (kind: "payment", subscription_id set; 3-D Secure as usual). Any connection that takes normal payments for the project can be used, and no saved card is needed; the card is not saved and the subscription's card does not change.
  • The change becomes pending_change (proration.status: "requires_payment", session_id); meanwhile a new change returns 409 subscription_change_pending.
  • It can only be opened on an active subscription with no unpaid period; on the provider engine, cancellation must also not be scheduled for period end (otherwise 409 subscription_state_invalid). The difference payment is an ordinary payment: subscription_id, subscription_period: null, metadata.kind: "proration", order_reference SUB-<id>-ADJ-<n>.
  • Once the payment succeeds, on the efespay engine the change is applied immediately and the new amount renews from the next period; on the provider engine the new amount takes effect at the provider from the next period (a plan change) and is applied once confirmed. In both cases payment.succeeded arrives first, then subscription.updated.
  • If it cannot be confirmed at the provider, the payment stays successful, pending_change.proration.status becomes applying (retry: { attempts, last_error, next_attempt_at }) and Efespay retries with back-off: 5 min, 15 min, 1 h, 6 h, 12 h, 24 h, 24 h (about 3 days).
  • Final state: if the retries run out, the subscription ends in the meantime, or a late success arrives after the session was dropped, the pending change is removed, change_failure is set on the object and subscription.change_failed is published. Refund the difference (change_failure.payment_id) or send the change again with proration: "none".
  • If the session is closed without payment (POST /v1/payment-sessions/{id}/cancel) or expires, the change is dropped (subscription.updated, pending_change: null); nothing changes.

Replacement subscription

  • For an interval change (on both engines), a new subscription session is opened with subscription.replaces: "sub_…".
  • When the first payment succeeds, the new subscription carries replaces and the old one is cancelled immediately in the same flow (subscription.cancelled, cancel_reason: "replaced", replaced_by). Event order: the new subscription's subscription.created first, then the old one's subscription.cancelled.
  • On the provider engine the old subscription is cancelled at the provider first. If that cannot be confirmed, the new subscription is still valid; the old one stays live, is marked with replaced_by and replacement_cancel (subscription.updated), and Efespay retries until it is confirmed. If the provider charges the old period meanwhile, the usual payment.succeeded and subscription.renewed arrive; refund it.
  • Efespay does not calculate refunds or credit; your product decides what the unused time is worth. On the efespay engine you do this by lowering the first amount (amount_minor); on the provider engine the first amount must equal the recurring amount (409 subscription_first_amount_unsupported), so if there is credit, you refund it.

Cancellation

POST /v1/subscriptions/{id}/cancel takes { at_period_end?, reason? }. at_period_end: true schedules cancellation for the end of the period (subscription.updated) and the subscription becomes cancelled when it arrives. Without it, cancellation is immediate (subscription.cancelled; the unpaid period's session is closed). On immediate cancellation current_period_start and current_period_end do not change (the end of the paid period stays; there is no refund): whether access continues until then or ends right away is your product's decision. Use /pause and /resume to pause and continue.

Card update and overdue payments

POST /v1/subscriptions/{id}/payment-session (optional success_url, cancel_url, locale) returns a payment_session with a url. Efespay sets up the session according to the subscription's state:

Card update and overdue payments
StateSession
An unpaid period exists (past_due)The amount of that period (the same payment). On success the new card is attached to the subscription and it becomes active (subscription.renewed).
Paused because of a card problem (paused; pause_reason payment_failed or payment_method_unavailable)The period amount. The new period starts at the moment of payment (current_period_start is now), the new card is attached and the subscription becomes active (subscription.renewed, subscription.resumed).
No unpaid period; the connection can verify a card without an amountkind: "setup": no charge, only the card is saved (subscription.updated). For a pause the user requested (pause_reason: "requested"), this is the only session offered.
No unpaid period; the connection cannot verify without an amountEarly renewal: the next period is charged now with the new card and current_period_end moves one period ahead (subscription.renewed). The page says so plainly.
  • The session only goes through a connection that saves the card with a guarantee; otherwise 409 payment_method_unavailable.
  • While an early renewal session is open, the same request returns that same session.
  • 409 payment_in_progress: the period's payment is in progress.
  • 409 subscription_state_invalid: the subscription is cancelled or ended; it was paused by the user and a card-only setup is not available; or its cancellation is scheduled for the end of the period.
  • On a provider-managed subscription the session is always a kind: "setup" session that opens the provider's card update form: Engine differences.

Customer portal

  • POST /v1/portal-sessions (scope subscriptions:write) opens a portal session valid for 60 minutes: { id: "bps_…", object: "portal_session", url, expires_at }. The customer is given as a cus_… id or a customer_external_reference.
  • return_url is required and must be on an allowed address. Any flag left out of features (cancel, update_payment_method) counts as enabled.
  • url is returned only in this response: Efespay stores only a digest of the token. Idempotency-Key is ignored; every request opens a new session.
  • With the project's branding, the page (/portal/{token}) shows the customer's subscriptions, payment history and saved cards. The customer can update the card (the card update rules above), cancel the subscription at period end or undo the cancellation, and delete an unused card.
  • Changes publish the same subscription.* events (and payment_method.deleted).
  • On a provider-managed subscription there is no undoing a cancellation and the card list is empty: Engine differences.
Portal session
POST /v1/portal-sessions
{
  "customer": "cus_…",
  "return_url": "https://muhurmail.com/app/billing",
  "locale": "tr",
  "features": { "cancel": true, "update_payment_method": true }
}

→ { "id": "bps_…", "object": "portal_session", "url": "https://efespay.com/portal/…", "expires_at": "…" }

One-off and usage-based charges

  • Charge a saved card with POST /v1/payments: { payment_method, order_reference, amount_minor, … }, Idempotency-Key required, scope payments:charge. Automatic top-ups and end-of-period usage overages are charged this way.
  • The card is saved with the customer's consent through save_payment_method: "optional" or "required" on a payment session.
  • The card object (and payment_method.* events) carries customer_external_reference alongside customer_id.
  • In the card list (GET /v1/payment-methods), a customer_external_reference that Efespay has never seen returns 404 customer_not_found, not an empty list (the customer record is created with the first session); you can treat it as "no saved cards".

Saved cards

  • Saving during payment: pass save_payment_method: "optional" or "required" and customer.external_reference on the session; the customer consents on the checkout page, and payment_method.created arrives once the card is saved. On a subscription session the card is always saved.
  • Adding a card without a payment: POST /v1/payment-sessions { kind: "setup", customer: { external_reference }, set_default?, success_url?, cancel_url? } returns a url (the same checkout page, amount 0, no charge). It only works on a connection that can save a card without an amount (test provider, Stripe); otherwise 409 payment_method_unavailable. On this error, hide the "add card" button in your product. The customer portal also has "add card".
  • Default card: one of the customer's active cards carries is_default: true. The first saved card is the default; a later card only becomes the default with set_default: true or POST /v1/payment-methods/{id}/default. If the default is deleted or expires, the most recently used active card becomes the default (if there is none, there is no default).
  • Charging the default: POST /v1/payments { customer_external_reference (or customer: cus_…), order_reference, amount_minor }; do not pass payment_method. Without a default, 409 payment_method_default_missing is returned; ask the customer for a card.
  • Replacing and deleting cards: deleting a card in use returns 409 payment_method_in_use; the error lists the subscriptions using the card and the cards that could replace it (subscriptions, replacements, can_move). First move the subscriptions with POST /v1/payment-methods/{id}/move-subscriptions { to }, then delete.
  • Expiry: a card is valid until the end of its expiry month (expires_at). For a card expiring within 30 days that is used by a subscription, or is the default of a customer with a payment in the last 90 days, payment_method.expiring arrives once (the object carries expiring_reason: subscription | default and the affected subscriptions).
  • On this event, show the customer an email or in-app warning with a link to a card-adding session (or the portal). When the new card arrives, make it the default with set_default and move the subscriptions with move-subscriptions (or the customer picks "use this card for my subscriptions" in the portal).
  • When the month passes, the card becomes expired (payment_method.expired); a subscription charged to that card pauses at the next period (paused, payment_method_unavailable).
  • iyzico difference: on an iyzico connection card saving is not reliable (the form depends on the customer's choice) and there is no saving a card without a payment (kind: "setup" returns 409). Subscriptions on the iyzico engine have no card in Efespay (payment_method_id: null; the card is with iyzico): moving, defaults and payment_method.expiring do not apply to them; the card is updated through the card update session above.
  • If the same card is saved on two connections (e.g. the test provider and Stripe), it is two separate pm_… records; a token only works on its own connection.

Engine differences

The subscription object's engine field says who charges the periods. Field names, event types and the shape of the object are the same for both engines; the table below lists the differences in behaviour.

  • efespay: Efespay charges the saved card (a connection that saves cards with a guarantee: the test provider, Stripe).
  • provider: the payment provider's own subscription API charges; Efespay reads the provider and mirrors it onto the same object and events. Today this is iyzico, and it is the usual route for TRY subscriptions.
  • Efespay chooses the engine, not the project. If both are possible, efespay is preferred unless a routing rule says otherwise.
Differences in behaviour by engine
Contract operationefespayprovider (iyzico)
StartEfespay payment form; the card is saved.Same session and page; the page opens iyzico's subscription form. The first period amount must equal subscription.amount_minor (if only a managed connection is available and it differs, 409 subscription_first_amount_unsupported). Currency TRY, USD or EUR.
Opening eventspayment.succeeded → payment_method.created → subscription.createdpayment.succeeded → subscription.created (the card is not saved in Efespay; no payment_method.created).
payment_method_idThe saved card; without a card the subscription becomes paused at the next period.Always null (the card is with the provider); so it never pauses for this reason.
current_period_start · current_period_end · next_charge_atEfespay's calendar.The provider's periods (access is still granted until current_period_end).
RenewalEfespay charges; payment.succeeded (initiator: "merchant") and subscription.renewed.The provider charges; Efespay publishes the same events from a notification or reconciliation (within about 1 hour at most; it reads around the end of the period), and the payment carries initiator: "provider". The same period is never paid twice.
Failed periodpast_due; Efespay retries on the retry_days, then applies final_action.past_due; the provider does the retries (Efespay does not retry, and no payment.failed is published for the unpaid period). If the period is still unpaid once the last day in retry_days has passed, final_action applies: cancel also cancels at the provider; pause makes the subscription paused, and if the provider charges later, subscription.renewed and subscription.resumed arrive.
Cancellation or expiry on the provider's side—cancelled (cancel_reason: "provider_cancelled") or ended.
Change with proration: "none"The new amount applies from the next period.The same (a plan change at the provider); quantity, plan_reference, description and metadata work the same too.
Change with proration: "charge_now"The difference is charged to the saved card right away.Not available: an amount or interval change returns 409 subscription_proration_unsupported (fallback: change_session or replace); use a change session or proration: "none". This engine has no interval change.
Change sessionAvailable: applied immediately once paid.Available: once paid, the new amount takes effect at the provider from the next period (retried if it cannot be confirmed; final state subscription.change_failed).
Replacement subscriptionAvailable: the old one is cancelled immediately.Available: the old one is cancelled at the provider (retried until confirmed); the first amount equals the recurring amount.
capabilitiesAll true.charge_now, interval_change, pause, undo_cancel and off_session_charge are false; change_session is true.
Changing payment_methodAvailable.409 subscription_engine_unsupported; the card is changed through a card update session.
cancel (immediate)Available.Cancelled at the provider first. If the provider cannot be reached, 503 subscription_provider_unavailable; if it declines, 502 subscription_provider_error; in both cases the subscription does not change.
Cancel at period end (at_period_end or cancel_at_period_end: true)Scheduled; can be undone.Renewal stops at the provider immediately; the subscription stays active until current_period_end, then becomes cancelled. It cannot be undone (cancel_at_period_end: false returns 409 subscription_engine_unsupported); to continue, open a new subscription session.
pause · resumeAvailable.409 subscription_engine_unsupported.
Card update and overdue paymentDepending on the state: period payment, setup or early renewal (the card update table).Always a kind: "setup" session (amount 0): the page opens the provider's card update form (the provider charges and refunds a small amount to verify the card). If a period is unpaid, it is retried at the provider once the form is completed; if it is paid, subscription.renewed arrives. A card change does not change any field on the object (no subscription.updated). If cancellation is scheduled for period end, 409 subscription_state_invalid.
Customer portalView, cancel and undo, card update, card deletion.View, cancel at period end and card update are the same; there is no undoing a cancellation; the card list is empty for this subscription.
Business charge with the saved cardPossible with the subscription's card.The subscription has no card in Efespay.
POST /v1/subscriptions (creating with a saved card)Available.Not available: this engine is only opened through a payment session.

What the project does differently

  • Handle subscription.* and payment.* events with the same handler for both engines.
  • For a plan change, try charge_now; then fall back to a change session or a replacement subscription according to the error's fallback hint.
  • Show buttons according to capabilities (e.g. no "undo cancellation" when undo_cancel: false).
  • In a project with a managed connection, do not open subscriptions whose first period is discounted or prorated.

Refunds

A refund is made on the payment. The response is always a refund object; an outcome that is not yet certain arrives as an event.

  • POST /v1/payments/{id}/refunds takes { amount_minor?, reason?, metadata? }, scope payments:refund.
  • metadata (at most 20 keys, same rule as sessions) marks what the refund belongs to; it comes back unchanged on the refund object and in refund.* events.
  • The response is always 201 refund, and status is one of three values: succeeded, failed (the provider declined, failure is set; this is not an HTTP error) or uncertain.
  • uncertain: no response came from the provider; Efespay queries it and the outcome arrives as a refund.succeeded or refund.failed event. Do not send the same refund again with a new key.
  • pending can only be seen on the record while the request is being processed (GET /v1/payments/{id}/refunds); it is never returned in the response.
  • Apply the refund to your own record from the event (see Webhooks).

Webhooks

The webhook is the single source of truth. The project's endpoint verifies the signature, deduplicates the event and updates its record from the object's state.

Request headers
POST https://muhurmail.com/api/webhooks/efespay
Content-Type: application/json
Efespay-Event-Id: evt_…
Efespay-Event-Type: subscription.renewed
Efespay-Signature: t=1795000000,v1=5f2c…
Body (with project_id)
{
  "id": "evt_…",
  "object": "event",
  "type": "subscription.renewed",
  "created_at": "2026-11-22T10:00:00.000Z",
  "mode": "live",
  "project_id": "prj_…",
  "data": {
    "object": {
      "id": "sub_…",
      "object": "subscription",
      "status": "active",
      "project_id": "prj_…",
      "customer_id": "cus_…",
      "customer_external_reference": "merchant_65f0c1",
      "plan_reference": "standart-monthly",
      "quantity": 10,
      "current_period_start": "2026-11-22T10:00:00.000Z",
      "current_period_end": "2026-12-22T10:00:00.000Z",
      "cancel_at_period_end": false
    }
  }
}
  • Verify Efespay-Signature against the raw body; reject the request if t is older than 5 minutes.
  • Deduplicate with the signed body's id (evt_…): the same event can arrive again. The Efespay-Event-Id header always equals this id, but only the body is signed.
  • Update your record from the state of the object in the event; events can arrive out of order, and an older event never undoes a newer state. Processing is idempotent.
  • Return 2xx within 10 seconds; on a processing error return 5xx so Efespay retries.
  • A project-bound endpoint receives only that project's events; a project-less endpoint receives all of the business's events.
Signature verification (Node.js)
import crypto from "node:crypto";

export function verifyEfespaySignature(rawBody, header, secret) {
  const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
  const expected = crypto.createHmac("sha256", secret).update(`${parts.t}.${rawBody}`).digest("hex");
  const fresh = Math.abs(Date.now() / 1000 - Number(parts.t)) < 300;
  const a = Buffer.from(expected);
  const b = Buffer.from(parts.v1 || "");
  return fresh && a.length === b.length && crypto.timingSafeEqual(a, b);
}
Webhook handler (Node.js, Express)
app.post("/api/webhooks/efespay", express.raw({ type: "application/json" }), async (req, res) => {
  const raw = req.body.toString("utf8");
  // 1. Verify the signature on the raw body (t older than 5 minutes is rejected)
  if (!verifyEfespaySignature(raw, req.get("Efespay-Signature"), process.env.EFESPAY_WEBHOOK_SECRET)) {
    return res.sendStatus(400);
  }
  // 2. Deduplicate by the id in the verified body: the same event can arrive more than once.
  //    The Efespay-Event-Id header always equals it, but only the body is signed.
  const event = JSON.parse(raw);
  if (await processedEvents.has(event.id)) return res.sendStatus(200); // already processed: 2xx, never 409

  try {
    // 3. Update your record from the object's state; events can arrive out of order,
    //    and an older event must not undo a newer state
    await applyEfespayObject(event.type, event.data.object);
    await processedEvents.add(event.id);
    res.sendStatus(200); // 4. answer 2xx within 10 seconds
  } catch {
    res.sendStatus(500); // any non-2xx answer is retried
  }
});

Delivery and retries

  • Any answer other than 2xx (including 409, other 4xx and 3xx), a timeout (10 seconds) and a connection error count as failures and are retried after 1 min, 5 min, 30 min, 2 h, 6 h, 12 h and 24 h (8 deliveries in total).
  • After that the delivery is failed; it can be resent from the dashboard.
  • If there is no successful delivery for 3 days, the endpoint is disabled.
  • When you have already processed an event, answer 2xx, not 409: a 409 brings the event back for two days.
Events and what the project does
EventWhat the project does
payment.succeededFinds its record by order_reference, checks amount and currency, completes it and issues a receipt. If subscription_id is set, the payment belongs to a subscription: if subscription_period is set it is a period payment and period_start / period_end tell which period was paid (it can be an older overdue one); subscription_period: null with metadata.kind: "proration" is a proration charge. A late success on a closed or expired session carries late_success: true (refund it or reopen the record). A payment can succeed later: apply this event even to a payment that earlier received payment.failed.
payment.failedNot final. The card was declined but the session stays open; the customer retries in the same session and payment.succeeded can still arrive for the same payment. Do not close the record; let the customer know. For a subscription period payment, Efespay retries on schedule (subscription.past_due).
payment.expiredpayment.cancelledCloses the pending record: the session expired or was closed (sent even if the payment was never started). If a late success arrives for the closed payment, payment.succeeded arrives (late_success: true).
payment.uncertainNo result came from the provider; Efespay keeps querying. Do nothing (do not treat the record as failed, do not open a new session); the final result arrives with payment.succeeded or payment.failed.
refund.succeededrefund.failedProcesses the refund (credit reversal, receipt status).
refund.uncertainThe refund (or a void, kind: "cancel") was sent to the provider but its result is unknown; the amount stays reserved. Do not send the refund again; the final result arrives with refund.succeeded or refund.failed.
subscription.createdActivates the subscription and grants access until current_period_end.
subscription.renewedA period was charged and current_period_end moved forward (renewal, payment of an overdue period, reactivation, early renewal): extends access.
subscription.updatedAmount, quantity, plan, interval, card, description, metadata or cancel_at_period_end changed, or a pending change was resolved: syncs from the object.
subscription.past_dueThe payment failed; starts the grace period.
subscription.pausedCharging stopped; asks the customer for a new card.
subscription.resumedActive again.
subscription.cancelledsubscription.endedFinished; ends access at current_period_end. If cancel_reason: "replaced", the replaced_by subscription has taken its place: continue access through the new subscription.
subscription.change_failedThe change session's difference was paid but the change could not be applied: refund the change_failure.payment_id payment or send the change again.
payment_method.createdpayment_method.expiredpayment_method.deletedUpdates how the card is shown (including is_default).
payment_method.expiringThe card expires within 30 days and is in use: ask the customer for a new card. Sent once per card and expiry date.

For a subscription started from the checkout page, the first period arrives with subscription.created and subscription.renewed starts from the second period. For a subscription created through the API (POST /v1/subscriptions), the first charge also produces subscription.renewed. One handler that syncs from the object is enough for all three events (created, renewed, updated). Find your own record from a subscription event by customer_external_reference (or metadata).

When writing to Efespay: Idempotency-Key

  • The same Idempotency-Key with the same body returns the stored response.
  • With a different body it returns 409 idempotency_conflict: when retrying after a timeout, do not change the body (amount, metadata and addresses must stay the same).
  • If the first request is still running, it returns 409 idempotency_in_progress; retry a little later with the same key.
  • Keys are kept for 24 hours; 5xx responses are not stored.

Registering a tenant's webhook endpoint through the API

Products whose tenants connect their own Efespay account register the tenant's webhook endpoint through the API: POST /v1/webhook-endpoints { url, events?, description? } (scope webhook_endpoints:write). The secret in the response is returned only once; store it in the tenant's record. To manage endpoints, use GET, PATCH and DELETE /v1/webhook-endpoints/{id} and POST /v1/webhook-endpoints/{id}/rotate-secret.

Error codes

Codes added by this contract. The error format and the other codes are in the developer documentation.

Error codes
HTTPCodeMeaning
400line_items_amount_mismatchamount_minor does not equal the sum of the basket lines.
400line_items_with_itemsA basket (line_items) cannot be combined with marketplace items.
400invalid_line_itemsA basket line is invalid; param points at it.
400invalid_kindkind is not payment, subscription or setup.
400invalid_subscriptionThe subscription fields are missing or invalid, or an option a subscription cannot use was given (capture: "manual", marketplace items); param names the field.
400installments_not_allowedInstalments cannot be offered on a subscription.
400project_mismatchA project-bound key was sent with a different project.
400project_not_foundThe given project was not found.
400invalid_prorationproration is not none or charge_now, or the interval was changed without charge_now; on the provider engine an interval change comes with fallback: "replace".
400invalid_portal_featuresfeatures is invalid (cancel and update_payment_method can only be true or false).
400customer_requiredNo customer was given: a portal session is opened with the customer ID or external reference.
400idempotency_key_requiredA change with proration: "charge_now" needs an Idempotency-Key header.
400change_session_interval_unsupportedA change session cannot change the interval (fallback: "replace"); open a replacement subscription.
400subscription_change_emptyThe change session body has no field to change.
400setup_field_not_allowedA charge field was given on a kind: "setup" session (items, line_items, capture: "manual", save_payment_method: off or optional); param names it.
400invalid_set_defaultset_default is invalid; the field is only used on a kind: "setup" session.
400payment_method_customer_mismatchWhen charging a saved card, both a card and a customer were given and the card does not belong to that customer.
400payment_method_move_sameWhen moving subscriptions, the target card is the card being moved from.
400payment_method_move_subscriptions_invalidWhen moving subscriptions, the subscriptions list is invalid.
402proration_payment_failedThe card declined the difference charge; the subscription did not change (failure is set).
404portal_session_not_foundOn the portal page endpoints: the token is unknown or malformed.
404customer_not_foundThe customer was not found (ID, or external reference within the project). The card list also returns it for an external reference that has never been seen; you can treat that as "no saved cards".
404subscription_not_foundThe subscription given in subscription.replaces was not found or belongs to another project (param: "subscription.replaces").
409project_archivedThe project is archived: new writes are closed; reads, refunds and cancellations still work.
409subscription_state_invalidThe subscription's state does not allow this operation, or another write won at the same moment; nothing changed.
409payment_method_unavailableNone of the project's connections can carry the subscription (no connection that saves cards with a guarantee and none with provider-managed subscriptions enabled), or no connection can save the card with a guarantee for a card update session.
409subscription_change_pendingA change is awaiting its result; try again once it settles.
409payment_in_progressA charge is in progress (a subscription period's payment, or the customer's attempt on the provider's page); try again once it settles.
409subscription_engine_unsupportedAn operation that a provider-managed subscription (engine: "provider") does not support; see Engine differences.
409subscription_proration_unsupportedA provider-managed subscription has no proration: "charge_now"; the body carries fallback (change_session or replace) and capabilities.
409subscription_replace_customer_mismatchThe subscription given in subscription.replaces belongs to a different customer.
409subscription_replace_not_liveThe subscription given in subscription.replaces is cancelled, ended or already replaced by another subscription.
409subscription_first_amount_unsupportedOnly a provider-managed connection is available and the first period amount differs from subscription.amount_minor.
409payment_method_default_missingThe customer has no default card; ask the customer for a card.
409payment_method_in_useThe card is used by a subscription; the error carries subscriptions, replacements and can_move. Move the subscriptions with move-subscriptions first.
409payment_already_succeededWhen closing a session: the session has been paid (or is authorised); complete your record. See Closing an open session.
409payment_not_cancellableWhen closing a session: the session is already closed (cancelled, expired); treat it as closed.
409payment_uncertainWhen closing a session: the result of the last attempt is unknown; wait for the payment.succeeded or payment.failed event.
409session_managed_by_subscriptionWhen closing a session: the session belongs to a subscription period's payment; use the same session or cancel the subscription.
410portal_session_expiredOn the portal page endpoints: the session has expired (60 minutes); open a new one.
502subscription_provider_errorOn a provider-managed subscription the provider declined the operation; the subscription did not change (failure.code).
503subscription_provider_unavailableThe provider could not be reached or the result could not be confirmed; the subscription did not change, try again.

Testing

With a test key (efp_test_…) you can try the whole flow without any real money moving.

  • In test mode the Efespay test provider is available in every project; card scenarios are the same as the test cards in the developer documentation.
  • When charging a saved card, the last two digits of the amount pick the outcome: 51, 52, 53, 54 (declined, insufficient funds, expired card and unknown result, in that order).
  • To see renewals without waiting, use a short interval (interval: "day").
  • Try your webhook endpoint with a test event (ping) from the project's page in the dashboard.

Payments taken outside Efespay

Some revenue does not go through Efespay. Report it with POST /v1/external-payments so that all of the project's revenue shows up in Efespay reports.

  • Covers: in-app store purchases (App Store, Google Play; existing buyers of products that receive store notifications), invoices the customer paid by bank transfer or EFT and you marked as "paid", cash or cheque, and manual plan assignments with a recorded amount.
  • API scopes: writing external_payments:write, reading external_payments:read.

What it is not

  • It grants no access. The record does not open a subscription or give the user access; your own system (store verification, invoice status) does that. Efespay only keeps the record.
  • It moves no money. Efespay never saw this money and cannot refund it. POST /v1/external-payments/{id}/refund only records that "the external system refunded it".
  • It does not replace a payment session. A payment taken through Efespay always goes through POST /v1/payment-sessions. External records are not in payment lists, payment.* events or provider figures (volume, success rate); reports show them as separate external figures.

Safe to repeat

  • The same project, channel and external_id (or, without one, the same order_reference) never opens a second record: the existing record comes back with 200, a new one with 201. You can forward a store notification blindly every time it arrives.
  • If the same identity arrives with a different amount or currency, 409 external_payment_mismatch is returned.
  • amount_minor is in the currency's smallest unit (USD cents, JPY yen); currency is an ISO 4217 code and is required (it is not limited to the currencies Efespay charges in).
  • App Store prices are in milli-units (unit × 1000); convert to the smallest unit using the currency's decimal places (USD 4990 → 499 cents, JPY 500000 → 500 yen). Verify the store notification with the store on your server before sending it.
  • Events: external_payment.recorded (only for a new record) and external_payment.refunded. An endpoint not subscribed to them does not receive them; a ["*"] subscriber does, so answer 2xx to event types you do not recognise as well. The error codes for these endpoints are in the API reference.
Store renewal, store refund and bank transfer
# Store renewal, after your server has verified the store notification
POST /v1/external-payments
{
  "channel": "app_store",
  "external_id": "<transactionId>",
  "order_reference": "<your subscription id>",
  "amount_minor": 499,
  "currency": "USD",
  "paid_at": "2026-11-22T10:00:00.000Z",
  "customer": { "external_reference": "<your user id>" },
  "subscription_reference": "<your subscription id>",
  "plan_reference": "<productId>"
}
→ 201 external_payment (new record) or 200 (already recorded)

# Store refund: record that the external system refunded it
POST /v1/external-payments/xp_…/refund
{ "refund_external_id": "refund:<transactionId>", "reason": "App Store refund" }

# Bank transfer marked as paid in your admin panel
POST /v1/external-payments
Idempotency-Key: invoice-paid:inv_1042
{
  "channel": "bank_transfer",
  "order_reference": "inv_1042",
  "amount_minor": 108000,
  "currency": "TRY",
  "paid_at": "2026-11-22T09:30:00.000Z",
  "description": "Invoice 1042, bank transfer",
  "customer": { "external_reference": "merchant_65f0c1", "name": "Örnek A.Ş." }
}

Let's bring your products onto one platform.

Tell us which product uses which flow, and we will set up the projects, connections and test plan together.