Skip to content

Step 2: Calculate Order ​

Calculate a quote before customer confirmation; this creates no resource and does not lock prices.

Calculate before payment

Calculate before each new payment attempt, including retries after a failed payment. Show the latest total to the customer and use it as expected_payment_total when creating the payment.

Endpoint ​

http
POST https://api.iimmpact.com/v2/orders/calculate

Request headers ​

FieldTypeRequiredDescription
X-Api-KeystringYesYour API key; keep it on your backend.
X-TimestampstringYesCurrent Unix time in seconds; within five minutes of server time.
X-NoncestringYesFresh identifier for every request, including retries.
X-SignaturestringYesv1= followed by the request's HMAC signature.

Follow API Key Authentication. Sign the exact body, or an empty body for bodyless requests, and the sorted query when present.

FieldTypeRequiredDescription
Content-TypestringYesapplication/json.

Request fields ​

FieldTypeRequiredDescription
order_idstringConditionalSend for an existing unpaid order. Omit items.
itemsarrayConditionalSend for a new order. Include at least one item and omit order_id.
FieldTypeRequiredDescription
payment_method_codestringYesCode from Payment Methods.
customer_fee_percentstringNoPercentage of the fee the customer bears, 0.00–100.00; defaults to 0.00.

Choose one input

Send either items or order_id, not both. With order_id, Pine Labs uses that order's stored items and prices. Keep the payment method and customer fee percent in the request.

The item fields below apply when sending items.

Item fields ​

See Product Listing for available products. Each item follows Make Payment — Request Body; the purchased product runs after payment succeeds.

FieldTypeRequiredDescription
items[].productstringYesProduct code from Product Listing.
items[].accountstringProduct-dependentRecipient's account number or identifier. Send "" only when the product allows an optional account; otherwise provide its required destination. A supplied value must still pass that product's validation.
items[].amountstring or numberYesAmount for one topup. Required for every product; follows the existing Make Payment rules.
items[].quantityintegerNoNumber of topups for this item; defaults to 1. Must be positive.
items[].remarksstringNoAdditional remarks.
items[].extrasobjectConditionalAdditional fields required by the selected product; see Make Payment above.

Order limit

Each order supports up to 100 topups in total. Add the quantities of all items; the total must not exceed 100. An omitted quantity counts as 1.

For example, 10 items with quantity 10 reaches the limit. This limit is checked during calculation and order creation.

Use subproducts where required and bill presentment for bill validation. Each purchased unit gets a fulfillment reference and a sale price calculated from the item details.

Fee fields ​

Payment Methods returns each method's fee rule. Calculate Order returns the exact fee and total for the selected method and order.

FieldTypeDescription
fee.typestringfixed or percentage.
fee.valuestringTwo-place decimal string: MYR amount for fixed, or percentage from 0.00 to 100.00 for percentage. For example, 1.70 means RM1.70 or 1.70%, respectively.

Customer fee percent ​

Send the percentage of the payment fee your customer bears on each calculation, order creation, and payment creation request. It is not inherited from an earlier request. Omission means 0.00: you pay the full fee.

json
{
  "customer_fee_percent": "50.00"
}

Fee calculation ​

  1. Round each server-resolved unit sale price half-up to cents; multiply by quantity and sum the lines.
  2. Calculate the payment fee once: for percentage, round subtotal × value / 100 half-up to cents; for fixed, use value as the MYR fee.
  3. Customer fee = payment fee × percent / 100, rounded half-up to cents.
  4. Your fee = payment fee − customer fee. Payment total = item subtotal + customer fee.

There is no gross-up. The same sharing rule applies to both fee types:

RM100 of itemsCustomer percentCustomer feeYour feePayment total
1.70% fee (RM1.70)OmittedRM0.00RM1.70RM100.00
1.70% fee (RM1.70)50%RM0.85RM0.85RM100.85
1.70% fee (RM1.70)100%RM1.70RM0.00RM101.70
Fixed RM2.00 feeOmittedRM0.00RM2.00RM100.00
Fixed RM2.00 fee50%RM1.00RM1.00RM101.00
Fixed RM2.00 fee100%RM2.00RM0.00RM102.00

Payment creation checks expected_payment_total against the current calculation. Fees are frozen only when that payment is admitted; refunds do not change its original fee breakdown.

Request example — new order ​

json
{
  "payment_method_code": "CARD",
  "customer_fee_percent": "50.00",
  "items": [
    {
      "product": "TNB",
      "account": "220012345679",
      "amount": "60.00",
      "quantity": 1
    },
    {
      "product": "TNB",
      "account": "220012345678",
      "amount": "40.00",
      "quantity": 1
    }
  ]
}

Request example — existing order ​

Replace items with order_id and call the same endpoint:

json
{
  "order_id": "ord_example",
  "payment_method_code": "CARD",
  "customer_fee_percent": "50.00"
}

Response fields ​

Both inputs return the same calculation breakdown. Existing-order responses also identify the order:

FieldTypeDescription
data.order_idstringReturned when the request includes order_id; omitted for a new-order calculation.
FieldTypeDescription
data.currencystringMYR.
data.payment_method_codestringSelected method.
data.customer_fee_percentstringPercentage of the fee the customer bears, 0.00–100.00.
data.feeobjectFee rule.
data.itemsarrayItem details with resolved prices below.
items[].productstringProduct code.
items[].product_namestringProduct display name.
items[].amountstringRequested topup amount, returned as a two-place decimal string.
items[].unit_pricestringTwo-place sale price per unit; may differ from face value.
items[].subtotalstringUnit price × quantity.
data.totalsobjectTwo-place amounts below.
totals.items_subtotalstringSum of item sale subtotals.
totals.feeobjectThe payment fee split between customer and you.
totals.fee.totalstringFull payment fee.
totals.fee.customerstringCustomer's portion of the fee.
totals.fee.merchantstringYour portion of the fee.
totals.payment_totalstringItem subtotal plus customer fee; use as expected_payment_total.

Response example — 200 ​

json
{
  "data": {
    "currency": "MYR",
    "payment_method_code": "CARD",
    "customer_fee_percent": "50.00",
    "fee": {
      "type": "percentage",
      "value": "1.70"
    },
    "items": [
      {
        "product": "TNB",
        "product_name": "Tenaga Nasional Berhad",
        "account": "220012345679",
        "amount": "60.00",
        "quantity": 1,
        "unit_price": "60.00",
        "subtotal": "60.00"
      },
      {
        "product": "TNB",
        "product_name": "Tenaga Nasional Berhad",
        "account": "220012345678",
        "amount": "40.00",
        "quantity": 1,
        "unit_price": "40.00",
        "subtotal": "40.00"
      }
    ],
    "totals": {
      "items_subtotal": "100.00",
      "fee": {
        "total": "1.70",
        "customer": "0.85",
        "merchant": "0.85"
      },
      "payment_total": "100.85"
    }
  }
}

Errors ​

HTTPCodeAction
400validation_errorFix invalid fields and try again. Sending both items and order_id, or neither, is rejected. See field errors.
400invalid_itemsOne or more items failed product validation; error.details.items lists each failure's index, code, and message. Correct them and calculate again.
400payment_method_unavailableRefresh methods and choose an available one.
404order_not_foundThe supplied order_id was not found in your account.

See shared errors. After confirmation, create the order or create a new payment for an existing unpaid order.

Pine Labs API Documentation