Debit order

Debit an order for a specific merchant.

This operation enables you to:

  • Partly debit a specific order
  • Fully debit a specific order
  • Debit and close order for further debits

When you debit an order you send which orderId it refers to and the below attributes:

  • type: type of transaction (DEBIT)
  • amount: amount on transaction, in order currency. If it is equal to residual order amount, order will be closed implicitly. 
  • transactionReference: merchant’s transaction reference. If supplied, will be returned as transactionReference when requesting balance transactions. 
  • debitTransaction: reference to associated debit transaction (id on custom object transaction).
  • closeDebit: closes the order for further debit transactions. It is not possible to make more debit transactions on a closed order but it is still possible to make credit transactions. If the parameter is not supplied the default value false will be used. Only applies if the debited amount is less than the order’s residual amount.
  • rows: rows on this order
  • message: message to consumer if the payment method allows it

1. Create debit transaction

To create a debit transaction for a specific order you have to send the above attributes via a server-side call to our REST API. You’ll find the complete REST API reference here.

POST /v1/orders/<orderId>/transactions

x-api-key: njdfdsdkjfl5598503mnfkfe
x-merchant-key: 86969769
Content-Type: application/json

{
  "type":"DEBIT",
  "amount":15000,
  "transactionReference":"transRefTest1",
  "closeDebit":false,
  "rows":[
    {
      "name":"Vit T-shirt",
      "quantity":1.0,  
      "unitAmount":15000,
      "vatRate":2500,
      "partNumber":"00012",
      "description":"Bomull Vit",
      "unit":"st",
      "discountAmount":0,
      "serials":[],
      "fee":false,
      "provided":false
    }
  ],
  "message":"TestMessage"
}

2. Handle response

The response will either be OK or an error code.

The response contains the following information:

  • orderStatus:  status on order, after transaction has been created
  • transaction: the created transaction
  • message: message to cunsomer if the payment method allows it
  • merchantId: 

 You can see all Ecsters custom objects here

Below you have an example of the response from the request obove.

Status: 201 Created

{
    "orderStatus": "PARTIALLY_DELIVERED",
    "transaction": {
        "id": "DYDtJIwD3JUXBzIOJIEz",
        "transactionReference": "transRefTest1",
        "type": "DEBIT",
        "created": "2018-12-12T21:11:45+01:00",
        "amount": 15000,
        "rows": [
            {
                "name": "Vit T-shirt",
                "quantity": 1,
                "unitAmount": 15000,
                "vatRate": 2500,
                "partNumber": "00012",
                "description": "Vit bomull",
                "unit": "st",
                "discountAmount": 0,
                "serials": [],
                "fee": false
            }
        ],
        "message": "TestMessage",
        "merchantId": "12345678"
    }
}
Request test account