Insurance
API Path
Provider Collection

Provider Collection

If your agreement with your provider has the provider collect the premium, the premium is not added to your payment. The premium is charged by your provider, separately from your payment. You start the charge with POST /api/v1/insurance/orders/{orderId}/pay.

  • Your payment is taken first. If you bound the order to a Lunixi payment, the premium can be charged only after that payment is captured. If your payment was not taken, no payment is sent to the provider.
  • The premium is a separate charge. The buyer sees two separate charges: your payment and the provider's premium charge. A failed premium charge does not affect your payment.
  • The premium does not go through your Lunixi payment. It is not part of your payment record or your payout; it is paid directly to the provider.
  • The policy is requested automatically once the premium is charged. You do not call issue-policy.

This is available on the API path only. The Checkout Form offers only the products whose premium you collect.

Before you start

  • In the panel, on the POS Center > Insurance page, set Who collects the premium to Provider collects for the product in your connection: Provider Connection › Products on this connection. The list shows only the methods the product supports.
  • For this product, premiumCollectedBy is PROVIDER on quote options and orders.
  • The provider's product charges the premium in one of two ways:
MethodpaymentInputWhat you send
By cardCARDThe buyer's card details. Only PCI-DSS certified merchants may send them; see Card details.
On the provider's payment pageHOSTEDNo card. You redirect the buyer with nextAction; see Buyer action.

Flow

Provider premium collection flowProcess: get a quote whose option has premiumCollectedBy PROVIDER and create the order, take your own payment without a premium item, call pay; if needed the buyer completes the charge on the provider page, then the premium is charged, the policy is requested automatically and you track the order.QuotepremiumCollectedBy: PROVIDEROrderPOST …/ordersTake your paymentno premium itemCharge the premiumPOST …/{orderId}/payProvider pagenextAction · if neededPremium chargedpolicy requested automaticallyTrack the orderGET …/orders/{orderId}LEGENDSTEPYOUR PAYMENTSEPARATE PREMIUM CHARGEIF NEEDEDEND
… stands for /api/v1/insurance. The premium never goes through your payment; if it cannot be charged, your payment stays valid. You do not call issue-policy.

Get a quote and create an order

The quote and order steps are the same as in the other flows: Quotes, Orders. Continue before the option expires; charging the premium requires a valid option.

Take your payment

  • If you take the payment with Lunixi, create the payment with the insurance-enabled items and bind the order to it with bind-payment: Binding to a payment. The basket has no premium item; the premium is not added to your payment. The payment must be a direct sale (no pre-authorization).
  • If you take the payment outside Lunixi, you do not bind the order to a payment. confirm-payment is not used for these orders.

Charge the premium

Call /pay after your Lunixi payment is captured (or after you took your own payment). If the product charges a card, send the buyer's card details in the body.

Handle the outcome

Continue according to providerPayment.status in the response: Outcomes. If the outcome is ACTION_REQUIRED, redirect the buyer to nextAction.redirectUrl.

Track the policy

Once the premium is charged, the policy is requested automatically. Track the result on the order endpoint or with webhooks.

Charging the premium: POST /api/v1/insurance/orders/{orderId}/pay

Authentication

Because this endpoint can carry card data, it applies the same identity rule as the direct payment endpoints: a Bearer access token together with an Ed25519 request signature (Step-Up). Unlike the other insurance endpoints, the Authorization header is required.

HeaderValue
AuthorizationBearer <access token>
X-Key-Id, X-Date, X-Nonce, Digest, X-SignatureSignature headers; the rules are the same as in Flows › Authentication.
Idempotency-KeyRequired. 8-200 printable ASCII characters, no spaces.

Getting an access token and the Step-Up rules: Authentication. The token and the signing key must belong to the same account and the same environment.

Request

Path parameterDescription
orderIdOrder ID (inso_…).
FieldTypeRequiredDescription
cardobjectYes for CARD productsThe buyer's card details; fields below. Not sent for HOSTED products.
returnUrlstringNoYour page the buyer returns to after the provider's page. https only; no user info and no # fragment; at most 2048 characters. See Return.
source lunixi-sign.sh
REQ_PATH="/api/v1/insurance/orders/<orderId>/pay"
BODY='{"card":{"cardNumber":"<card number>","expireMonth":"<MM>","expireYear":"<YYYY>","cvcNumber":"<security code>","cardHolderName":"<card holder>"},"returnUrl":"https://example.com/insurance/return"}'
lunixi_sign POST "$REQ_PATH" "$BODY"
 
