In Store Checkout

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

Guides an associate through the typical in-store flow: (optional) customer lookupreplace cartverify order/lease statusmark deliveredrefund or cancel

Step 1 (Optional) - Customer Lookup

Confirms whether the shopper has an in-progress application and if they can continue. If no lease object is present, they must apply first.

$ 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": "customerSearch",
      "query": "query customers($input: CustomerSearchInput!) { customer(input: $input) { orderId customers { firstName lastName emailAddress } eligibility { displayText canContinueWithKoalafi offerDetails { approvalType approvalLanguage maxApprovalAmount } application { lease { id displayId status } } } customerSearchErrors { __typename } } }",
      "variables": {
        "input": {
          "cellPhone": "9999999999",
          "taxIDLast4": "1234"
        }
      }
    }'
▶ Run Request
HTTP/1.1 200 OK

        {
        "data": {
        "customer": {
        "orderId": "e056dc1c-9f41-4cf7-a237-a2d8c393b011",
        "customers": [{ "firstName": "Koala", "lastName": "Tester", "emailAddress": "[[email protected]](mailto:[email protected])" }],
        "eligibility": {
        "displayText": "Congratulations! You are approved for Koalafi's lease-to-own financing of up to $3,500.",
        "canContinueWithKoalafi": true,
        "offerDetails": { "approvalType": "lease", "approvalLanguage": "approved", "maxApprovalAmount": "3500" },
        "application": { "lease": { "id": 139585, "displayId": "114824-1", "status": "approved" } }
        },
        "customerSearchErrors": []
        }
        }
        }

Step 2 - Update Order Items (replace cart)

Sends the full cart (service vs. merchandise, leasable vs. non-leasable).

$ 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 CartValidation { message extensions { validationErrType approvalType approvedAmount displayText } } ... on ServiceFeesTooHigh { message } ... on CartMinNotMet { message } ... on FatalError { message } ... on BadRequest { message } ... on NotFound { message } } } }",
      "variables": {
        "input": {
          "orderId": "<your-order-id>",
          "items": [
            {
              "sku": "abcd123",
              "price": "400",
              "itemUrl": "https://example.com/1",
              "quantity": 1,
              "displayName": "An example test item",
              "itemImageUrl": "https://imageurl.com",
              "isLeaseable": true,
              "category": "merchandise"
            },
            {
              "sku": "abcd1234",
              "price": "300",
              "itemUrl": "https://example.com/2",
              "quantity": 2,
              "displayName": "4k tv",
              "itemImageUrl": "https://imageurl.com",
              "isLeaseable": true,
              "category": "merchandise"
            },
            {
              "sku": "abcd-warranty",
              "price": "25.99",
              "itemUrl": "https://example.com/3",
              "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 3 - Order Query

Use to verify the application; docsSigned means the contract is signed.

$ 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": "docsSigned",
        "maxLeaseAmount": "3000",
        "options": [{ "leaseTerm": "12", "approvedAmount": "3000", "applicationFee": "49" }]
        }
        }
        }
        }
        }

Step 4 - Mark Order Delivered

Call when items have been delivered; initiates funding.

$ 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 (not orderId). Include adjustmentAmount for refunds.

Cancel

$ 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 BadRequest { message } ... on FatalError { message } } } }",
      "variables": {
        "input": {
          "applicationId": 1234,
          "modificationReason": "cancel"
        }
      }
    }'
▶ Run Request
HTTP/1.1 200 OK

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

Refund (partial)

$ 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 BadRequest { message } ... on FatalError { message } } } }",
      "variables": {
        "input": {
          "applicationId": 1234,
          "modificationReason": "refund",
          "adjustmentAmount": "50.00"
        }
      }
    }'
▶ Run Request
HTTP/1.1 200 OK

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