Downloading the list of orders

The article contains a description of the method which returns any information regarding orders created in the InPost app together with an example implementation of the method in PHP.

 

Description of the method

The method returns any information regarding orders created in the InPost Pay App. The method not used in the process of binding and handling baskets/orders by a customer.

Parameters 

Field name

Description

Type

Requirement status

Additional remarks

page_index

Page index

string

O

  

page_size

Page size

string

O

  

Request – none 

Response

Field name

Description

Type

Requirement status

Additional remarks

page_size

Page size

integer

O

"page_size":1

total_items

Total number of items

integer

O

"total_items":159

page_index

Page index

integer

O

"page_index":1

orders

An object which returns the list of orders

object

O

 

orders.order_details

Order details

object

Y

 

orders.order_details.order_comments

Comments to an order

string

O

"comments ": "Zamówienie przetwarzane"

orders.order_details.order_id

An order ID assigned by the Merchant

string

Y

"order_id":"3433d1b7-fd9b-484b-aa68-80fccc575407"

orders.order_details.customer_order_id

Order ID presented to customer and used for payment. In case of lack of customer_order_id order_id will be used.

string

O

"customer_order_id":"3433d1b7”

orders.order_details.pos_id

POS id

string

Y

"pos_id":"000000000"

orders.order_details.order_creation_date

The date of creating an order

string($date-time)

Y

"order_creation_date":"2023-09-07T14:18:41.949Z"

orders.order_details.order_update_date

The date of an order's last update

string($date-time)

O

"order_update_date":"2023-09-07T14:23:54.190Z"

orders.order_details.payment

An object which returns any information regarding the payment

object

O

 

orders.order_details.payment.payment_type

Selected payment type. Enum:

[ CARD, CARD_TOKEN, GOOGLE_PAY, APPLE_PAY, BLIK_CODE, BLIK_TOKEN, PAY_BY_LINK, SHOPPING_LIMIT, DEFERRED_PAYMENT, CASH_ON_DELIVERY ]

string

Y

"payment_type":"BLIK_CODE"

orders.order_details.payment.payment_status

Payment status

Enum:[ UNPAID, STARTED, PENDING, AUTHORIZED, DECLINED, CANCELLED, ERROR, COD ]

string

Y

"payment_status":"AUTHORIZED"

orders.order_details.payment.available_payment_types

Payment types available for a given order.

List with available values: [CARD, CARD_TOKEN, GOOGLE_PAY, APPLE_PAY, BLIK_CODE, BLIK_TOKEN, PAY_BY_LINK, SHOPPING_LIMIT, DEFERRED_PAYMENT, CASH_ON_DELIVERY]

  

array

O

"available_payment_types":["BLIK_CODE","BLIK_TOKEN","PAY_BY_LINK"]

orders.order_details.payment.payment_details

Payment details

object

O

 

orders.order_details.payment.payment_details.payment_reference

Reference number

string

Y

"payment_reference":"52428_9b642ee3-ff3d-4fae-8ff8-30e29c0dafac"

orders.order_details.payment.payment_details.payment_id

Payment Id

string

O

"payment_id":"3cb4967d-4b63-4c5c-84bc-54e699a2dca0"

orders.order_details.payment.payment_details.payment_sec_token

Security token used

string

O

"payment_sec_token":"eyJraWQiOiIyMDRjY2U0OC1iYTFkLTQ0ODYtOTNlNy1kY..."

orders.order_details.payment.payment_details.payment.payment_type

Payment type

string

Y

"payment_type":"BLIK_TOKEN"

orders.order_details.payment.payment_details.payment_token

Card token

string

O

"payment_token":"gr...ki@it...om"

orders.order_details.payment.payment_details.payment_card

Card Information

object

O

 

orders.order_details.payment.payment_details.payment_card.last_four_digits

Card's last 4 digits

string

O

"last_four_digits":"0021"

orders.order_details.payment.payment_details.payment_card.scheme

Scheme in which the card operates

string

O

"scheme":"https://static.payu.com/images/mobile/logos/pbl_c.png"

orders.order_details.payment.payment_details.payment_card.card_type

Typ kart [ DEBIT, CREDIT, PREPAID, CHARGE, DEFERRED_DEBIT ]

string

O

"card_type":" DEBIT"

orders.order_details.payment.payment_details.payment_status