curl -X POST "https://api-gateway.lunixi.com$REQ_PATH" \
  -H "Authorization: Bearer $LUNIXI_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: insurance-pay-1001" \
  -H "X-Key-Id: $LUNIXI_KEY_ID" \
  -H "X-Date: $DATE" \
  -H "X-Nonce: $NONCE" \
  -H "Digest: $DIGEST" \
  -H "X-Signature: $SIGNATURE" \
  --data-raw "$BODY"

If the product charges on the provider's payment page (HOSTED), the body carries only returnUrl.

Card details

🚫

Only PCI-DSS certified merchants may send raw card data. Receiving, storing or transmitting the card number and security code on your server brings your systems into PCI DSS scope. If you are not certified, do not send cards to this endpoint. See PCI DSS.

FieldTypeDescription
card.cardNumberstringCard number; 12-19 digits, no spaces.
card.expireMonthstringExpiry month; two digits (01-12).
card.expireYearstringExpiry year; two or four digits.
card.cvcNumberstringSecurity code; 3 digits (4 for AMEX).
card.cardHolderNamestringFirst and last name as on the card; at most 100 characters.
  • If your account is not registered as PCI-DSS certified, a request to a card product returns 403 insurance.card.pci_required before the card is processed; no request is sent to the provider.
  • The card is not stored by Lunixi. It is processed only during the request and forwarded to your provider. The security code is not kept anywhere.
  • Card details never appear in responses, error messages, request logs or webhooks. An error response only says which field is invalid.
  • If the card format is invalid (for example, the card number fails validation or the card has expired), the request returns 422 insurance.card.invalid; the invalid field is in details.field. No request is sent to the provider.

Response

When the request completes it returns 200. data carries two objects:

FieldDescription
orderThe current state of the order: Order object.
providerPaymentThe premium charge attempt; fields below.

providerPayment:

FieldTypeDescription
insurancePaymentIdstringCharge attempt ID (inspay_…).
orderIdstringOrder ID (inso_…).
statusstringThe outcome of the attempt; see Outcomes.
paymentInputstringHow the premium is charged: CARD or HOSTED.
amountintegerThe premium charged, in minor units.
currencystringCurrency, ISO 4217.
failureCodestring or nullThe Lunixi error code if the attempt failed, e.g. insurance.payment.declined.
nextActionobject or nullThe step the buyer must take; see Buyer action.
createdAtstringWhen the attempt was created, ISO 8601.
updatedAtstringWhen it last changed, ISO 8601.

The response does not include the provider's references, payment page address or error codes. Card details are never included in any form.

Outcomes

providerPayment.statusOn the orderWhat to do
SUCCEEDEDCollection COLLECTED, policy PENDINGThe premium was charged. The policy is requested automatically; you receive the result with insurance.policy.issued.
ACTION_REQUIREDCollection ACTION_REQUIRED; order.nextAction is setRedirect the buyer to nextAction.redirectUrl: Buyer action.
FAILEDCollection FAILED, errorCode insurance.payment.declinedThe provider declined the charge. Your payment stays valid. insurance.policy.failed is sent. If the buyer wants to try another card, call again with a new Idempotency-Key.
UNKNOWNCollection UNKNOWNThe outcome of the charge is not final yet. The charge is not repeated; the order stays in this state until the outcome is confirmed. Do not charge the buyer again and do not start a new attempt.
PENDINGCollection PENDINGThe attempt is in progress. You see this value only when you repeat a request with the same Idempotency-Key; track the order on the order endpoint.
  • An order has at most one open attempt at a time. While an open (PENDING, ACTION_REQUIRED, UNKNOWN) or successful attempt exists, no new attempt can be started; the same card is never charged twice.
  • If the request fails before reaching the provider (e.g. the provider cannot be reached), no money moves: an error response is returned and the order goes back to its previous collection state. You can repeat the request after a while.

Retries and Idempotency-Key

  • Charging the premium sends the offer to the provider and performs the charge in the same request. The request can take more than a minute; set your client timeout accordingly.
  • After a timeout or a 5xx, repeat the request with the same Idempotency-Key and the same body. The same key returns the same attempt; the card is not processed again and no second charge is made.
  • Generate a new key for a new attempt (e.g. another card after a declined charge).

