Hybrid (Custom Apply / Modal)

Prerequisites

Before running any commands:

Endpoints:

Sandbox: https://application-edge-service.sandbox.koalafi.com/query
Production: https://application-edge-service.koalafi.com/query

Headers (required on every request):

public-dealer-id: <your-public-dealer-id>
private-api-key: <your-private-api-key>

What this Does

Walks a hybrid flow: apply in your UI → if allowed, open Koalafi modalorder lookupupdateOrderItemsmark deliveredrefund/cancel.

Step 1 - Apply (create application and order)

When testing, increment cellPhone and taxpayerIdentificationNumber each submission. If canContinueInKoalafiUi is true, open the modal.

$ curl -sS https://application-edge-service.sandbox.koalafi.com/query   -H "public-dealer-id: <your-public-dealer-id>"   -H "private-api-key: <your-private-api-key>"   -H "Content-Type: application/json"   -d '{
    "operationName": "apply",
    "query": "mutation apply($applyInput: ApplyInput!) { apply(input: $applyInput) { orderId canContinueInKoalafiUi application { lease { id displayId status maxLeaseAmount options { leaseTerm approvedAmount applicationFee } } } offerDetails { maxApprovalAmount approvalLanguage recurringPaymentDetails { paymentFrequency paymentDetails { leaseTerm paymentAmount } } } applicationErrors { __typename ... on DenialError { message } ... on FatalError { message } ... on BadRequest { message } ... on OrderNotFound { message } ... on HardDecline { message } ... on SoftDecline { message extensions { declineField appId displayText } } ... on Ineligible { message } ... on NotFound { message } ... on LeaseRestricted { message } ... on CartValidation { message extensions { validationErrType approvalType approvedAmount displayText } } } } }",
    "variables": {
      "applyInput": {
        "customer": {
          "billingAddress": {
            "city": "Richmond",
            "line1": "400 Hull St",
            "state": "VA",
            "zip": "23224"
          },
          "birthDate": "1999-01-01",
          "cellPhone": "1234561111",
          "emailAddress": "[email protected]",
          "firstName": "Wally",
          "lastName": "Koala",
          "taxpayerIdentificationNumber": "234561111"
        },
        "employment": {
          "monthlyIncome": "6000"
        },
        "analytics": {
          "directIntegrationChannel": "online"
        }
      }
    }
  }'
▶ Run Request
HTTP/1.1 200 OK

    {
    "data": {
    "apply": {
    "orderId": "6139a31f-9ed3-4daf-a9bb-1d25b219d9dd",
    "canContinueInKoalafiUi": true,
    "application": {
    "lease": {
    "id": 62085,
    "displayId": "86967-1",
    "status": "preApproved",
    "maxLeaseAmount": "3000",
    "options": [{ "leaseTerm": "12", "approvedAmount": "3000", "applicationFee": "49" }]
    }
    },
    "applicationErrors": []
    }
    }
    }

Step 2 - Order Lookup

Use the orderId from apply to confirm current lease/application state.

$ curl -sS https://application-edge-service.sandbox.koalafi.com/query   -H "public-dealer-id: <your-public-dealer-id>"   -H "private-api-key: <your-private-api-key>"   -H "Content-Type: application/json"   -d '{
    "operationName": "order",
    "query": "query order($id: ID!) { order(id: $id) { id application { lease { id displayId status maxLeaseAmount options { leaseTerm approvedAmount applicationFee } } } } }",
    "variables": {
      "id": "<your-order-id>"
    }
  }'
▶ Run Request
HTTP/1.1 200 OK

    {
    "data": {
    "order": {
    "id": "6139a31f-9ed3-4daf-a9bb-1d25b219d9dd",
    "application": {
    "lease": {
    "id": 62085,
    "displayId": "86967-1",
    "status": "preApproved",
    "maxLeaseAmount": "3000",
    "options": [{ "leaseTerm": "12", "approvedAmount": "3000", "applicationFee": "49" }]
    }
    }
    }
    }
    }

Step 3 - Update Order Items