Payment status

string

O

"payment_status":"AUTHORIZED"

orders.order_details.payment.payment_details.payment_code

Payment code

string

O

"payment_code":"00"

orders.order_details.payment.payment_details.payment_description

Additional payment information

string

O

"payment_description":"APPROVED"

orders.order_details.payment.payment_details.payment_error_code

Error code 

string

O

"payment_error_code":"test"

orders.order_details.payment.payment_details.payment_message_code

Payment message (code)

string

O

"payment_message_code":"userCancelled"

orders.order_details.payment.payment_details.payment_date

Transaction date

string($date-time)

O

"payment_date":"2023-08-02T09:48:12.302Z"

orders.order_details.order_status

Technical status - used to specify the authorizations that the customer may exercise for the order in the InPost Pay app.

We can distinguish 3 technical statuses:

  

ORDER_COMPLETED- the status assigned by the merchant, informing the InPost Pay app that the order was completed by the customer on the merchant store's website.

ORDER_REJECTED - the status means the order has been rejected.

ORDER_PROCESSING - order in progress

string

Y

"order_status":"ORDER_COMPLETED"

orders.order_details.order_merchant_status_description

A descriptive status presented to the customer in the InPost Pay app - each Merchant may provide the status so that the statuses presented in InPost Mobile are compliant with the status presented to the clients in the Merchant's store.

string

Y

"order_merchant_status_description": "W trakcie realizacji"

orders.order_details.order_base_price

Order price without the delivery costs

object

Y

 

orders.order_details.order_base_price.net

Net

number ($decimal)

Y

"order_base_price":{"net":202.51,"gross":263.0,"vat":60.49},

orders.order_details.order_base_price.gross

Gross

number ($decimal)

Y

orders.order_details.order_base_price.vat

VAT

number ($decimal)

Y

orders.order_details.order_final_price

Order price with the delivery costs

object

Y

 

orders.order_details.order_final_price.net

Net

number ($decimal)

Y

"order_final_price":{"net":208.2,"gross":270.0,"vat":61.8}

orders.order_details.order_final_price.gross

Gross

number ($decimal)

Y

orders.order_details.order_final_price.vat

VAT

number ($decimal)

Y

orders.order_details.order_discount

Value used discount coupons on order

number($decimal) 

"order_discount": 20.2

orders.order_details.currency

Order's currency (currently, PLN only)

string

Y

"currency":"PLN"

orders.order_details.delivery_references_list

List of the numbers assigned to an order's shipments

array

O

"delivery_references_list":[12345678]

orders.account_info

Information about the account used

object

Y

 

orders.account_info.name

First name

string

Y

