Order · Payments for Programmers

Payments for Programmers

Order

500 words 3 minutes

The order endpoint is the primary endpoint used for creating and administrating orders.

Creating

Card Account Payment

Request

POST https://api.payfunc.com/order
Authentication: Bearer <public.api.key>

{
	"number": "your order identifier",
	"items": 1337.42,
	"currency": "EUR",
	"payment": {
		"type": "card",
		"account": "<account id>"
	}
}

Response

{
	"id": "<order id>",
	"number": "your order identifier",
	"items": 1337.42,
	"currency": "EUR",
	"created": "2019-01-01T13:37Z",
	"payment": {
		"id": "<payment id>",
		"type": "card",
		"account": "<account id>",
		"amount": 1337.42,
		"currency": "EUR"
	},
	"event": [
		{ 
			"type": "created",
			"date": "2019-01-01T13:37Z",
		}
	]
}

Charge, Cancel & Refund

Change & Cancel

Once the end user has placed the order you can then charge or cancel the order. Charge is usually performed once the order has been fullfilled and cancel is done to cancel the order.

Cancel Single Order

Request

POST https://api.payfunc.com/order/<order id>/event
Authentication: Bearer <private.api.key>

{
	"type": "cancel"
}

Charge Single Order

Request

POST https://api.payfunc.com/order/<order id>/event
Authentication: Bearer <private.api.key>

{
	"type": "charge"
}

Partial Charge of Items

If an order contains specied items, it’s possible to charge a certain quantity of one or more items specifically.

Request

PATCH https://api.payfunc.com/order
Authentication: Bearer <private.api.key>

[{
	"id": "<order id>",
	"event": [
		{
			"type": "charge",
			"items": [
				{
					"name": "t-shirt",
					"price": 80,
					"quantity": 2,
					"unit": "st",
					"vat": 20
				},
				{
					"name": "gloves",
					"price": 160,
					"quantity": 1,
					"unit": "st",
					"vat": 40
				}
			]
		}
	]
}]

Partial Charge of Amount

An order that does not have items specified can be partially charged with a speficic amount.

Request

PATCH https://api.payfunc.com/order
Authentication: Bearer <private.api.key>

[{
	"id": "<order id>",
	"event": [
		{
			"items": 100,
			"type": "charge"
		}
	]
}]

Refund

An order that has been charged can be refunded. This is useful if the customer ends up returning the ordered items.

Refund Single Order

Request

POST https://api.payfunc.com/order/<order id>/event
Authentication: Bearer <private.api.key>

{
	"type": "refund"
}

Partial Refund of Items

If an order contains specied items, it’s possible to refund a certain quantity of one or more items specifically.

Request

PATCH https://api.payfunc.com/order
Authentication: Bearer <private.api.key>

[{
	"id": "<order id>",
	"event": [
		{
			"type": "refund",
			"items": [
				{
					"name": "t-shirt",
					"price": 80,
					"quantity": 2,
					"unit": "st",
					"vat": 20
				},
				{
					"name": "gloves",
					"price": 160,
					"quantity": 1,
					"unit": "st",
					"vat": 40
				}
			]
		}
	]
}]

Partial Refund of Amount

An order that does not have items specified can be partially refunded with a speficic amount.

Request

PATCH https://api.payfunc.com/order
Authentication: Bearer <private.api.key>

[{
	"id": "<order id>",
	"event": [
		{
			"items": 100,
			"type": "refund"
		}
	]
}]

Multiple Orders

The API allows for manipulating several orders with one single API call.

Request

PATCH https://api.payfunc.com/order/
Authentication: Bearer <private.api.key>

[
	{ "id": "<order id 0>", "event": [ { "type": "cancel" } ] }
	{ "id": "<order id 1>", "event": [ { "type": "charge" } ] }
	{ "id": "<order id 2>", "event": [ { "type": "charge" } ] }
]