# Orders


Including application/json in the Accept header will return the Order as a JSON, otherwise the Order will be in a signed JWT.

Whenever a verification required error is returned, 3D Secure needs to be performed.

# Create an order with a card

When a cardholder enters their card number as a one time event, a card token is created which can be used to create an order.

To create an order, post an Order Creatable to the order endpoint. The payment field must be a Card Payment Creatable.

# Request

 



















POST /v1/order

Host: merchant.intergiro.com
Content-Type: application/json
Accept: application/json
Authentication: Bearer <customer.api.key> | Bearer <private.api.key>
{
  "items": <number or item information or array of items objects>,
  "currency": "<currency of the transaction>",
  "charge": "auto", // optional
  "payment": {
    "type": "card"
    "card": "<card token>"
    "client": {
      "browser": // <Browser object>
      }
    }
  }
}

See browser section for information on how to get the browser information above.

# Response

On success, the response will be an Order, otherwise an Error will be returned together with the id of the order.

IMPORTANT: Include the id from the error response in the request body for all following calls to the order-create endpoint, concerning the same order.** This is important to keep a correct History of the authorization creation, and to make sure 3DS is done correctly. The id field in an Order Creatable should never be populated with any id other than the id received from the order endpoint.

# Create an order with a saved card

To select a customer method to make an order with, the customer method first needs to be converted into a card payment. For this, the function Customer.Method.toPayment() should be used which can be accessed through the npm package @payfunc/model.

An order created with a saved card can be initiated by either the cardholder or merchant. The initiator should be specified by entering "cardholder" or "merchant" in the second input parameter of the Customer.Method.toPayment() function. If this is not specified the initiator will be defaulted to "merchant".

const payment = await Customer.Method.toPayment(
			{
				type: "card",
				scheme: "visa",
				iin: "411111",
				last4: "1111",
				expires: [2, 22],
				acquirer: "intergiro",
				created: "2021-10-25T13:57:36.599Z",
				token: "<card.token>",
			},
			"cardholder"
		)

POST an Order Creatable with

  1. the card payment populated on the payment field,
  2. the customer ID populated on the customer field
 
















POST /v1/order

Host: merchant.intergiro.com
Content-Type: application/json
Accept: application/json
Authentication: Bearer <customer.api.key> | Bearer <private.api.key>
{
    "items": 20,
    "currency": "EUR",
    "customer": "TjbHYXXn6yEdhLgS",
    "payment": {
        "card": "<card.token>",
        "type": "card",
        "subsequent": { "reference": "MCA1400001202", "initiator": "cardholder" }
    }
}

# Created an order for an existing customer

To create a customer order post an Order Creatable to the order endpoint, the customer field must be set to a customer id and the payment field must be a Customer Payment Creatable.

# Request

 















POST /v1/order

Host: merchant.intergiro.com
Content-Type: application/json
Authentication: Bearer <customer.api.key> | Bearer <private.api.key>
{
	"number": <your order identifier>,
	"items": <number or item information or array of items objects>,
    "customer": <customer id>,
	"currency": <currency of the transaction>,
	"payment": {
		"type": "customer",
        "initiator": "cardholder"
	}
}

# Response

{
    "id": "<Identifier of order in Intergiro's system>",
    "created": "<datetime of order>",
    "customer": "<id of customer or contact information>",
    "items": "<numer or item information or array of items objects>",
    "currency": "<Currency of order>",
    "payment": "<Card payment>",
}

# Change an order

In order to capture, refund or cancel an order you must change it. To change an order make a PATCH containing an array where each element contains an id of the order and an array of Event Creatable for the changes you want to apply on given order.

# Request

 













PATCH /v1/order

Host: merchant.intergiro.com
Content-Type: application/json
Authentication: Bearer <private.api.key>

[
    {
        "id": "<Identifier of order in Intergiro's system>",
        "event": [<Array of Event Creatables>]
    },
    ...
]

# Response

You should get a 200 response with the same changes you requested in the body.

[
    {
        "id": "<Identifier of order in Intergiro's system>",
        "event": [<Array of Event Creatables>]
    },
    ...
]

# List all orders

To list the orders send a GET request to the order endpoint. It is highly recommended to use the date queries when listing orders, to optimize behaviour.

# Request

 





GET /v1/order?start=2000-01-01&end=2000-02-01

Host: merchant.intergiro.com
Content-Type: application/json
Authentication: Bearer <customer.api.key> | Bearer <private.api.key>

# Response

The response will be an array of orders.