"account_info":{"name":"Jan","surname":"Kowalski","phone_number":{"country_prefix":"+48","phone":"600000000"}

orders.account_info.surname

Last name

string

Y

orders.account_info.phone_number

Telephone number

object

Y

orders.account_info.phone_number.country_prefix

Prefix

string

Y

orders.account_info.phone_number.phone

User's phone number

string

Y

orders.account_info.mail

Mail

string

Y

"mail":"test@g....m"

orders.account_info.client_address

User's address

object

Y

 

orders.account_info.client_address.country_code

Country code

string

Y

"client_address":{"country_code":"PL","city":"Test","address":"Testowa 3/9 Testowa 3 ","postal_code":"00-000"}

orders.account_info.client_address.address

Address

string

Y

orders.account_info.client_address.city

City

string

Y

orders.account_info.client_address.postal_code

Postal code

string

Y

orders.invoice_details

Invoice data

object

O

 

orders.invoice_details.legal_form

Legal Form [PERSON, COMPANY]

string

O

"invoice_details":{"legal_form":"COMPANY","country_code":"PL","tax_id":"0000000000","company_name":TEST","city":"Warszawa","street":"ul. Testowa","building":"10A","postal_code":"01-997","mail":"test@m...l","registration_data_edited":"true"}

orders.invoice_details.country_code

Country code

string

O

orders.invoice_details.tax_id_prefix

Id prefix

string

O

orders.invoice_details.tax_id

tax identifier

string

O

orders.invoice_details.company_name

Company name

string

O

orders.invoice_details.name

First name

string

O

orders.invoice_details.surname

Last name

string

O

orders.invoice_details.city

City

string

O

orders.invoice_details.street

Street

string

O

orders.invoice_details.building

Building number

string

O

orders.invoice_details.flat

Apartment number

string

O

orders.invoice_details.postal_code

Postal code

string

O

orders.invoice_details.mail

Mail

string

O

orders.invoice_details.registration_data_edited

Registration date

string

O

orders.invoice_details.additional_information

Additional information 

string

O

orders.delivery

Delivery Information

object

Y

 

orders.delivery.delivery_type

Delivery method. Enum:

[ APM, COURIER ]

string

Y

"delivery_type":"COURIER"

orders.delivery.delivery_date

Delivery date

string($date-time)

Y

"delivery_date":"2023-09-10T12:00:00.000Z"

orders.delivery.delivery_options

The options selected for a delivery

array

O

 

orders.delivery.delivery_options.delivery_name

Name

string

Y

"delivery_options":[{"delivery_name":"Paczka w Weekend","delivery_code_value":"PWW","delivery_option_price":{"net":5,"gross":"6.15","vat":"1.15"}}]

orders.delivery.delivery_options.delivery_code_value

Option code

string

Y

orders.delivery.delivery_options.delivery_option_price

Delivery option amount

object

Y

orders.delivery.delivery_options.delivery_option_price.net

Net

number ($decimal)

Y

orders.delivery.delivery_options.delivery_option_price.gross

Gross

number ($decimal)

Y

orders.delivery.delivery_options.delivery_option_price.vat

VAT

number ($decimal)

Y

orders.delivery.mail

Mail

string

O

"mail":"test@g..m"

orders.delivery.phone_number

Phone number

object

O

 

orders.delivery.phone_number.country_prefix

Prefix

string

Y

"phone_number":{"country_prefix":"+48","phone":"600000000"}

orders.delivery.phone_number.phone

Number

string

Y

orders.delivery.delivery_point

Automatic parcel locker delivery site

string

O

"delivery_point":"RSL218"

orders.delivery.delivery_address

Delivery address

object

O

 

orders.delivery.delivery_address.name

Name

string

Y

"delivery_address":{"name":"Jan Kowalski","country_code":"PL","address":"Testowa 3 ","city":"Test","postal_code":"00-000"}

orders.delivery.delivery_address.country_code

Country code

string

Y

orders.delivery.delivery_address.address

Address

string

Y

orders.delivery.delivery_address.city

City

string

Y

orders.delivery.delivery_address.postal_code

Postal code

string

Y

orders.delivery.delivery_price

Object intended to transfer information related to the cost of delivery

object

Y

 

orders.delivery.delivery_price.net

Net price

number ($decimal) (10,2)

Y

"delivery_price":{"net":"10.00","gross":"12.30","vat":"2.30"}

orders.delivery.delivery_price.gross

Gross Price (net + VAT)

number ($decimal) (10,2)

Y

orders.delivery.delivery_price.vat

VAT

number ($decimal) (10,2)

Y

orders.delivery.courier_note

Notes for the courier

string

O

" courier_note ":"Proszę o przekazanie przesyłki po godzinie 16"

orders.products

List of the products in an order

array

Y

 

orders.products.product_id

Product ID assigned by the Merchant

string

Y

"product_id": 26

orders.products.product_category

Product category assigned by the Merchant

string

O

"product_category":20

orders.products.ean

Ean

string

O

"ean":"0"

orders.products.product_name

Product name

string

Y

"product_name": "washpapa backpack"

orders.products.product_description

Product description

string

O

"product_description": "  \r\n\r\nSometimes you just want to leave everything, pack your bags and go to Bieszczady? It's a good plan for holidays. And during the year, simply discover your city again.\r\n\r\ Exploration cannot be successful without a reliable backpack with foldable closings and made of high quality materials, such as our.\r\n\r\nThe cotton straps ensure the convenience of carrying, and washpapa will express your devotion to the nature. Remember! Behind each adventure, there is a good backpack."

orders.products.product_link

Link to the product on the Merchant's website

string

O

"product_link":"https://test.outofthebox.pl/product/plecak-washpapa/"

orders.products.product_image

Link to a photograph of the product. Formats preferable: png, jpg (recommendation: png without background)

 

string

O

"product_image":"https://test.outofthebox.pl/img/2022/10/INPOST_aranzacje-z-modelami25-1.jpg"

orders.products.additional_product_images

Additional product images.

object

O

-

orders.products.additional_product_images.small_size

Product image. Preferred size 360 x 352

string

Y

-

orders.products.additional_product_images.normal_size

Product image. Preferred size 360 x 504

string

Y

-

orders.products.base_price

Product's base price

object

Y

 

orders.products.base_price.net

Net price

number ($decimal) (10,2)

 

Y

"base_price":{"net":"161.79","gross":"199.00","vat":"37.21"}

orders.products.base_price.gross

Gross Price (net + VAT)

number ($decimal) (10,2)

Y

orders.products.base_price.vat

VAT

number ($decimal) (10,2)

Y

orders.products.lowest_price

Object intended to transfer the lowest price of the product over the previous 30 days. Required to handle the Omibus directive

object

O

 

orders.products.lowest_price.net

Net price

number ($decimal) (10,2)

 

Y

"lowest_price ":{"net":"160.98","gross":"198.00","vat":"37.02"}

orders.products.lowest_price.gross

Gross Price (net + VAT)

number ($decimal) (10,2)

 

Y

orders.products.lowest_price.vat

VAT

number ($decimal) (10,2)

 

Y

orders.products.quantity

Object for reporting the product quantity

object

Y

 

orders.products.quantity.quantity

product quantity 

number ($decimal)

Y

"quantity":1

orders.products.quantity.quantity_type

Field type quantity. Available values: [DECIMAL, INTEGER]

 

string

Y

"quantity_type":"INTEGER"

orders.products.quantity.quantity_unit

Quantity unit of the product

string

O

"quantity_unit":"pcs"

orders.products.product_attributes

Object intended to determine the product's attributes

array

O

 

orders.products.product_attributes.attribute_name

Attribute name

string

Y

"product_attributes ": [{ "attribute_name ": "Dimensions/Capacity", "attribute_value ":"54 cm x 38 cm x 10 cm "}, { "attribute_name ": "Material", "attribute_value": "Washable paper standard + kodura + woven cotton straps"}]

orders.products.product_attributes.attribute_value

Attribute value

string

Y

 

orders.products.variants

Object intended to transfer products' variants. Object currently not used. The functionality shall be implemented in the app's subsequent versions.

object

O

 

orders.products.variants.variant_id

Version's Id

string

Y

 

orders.products.variants.variant_name

Version's name

string

Y

 

orders.products.variants.variant_description

Version's detailed description

string

O

 

orders.products.variants.variant_type

Version's type

string

O

 

orders.products.variants.variant_values

Version's value 

string

O

 

orders.consents

An object intended to transfer information related to the consents expressed by the customer for a given order

array

Y

 

orders.consents.consent_id

Consent Id

string

Y

"consent_id":3

orders.consents.consent_version

Consent version 

string

O

"consent_version":1

orders.consents.is_accepted

Information whether the consent has been expressed or not

boolean

Y

"is_accepted": true

GET /v1/izi/orders

Example response

{ "orders": [ { "order_details": { "order_id": "c5bea8ea-4444-4aaa-9ccf-12345678", "pos_id": "V123", "order_creation_date": "2023-10-19T07:18:27.000Z", "order_update_date": "2023-10-19T08:37:23.313Z", "payment": { "payment_type": "BLIK_CODE", "payment_status": "AUTHORIZED", "payment_details": { "payment_reference": "1234_6e8d5ee2-26eb-4953-bb68-12344567", "payment_type": "BLIK_CODE", "payment_status": "AUTHORIZED", "sdk_payment_status": "PENDING", "payment_id": "1234567-3894-2222-3333-d9cad00781b4", "payment_code": "00", "payment_description": "APPROVED", "payment_date": "2023-10-19T05:18:42.202Z", "base_transaction_amount": { "amount": 35.9, "currency": "PLN" } }, "available_payment_types": [ "CARD", "BLIK_CODE", "BLIK_TOKEN", "PAY_BY_LINK", "SHOPPING_LIMIT", "DEFERRED_PAYMENT" ] }, "order_status": "ORDER_REJECTED", "order_merchant_status_description": "Anulowano", "order_base_price": { "net": 19.52, "gross": 24.01, "vat": 4.49 }, "order_final_price": { "net": 29.19, "gross": 35.9, "vat": 6.71 }, "currency": "PLN", "delivery_references_list": [] }, "account_info": { "name": "<secret>", "surname": "<secret>", "phone_number": { "country_prefix": "+48", "phone": "600000000" }, "mail": "jan.kowalski@o...l", "client_address": { "country_code": "pl", "city": "Warszawa", "address": "Warszawska 3,4", "postal_code": "00-000" } }, "delivery": { "delivery_type": "APM", "delivery_date": "2023-10-21T07:18:27.000Z", "mail": "<secret>", "phone_number": { "country_prefix": "+48", "phone": "600000000" }, "delivery_point": "WAW73M", "delivery_price": { "net": 9.67, "gross": 11.89, "vat": 2.22 } }, "products": [ { "product_id": "12345", "ean": "1234567890", "product_name": "Zestaw balonów", "product_link": "https://zestaw-balonow-urodzinowych", "product_image": "https://zestaw-balonow-urodzinowych-granatowo-czarny.jpg", "base_price": { "net": 19.52, "gross": 31.01, "vat": 4.49 }, "quantity": { "quantity": 1, "quantity_type": "INTEGER", "quantity_unit": "szt." } } ], "consents": [ { "consent_id": "7", "consent_version": "2023-06-06", "is_accepted": true }, { "consent_id": "3", "consent_version": "2018-06-07", "is_accepted": true }, { "consent_id": "2", "consent_version": "2018-06-07", "is_accepted": true }, { "consent_id": "4", "consent_version": "2018-06-07", "is_accepted": false } ] }, { "order_details": { "order_id": "123456-36ca-4731-a945-1234567890", "pos_id": "V123456789", "order_creation_date": "2023-10-19T07:30:46.000Z", "order_update_date": "2023-10-19T07:56:45.748Z", "payment": { "payment_type": "CASH_ON_DELIVERY", "payment_status": "COD" }, "order_status": "ORDER_REJECTED", "order_merchant_status_description": "Anulowano", "order_base_price": { "net": 1.45, "gross": 1.78, "vat": 0.33 }, "order_final_price": { "net": 13.08, "gross": 16.08, "vat": 3 }, "currency": "PLN", "delivery_references_list": [] }, "account_info": { "name": "Jan", "surname": "Kwiatkowski", "phone_number": { "country_prefix": "+48", "phone": "000000000" }, "mail": "j.kwiat@o...l", "client_address": { "country_code": "pl", "city": "Warszawa", "address": "Jana Pawła 33", "postal_code": "00-001" } }, "delivery": { "delivery_type": "APM", "delivery_date": "2023-10-21T07:30:46.000Z", "mail": "<secret>", "phone_number": { "country_prefix": "+48", "phone": "000000000" }, "delivery_point": "BPO02A", "delivery_price": { "net": 9.67, "gross": 11.89, "vat": 2.22 } }, "products": [ { "product_id": "3456", "ean": "12345678986", "product_name": "Magiczna gąbka", "product_link": "https://magiczna-gabka", "product_image": "https://magiczna-gabka.png", "base_price": { "net": 1.45, "gross": 1.78, "vat": 0.33 }, "quantity": { "quantity": 1, "quantity_type": "INTEGER", "quantity_unit": "szt." } } ], "consents": [ { "consent_id": "7", "consent_version": "2023-06-06", "is_accepted": true }, { "consent_id": "3", "consent_version": "2018-06-07", "is_accepted": true }, { "consent_id": "2", "consent_version": "2018-06-07", "is_accepted": true }, { "consent_id": "4", "consent_version": "2018-06-07", "is_accepted": false } ] } ], "page_size": 10, "total_items": 2, "page_index": 0 }

Example implementation in PHP

  • Entering the code -

Only the getOrders function has been added in the implementacjaKlienta.txt file.

/** * Client symfony implementation used for communication between Merchant and InPost Pay application. * * @param InpostPayBearerServiceInterface $inpostPayBearerService <p> Bearer service interface, * with contains creating bearer token which is required for communication with Inpost Pay </p> * */ final class InpostPayClient implements InpostPayClientInterface { private ClientInterface $client; private InpostPayURLCreatorInterface $URLCreator; private InpostPayBearerServiceInterface $bearerService; public function __construct( ClientInterface $client, InpostPayURLCreatorInterface $URLCreator, InpostPayBearerServiceInterface $bearerService ) { $this->client = $client; $this->URLCreator = $URLCreator; $this->bearerService = $bearerService; } public function getBaskets(int $pageIndex = null, int $pageSize = null): BasketsResponse { $path = 'baskets'; $uri = (new Uri($this->buildUri($path))) ->withQuery(Psr7\Query::build(['page_index' => $pageIndex, 'page_size' => $pageSize])); $request = new Request( 'GET', $uri, $this->provideDefaultClientHeaders() ); try { $response = $this->client->sendRequest($request); $content = $response->getBody()->getContents(); /** * @var BasketsResponseArray $data */ $data = json_decode($content, true, 512, JSON_THROW_ON_ERROR); return BasketsResponse::fromArray($data); } catch (\Throwable $throwable) { throw InpostPayGetBasketsException::createResponseException($throwable); } } public function getBasketBinding(string $basketId, string $browserId = null): BindingBasket { $path = sprintf('basket/%s/binding', $basketId); $uri = (new Uri($this->buildUri($path))) ->withQuery(Psr7\Query::build(['browser_id' => $browserId])); $request = new Request( 'GET', $uri, $this->provideDefaultClientHeaders() ); try { $response = $this->client->sendRequest($request); $content = $response->getBody()->getContents(); /** * @var BindingBasketArray $data */ $data = json_decode($content, true, 512, JSON_THROW_ON_ERROR); return BindingBasket::fromArray($data); } catch (\Throwable $throwable) { throw InpostPayGetBasketBindingException::createResponseException($throwable); } } public function postBasketBinding(string $basketId, BasketBindingRequest $requestBody): ?QrCodeData { if (BindingMethod::PHONE()->equals($requestBody->getBindingMethod()) && !$requestBody->getPhoneNumber()) { throw InpostPayPostBasketBindingException::createNoPhoneForPhoneBindingMethodException(); } $path = sprintf('basket/%s/binding', $basketId); $uri = new Uri($this->buildUri($path)); /** @var string $body */ $body = json_encode($requestBody); $request = new Request( 'POST', $uri, $this->provideDefaultClientHeaders(), $body ); try { $response = $this->client->sendRequest($request); $statusCode = $response->getStatusCode(); $content = $response->getBody()->getContents(); if (HttpResponseStatus::ACCEPTED()->getValue() === $statusCode) { return null; } if (HttpResponseStatus::OK()->getValue() === $statusCode) { /** * @var QrCodeDataArray $data */ $data = json_decode($content, true, 512, JSON_THROW_ON_ERROR); return QrCodeData::fromArray($data); } } catch (\Throwable $throwable) { throw InpostPayPostBasketBindingException::createResponseException($throwable); } throw InpostPayPostBasketBindingException::createBadStatusCodeException($statusCode, $content); } public function putBasket(string $basketId, Basket $basket): InpostBasketId { $path = sprintf('basket/%s', $basketId); $uri = new Uri($this->buildUri($path)); /** @var string $body */ $body = json_encode($basket); $request = new Request( 'PUT', $uri, $this->provideDefaultClientHeaders(), $body ); try { $response = $this->client->sendRequest($request); $content = $response->getBody()->getContents(); /** * @var array{inpost_basket_id: string} $responseData */ $responseData = json_decode($content, true, 512, JSON_THROW_ON_ERROR); return InpostBasketId::fromArray($responseData); } catch (\Throwable $throwable) { throw InpostPayPutBasketException::createResponseException($throwable); } } public function deleteBasketBinding(string $basketId, bool $ifBasketRealized = null): void { $path = sprintf('basket/%s/binding', $basketId); $uri = (new Uri($this->buildUri($path))) ->withQuery(Psr7\Query::build(['if_basket_realized' => $ifBasketRealized])); $request = new Request( 'DELETE', $uri, $this->provideDefaultClientHeaders() ); try { $response = $this->client->sendRequest($request); $statusCode = $response->getStatusCode(); $content = $response->getBody()->getContents(); } catch (\Throwable $throwable) { throw InpostPayDeleteBasketBindingException::createResponseException($throwable); } if (HttpResponseStatus::NO_CONTENT()->getValue() === $statusCode) { return; } throw InpostPayDeleteBasketBindingException::createBadStatusCodeException($statusCode, $content); } public function deleteBrowserBinding(string $browserId): void { $path = sprintf('browser/%s/binding', $browserId); $uri = new Uri($this->buildUri($path)); $request = new Request( 'DELETE', $uri, $this->provideDefaultClientHeaders() ); try { $response = $this->client->sendRequest($request); $statusCode = $response->getStatusCode(); $content = $response->getBody()->getContents(); } catch (\Throwable $throwable) { throw InpostPayDeleteBrowserBindingException::createResponseException($throwable); } if (HttpResponseStatus::NO_CONTENT()->getValue() === $statusCode) { return; } throw InpostPayDeleteBrowserBindingException::createBadStatusCodeException($statusCode, $content); } public function getSigningKey(string $version): SigningKeyResponse { $path = sprintf('signing-keys/public/%s', $version); $uri = new Uri($this->buildUri($path)); $request = new Request( 'GET', $uri, $this->provideDefaultClientHeaders() ); try { $response = $this->client->sendRequest($request); $statusCode = $response->getStatusCode(); $content = $response->getBody()->getContents(); if (HttpResponseStatus::OK()->getValue() === $statusCode) { /** * @var SigningKeyResponseArray $data */ $data = json_decode($content, true, 512, JSON_THROW_ON_ERROR); return SigningKeyResponse::fromArray($data); } } catch (\Throwable $throwable) { throw InpostPayGetSigningKeyException::createResponseException($throwable); } throw InpostPayGetSigningKeyException::createBadStatusCodeException($statusCode, $content); } public function getSigningKeys(): SigningKeysResponse { $path = 'signing-keys/public'; $uri = new Uri($this->buildUri($path)); $request = new Request( 'GET', $uri, $this->provideDefaultClientHeaders() ); try { $response = $this->client->sendRequest($request); $statusCode = $response->getStatusCode(); $content = $response->getBody()->getContents(); if (HttpResponseStatus::OK()->getValue() === $statusCode) { /** * @var SigningKeysResponseArray $data */ $data = json_decode($content, true, 512, JSON_THROW_ON_ERROR); return SigningKeysResponse::fromArray($data); } } catch (\Throwable $throwable) { throw InpostPayGetSigningKeysException::createResponseException($throwable); } throw InpostPayGetSigningKeysException::createBadStatusCodeException($statusCode, $content); } /** * @return array{ * Authorization: string, * Content-Type: string * } * * @throws InpostPayEndpointException */ private function provideDefaultClientHeaders(): array { return [ 'Authorization' => sprintf('Bearer %s', $this->bearerService->getBearerToken()), 'Content-Type' => 'application/json', ]; } private function buildUri(string $path): string { return sprintf( '%s%s', $this->URLCreator->create()->getUrl(), $path ); } public function postOrderEvent(string $orderId, OrderEventRequest $orderEventRequest): void { $path = sprintf('order/%s/event', $orderId); $uri = new Uri($this->buildUri($path)); /** @var string $body */ $body = json_encode($orderEventRequest); $request = new Request( 'POST', $uri, $this->provideDefaultClientHeaders(), $body ); try { $response = $this->client->sendRequest($request); $statusCode = $response->getStatusCode(); $content = $response->getBody()->getContents(); } catch (\Throwable $throwable) { throw InpostPayPostOrderEventException::createResponseException($throwable); } if (HttpResponseStatus::CREATED()->getValue() === $statusCode) { return; } throw InpostPayPostOrderEventException::createBadStatusCodeException($statusCode, $content); } public function getOrders(int $pageIndex = null, int $pageSize = null): OrdersResponse { $path = 'orders'; $uri = (new Uri($this->buildUri($path))) ->withQuery(Psr7\Query::build(['page_index' => $pageIndex, 'page_size' => $pageSize])); $request = new Request( 'GET', $uri, $this->provideDefaultClientHeaders() ); try { $response = $this->client->sendRequest($request); $content = $response->getBody()->getContents(); /** * @var OrdersResponseArray $data */ $data = json_decode($content, true, 512, JSON_THROW_ON_ERROR); return OrdersResponse::fromArray($data); } catch (\Throwable $throwable) { throw InpostPayGetOrdersException::createResponseException($throwable); } } }
  • SDK.zip contains a code which includes the object of the request and of the endpoint response.