Send the entire cart just before checkout / opening UI.

$ curl -sS https://application-edge-service.sandbox.koalafi.com/query   -H "public-dealer-id: <your-public-dealer-id>"   -H "private-api-key: <your-private-api-key>"   -H "Content-Type: application/json"   -d '{
    "operationName": "updateOrderItems",
    "query": "mutation updateOrderItems($input: UpdateOrderItemsInput!) { updateOrderItems(input: $input) { order { id details { customer { firstName lastName } items { price } } } orderErrors { __typename ... on FatalError { message } ... on BadRequest { message } ... on NotFound { message } } } }",
    "variables": {
      "input": {
        "orderId": "<your-order-id>",
        "items": [
          {
            "sku": "abcd123",
            "price": "400",
            "itemUrl": "http://www.example.com/item1",
            "quantity": 1,
            "displayName": "An example test item",
            "itemImageUrl": "https://imageurl.com",
            "isLeaseable": true,
            "category": "merchandise"
          },
          {
            "sku": "abcd1234",
            "price": "300",
            "itemUrl": "http://www.example.com/item2",
            "quantity": 2,
            "displayName": "4k tv",
            "itemImageUrl": "https://imageurl.com",
            "isLeaseable": true,
            "category": "merchandise"
          },
          {
            "sku": "abcd1234",
            "price": "25.99",
            "itemUrl": "http://www.example.com/item3",
            "quantity": 1,
            "displayName": "Warranty",
            "itemImageUrl": "https://imageurl.com",
            "isLeaseable": false,
            "category": "service"
          }
        ],
        "shippingAmnt": "3.99",
        "taxAmnt": "12.99"
      }
    }
  }'
▶ Run Request
HTTP/1.1 200 OK

    {
    "data": {
    "updateOrderItems": {
    "order": {
    "id": "526884e8-b02b-4fb4-a556-53f306069940",
    "details": {
    "customer": { "firstName": "Wally", "lastName": "Koala" },
    "items": [{ "price": "400.00" }, { "price": "300.00" }, { "price": "25.99" }]
    }
    },
    "orderErrors": []
    }
    }
    }

Step 4 - Mark Order Delivered

Initiates funding post-delivery.

$ curl -sS https://application-edge-service.sandbox.koalafi.com/query   -H "public-dealer-id: <your-public-dealer-id>"   -H "private-api-key: <your-private-api-key>"   -H "Content-Type: application/json"   -d '{
    "operationName": "markOrderDelivered",
    "query": "mutation markOrderDelivered($input: MarkOrderDeliveredInput!) { markOrderDelivered(input: $input) { markOrderDeliveredErrors { __typename ... on FatalError { message } ... on InvalidApp { message } ... on NotFound { message } ... on BadRequest { message } } } }",
    "variables": {
      "input": {
        "orderId": "<your-order-id>"
      }
    }
  }'
▶ Run Request
HTTP/1.1 200 OK

    { "data": { "markOrderDelivered": { "markOrderDeliveredErrors": [] } } }

Step 5 - Refund or Cancel

Use applicationId and include adjustmentAmount for refunds.

$ curl -sS https://application-edge-service.sandbox.koalafi.com/query   -H "public-dealer-id: <your-public-dealer-id>"   -H "private-api-key: <your-private-api-key>"   -H "Content-Type: application/json"   -d '{
    "operationName": "refundOrCancelOrder",
    "query": "mutation refundOrCancelOrder($input: RefundOrderInput!) { refundOrCancelOrder(input: $input) { transactionId refundOrderErrors { __typename ... on FatalError { message } ... on BadRequest { message } } } }",
    "variables": {
      "input": {
        "applicationId": 1234,
        "modificationReason": "refund",
        "adjustmentAmount": "500.25"
      }
    }
  }'
▶ Run Request
HTTP/1.1 200 OK

    { "data": { "refundOrCancelOrder": { "transactionId": "357f74a6-c08c-43ab-aaed-4d57ed925972", "refundOrderErrors": [] } } }