Buyer action (nextAction)

If the provider needs the buyer to take a step for the charge (3-D Secure verification or the provider's payment page), the attempt becomes ACTION_REQUIRED and nextAction is returned. The same object is also on the order's nextAction field while the step is pending.

FieldTypeDescription
typestringREDIRECT
redirectUrlstringThe Lunixi address you redirect the buyer's browser to.
expiresAtstring or nullThe deadline for the step, ISO 8601.
  • redirectUrl is a Lunixi address (/api/v1/insurance/payments/{insurancePaymentId}/redirect). Lunixi redirects the buyer from there to the provider's page; the provider's page address is not shared with you.
  • Open the address only in the buyer's browser. Once the return is processed, or when the attempt is no longer waiting for the buyer, the address returns 404 insurance.payment.not_found.
  • If the buyer does not return by expiresAt, the outcome is confirmed with the provider.

Return

When the buyer completes the step on the provider's page, the provider returns to Lunixi. Then:

  • If you sent returnUrl, the buyer is redirected to it with these query parameters added: insurancePaymentId, orderId, status.
  • If you did not send returnUrl, the result is shown to the buyer as JSON. Send returnUrl on every request where you redirect the buyer.

The return alone is not proof of payment. Use the status query parameter only to choose what to show the buyer; confirm that the premium was charged and the policy issued on the order endpoint or with webhooks.

Errors

HTTPcodeWhat to do
400VALIDATION_ERRORFix the format; this error is also returned when Idempotency-Key is missing.
401Authentication codesCheck the Bearer token and the signature headers: Authentication.
403AUTH_MERCHANT_MISMATCH, AUTH_ENVIRONMENT_MISMATCHThe token and the signing key must belong to the same account and the same environment.
403PRODUCT_NOT_ENABLEDThe insurance product is not enabled on your account or key.
403insurance.card.pci_requiredThe product charges by card, but your account is not registered as PCI-DSS certified. The card is not processed and no request is sent to the provider.
404insurance.order.not_foundThe order was not found or belongs to another account.
409insurance.order.state_conflictSee details.reason; table below.
409insurance.quote.expiredThe option expired; get a new quote and create a new order.
412insurance.payment.merchant_payment_not_capturedThe Lunixi payment bound to the order is not captured yet. Retry after the payment is captured.
422insurance.payment.method_not_supportedProvider collection cannot be used for this order; see details.reason, table below.
422insurance.card.invalidThe card details are invalid; fix the field in details.field.
422insurance.validation.invalidFix the fields in details.errors[]. For example, card was not sent for a CARD product (field: card, reason: required) or returnUrl is invalid (reason: https_required or invalid).
422insurance.reference.unknownA reference code on the order has no counterpart at this provider; no request is sent to the provider.
422insurance.quote.declinedThe provider did not accept the offer on the same terms; get a new quote.
503insurance.provider.unavailableThe provider could not be reached; no money moved. Retry after a while.

Common codes: Flows › Responses and errors.

State conflict

reasonMeaning
not_provider_collectionYou collect the premium of this order (premiumCollectedBy: MERCHANT). Collect it as described in Premium and Payment.
provider_payment_in_progressThe order has an open attempt: in progress, waiting for the buyer, or with an outcome that is not final.
premium_collectedThe premium has already been charged.
offer_outcome_unknownThe outcome of sending the offer to the provider is not final; the premium is not charged. The order is reviewed.

Unsupported collection

reasonMeaning
card_path_not_enabledProvider collection by card is not available in this environment.
card_not_acceptedThe product charges the premium on the provider's payment page (HOSTED); do not send card.
preauth_paymentThe payment bound to the order is a pre-authorization. Provider collection is used only with direct sale payments.
provider_payment_not_supportedThis product or provider does not collect the premium with a provider charge.

Cancellation and refund

  • You can cancel the policy with the cancel endpoint: Cancellation and Premium Refund › Policy cancellation.
  • Because the premium is paid to the provider, it is not refunded through Lunixi; refund-premium returns 409 (reason: collected_by_provider) for these orders.
  • Refunds you make from your own payment are not linked to insurance and do not cancel the policy.

Related