Downloading the list of baskets
The article contains a description of the method which returns the list of bound baskets together with an example implementation of the method in PHP.
On this page:
Description of the method
The method returns any information regarding active baskets bound to 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 | string | O |
|
| Page size | string | O |
|
Request – none
Response
Field name | Description | Type | Requirement status | Additional remarks |
| Page size | string | O |
|
| Total number of items | string | O |
|
| Page index | string | O |
|
| An object which returns the list of active baskets in Inpost Pay | object | Y |
|
| Basket's unique ID assigned by the merchant | string | Y |
|
| The date of creating/binding a basket with the Inpost Pay app | string($date-time) | O |
|
| Date of the last basket update | string($date-time) | O |
|
| Object intended to transfer the basket's key data | object | Y |
|
| Object intended to transfer the main price for the basket without the delivery costs | object | Y |
|
| Net price | number ($decimal) (10,2) | Y |
|
| Gross Price (net + VAT) | number ($decimal) (10,2) | Y | |
| VAT | number ($decimal) (10,2) | Y | |
| Object intended to transfer the basket's final price with any promotion and discount code taken into account without the delivery costs. | object | O |
|
| Net price | number ($decimal) (10,2) | Y |
|
| Gross Price (net + VAT) | number ($decimal) (10,2) | Y | |
| VAT | number ($decimal) (10,2) | Y | |
| An object intended to transfer a basket's price taking into account any promotion without the delivery costs | object | O |
|
| Net price | number ($decimal) (10,2) | Y |
|
| Gross Price (net + VAT) | number ($decimal) (10,2) | Y | |
| VAT | number ($decimal) (10,2) | Y | |
| Basket's currency. Currently, the only currency available PLN | string | Y |
|
| Basket's expiration /validity date. This is the date when the basket will be automatically removed from the Inpost Pay app (it becomes invalid). The date cannot be backward. | string($date-time) | O |
|
| The field is used to transfer additional information of the basket which, from the merchant's point of view, could be significant for the customer | string | O |
|
| Preferable payment methods for the basket. The merchant provides the list of preferred payment forms for a basket from which the customer can choose a payment method. In the case of transferring an empty list, the customer will be presented with a default list of payment methods according to the Merchant's configuration. List with payment types: [CARD, CARD_TOKEN, GOOGLE_PAY, APPLE_PAY, BLIK_CODE, BLIK_TOKEN, PAY_BY_LINK, SHOPPING_LIMIT, DEFERRED_PAYMENT, CASH_ON_DELIVERY] | object | Y |
|
| An object with additional information of the basket which the Merchant wants to transfer to the customer in the Inpost Pay app | object | O |
|
| Information Type. We can distinguish two information types, based on which the app presents the relevant Enum message format: [ATTENTION, ERROR]: ATTENTION – to be used if we want to notify the customer of something significant regarding a basket, e.g. applying promotional codes, adding a free product etc. ERROR – to be used when some action cannot be performed on a basket eg. incorrect discount code or unsuccessful addition of a suggested product.
| string | Y |
|
| The message presented to the customer in the InPost Pay app for the given notice.type | string | Y |
|
| Object intended to transfer information related to delivery methods preferred for the given basket | array | Y |
|
| Delivery method.. Two forms available [APM, COURIER]: APM – parcel locker device, COURIER – Inpost courier | string | Y |
|
| Suggested delivery date | string($date-time) | O |
|
| An object intended to transfer additional delivery options. Currently two additional delivery options available: PWW – Parcel on Weekend; COD – Payment at Delivery. If, for a given basket, the payment_type is CASH_ON_DELIVERY, it is required to enter COD as an additional delivery option.
|
| O |
|
| Name of additional delivery option | string | Y |
|
| Additional delivery option code. Currently available, two codes: PWW – parcel on weekend COD – payment at delivery
| string | Y |
|
| Object intended to transfer information related to the cost of additional delivery options | object | Y |
|
| Net price | number ($decimal) (10,2)
| Y |
|
| Gross Price (net + VAT) | number ($decimal) (10,2)
| Y |
|
| VAT | number ($decimal) (10,2)
| Y |
|
| Object intended to transfer information related to the cost of delivery | object | Y |
|
| Net price | number ($decimal) (10,2)
| Y |
|
| Gross Price (net + VAT) | number ($decimal) (10,2)
| Y |
|
| VAT | number ($decimal) (10,2)
| Y |
|
| The minimum basket value from which the delivery cost will be PLN 0 | number ($decimal) (10,2)
| O |
|
| Functionality using the object will be available in subsequent versions of the application Object used to provide information about the estimated delivery time in the event that the customer orders goods within a specified time. | array | O |
|
| Message presented to the customer in application | string | Y | |
| Days of the week on which the message is presented | array | O | |
| The time from which the message is presented | string | O | |
| The time until which the message is presented | string | O | |
| List of promotional codes applied for the basket | array | O |
|
| Code name (in the subsequent version the field not required) | string | Y |
|
| Promotion code | string | Y |
|
| Specifies the type of regulation or restriction that the promotional code is subject to. | string | O |
|
| An object used to provide a list of available promotions for the cart. | array | O |
|
| Code type: ONLY_IN_APP - code available only in InPost Pay app (TYLKO W APCE). | string | Y | |
| Code value e.g. DOSTAWA | string | Y | |
| Code description Max: 60 characters | string | Y | |
| Start date from which the code is valid | string($date-time) | O | |
| End date until which the code is valid | string($date-time) | O | |
| Code priority | integer | O | |
| Code details | object | Y | |
| Link to code information details on the merchant's website | string | Y | |
| List for providing information of the products in the basket | array | Y |
|
| Product ID assigned by the merchant | string | Y |
|
| Product category assigned by the merchant | string | O |
|
| Ean | string | O |
|
| Product name | string | Y |
|
| Product description | string | O |
|
| Link to the product on the merchant's website | string | O |
|
| Link to a photograph of the product. Formats preferable: png, jpg (recommendation: png without background)
| string | O |
|
| Object to pass additional product images (list) | object | O |
|
| Product image. | string | Y |
|
| Product image. | string | Y |
|
| Product's base price | object | Y |
|
| Net price | number ($decimal) (10,2)
| Y |
|
| Gross Price (net + VAT) | number ($decimal) (10,2)
| Y | |
| VAT | number ($decimal) (10,2)
| Y | |
| Promotional price of the product | object | O |
|
| Net price | number ($decimal) (10,2)
| Y |
|
| Gross Price (net + VAT) | number ($decimal) (10,2)
| Y | |
| VAT | number ($decimal) (10,2)
| Y | |
| Object intended to transfer the lowest price of the product over the previous 30 days. Required in order to handle the Omibus directive. Object required to be transferred if the product's promotional price was provoded (obiekt promo_price). | object | O |
|
| Net price | number ($decimal) (10,2)
| Y |
|
| Gross Price (net + VAT) | number ($decimal) (10,2)
| Y | |
| VAT | number ($decimal) (10,2)
| Y | |
| Object for reporting the product quantity | object | Y |
|
| product quantity | number ($decimal)
| Y |
|
| Type quantity. Available values: [DECIMAL, INTEGER]
| string | Y |
|
| Quantity unit of the product | string | O |
|
| The quantity available at the store | number ($decimal)
| O |
|
| The minimum number of the product a Customer can order e.g. at one order | number ($decimal)
| O |
|
| The maximum number of the product a Customer can order e.g. at one order | number ($decimal)
| O |
|
| The quantity jump value in case of increase/decrease of product quantity by customer (e.g. 0.1 or 0.5 or 0.01) | number ($decimal) | O |
|
| Object intended to determine the product's attributes | array | O |
|
| Attribute name | string | Y |
|
| Attribute value | string | Y |
|
| Object used to provide information about available delivery methods for a product. If there is no delivery_product object, it means that delivery is available in all types. | object | O |
|
| Delivery type | string | O |
|
| Flag indicating whether the delivery type is available. | string | O |
|
| Object intended to transfer the list of products suggested for a given basket that the customer can add from the Inpost Pay app level | array | O |
|
| Product ID assigned by the merchant | string | Y |
|
| Product category assigned by the merchant | string | O |
|
| Ean | string | O |
|
| Product name | string | Y |
|
| Product description | string | O |
|
| Link to the product on the merchant's website | string | O |
|
| Url to a photograph of the product. Formats preferable: png, jpg (recommendation: png without background) | string |
|
|
| Object to pass additional product images (list) | object | O |
|
| Product image. Preferred size 360 x 352 | string | Y |
|
| Product image. Preferred size 360 x 504 | string | Y |
|
| Product's base price | object | Y |
|
| Net price | number ($decimal) (10,2) | Y |
|
| Gross Price (net + VAT) | number ($decimal) (10,2) | Y | |
| VAT | number ($decimal) (10,2) | Y | |
| Promotional price of the product | object | O |
|
| Net price | number ($decimal) (10,2) | Y |
|
| Gross Price (net + VAT) | number ($decimal) (10,2) | Y | |
| VAT | number ($decimal) (10,2) | Y | |
| Object intended to transfer the lowest price of the product over the previous 30 days. Required in order to handle the Omibus directive. Object required to be transferred if the product's promotional price was provoded (obiekt promo_price). | object | O |
|
| Net price | number ($decimal) (10,2) | Y |
|
| Gross Price (net + VAT) | number ($decimal) (10,2) | Y | |
| VAT | number ($decimal) (10,2) | Y | |
| Object for reporting the product quantity | object | Y |
|
| product quantity | number ($decimal)
| Y |
|
| Type quantity. Available values: [DECIMAL, INTEGER]
| string | Y |
|
| Quantity unit of the product | string | O |
|
| The quantity available at the store | number ($decimal) | O |
|
| The minimum number of the product a Customer can order e.g. at one order | number ($decimal) | O |
|
| The maximum number of the product a Customer can order e.g. at one order | number ($decimal) | O |
|
| The quantity jump value in case of increase/decrease of product quantity by customer (e.g. 0.1 or 0.5 or 0.01) | number ($decimal) | O |
|
| Object intended to determine the product's attributes | array | O |
|
| Attribute name | string | Y |
|
| Attribute value | string | Y | |
| Object used to provide information about available delivery methods for a product. If there is no delivery_product object, it means that delivery is available in all types. | object | O |
|
| Delivery type | string | O |
|
| Flag indicating whether the delivery type is available. | boolean | O |
|
| Object informing whether the customer will receive free shipping after adding the suggested product to the cart If if_delivery_free= true is on a given suggested product, the customer will be presented with an appropriate message on that product. | boolean | O |
|
| An object intended to transfer the list of consents for a given basket | array | Y |
|
| Consent IDs assigned by the merchant | string | Y |
|
| Label to the link passed in consent_link | string | O |
|
| Object used to provide an additional link to the consent/regulations | object | O |
|
| Consent ID assigned by the merchant | string | O |
|
| Link redirecting to the full content, e.g. to the merchant’s website | string | O |
|
| Label to the link passed in consent_link | string | O |
|
| The link which redirects to the full content of a consent eg. to the Merchant | string | Y |
|
| Description of the consent, not more than 500 characters | string | Y |
|
| Consent version | string | Y |
|
| Consent type. Available values: Enum: [OPTIONAL, REQUIRED_ONCE, REQUIRED_ALWAYS] OPTIONAL – optional consent REQUIRED_ONCE - required once. A consent of such a type and version will be included in the user's profile, with information that the customer has consented, and, in the case of further baskets, will be checked by default. REQUIRED_ALWAYS - required always. A consent of such a type and version is saved to the user's profile. The customer must consent each time. | string | Y |
|
GET /v1/izi/baskets
Example response
{
"baskets": [
{
"basket_id": "3456789",
"creation_date": "2023-11-15T07:42:57.218Z",
"update_date": "2023-11-15T07:42:57.213Z",
"summary": {
"basket_base_price": {
"net": 13.98,
"gross": 17.2,
"vat": 3.22
},
"basket_final_price": {
"net": 13.98,
"gross": 17.2,
"vat": 3.22
},
"currency": "PLN",
"basket_expiration_date": "2023-11-19T23:00:00.000Z",
"payment_type": [
"CARD",
"CARD_TOKEN",
"GOOGLE_PAY",
"APPLE_PAY",
"BLIK_CODE",
"BLIK_TOKEN",
"PAY_BY_LINK"
]
},
"delivery": [
{
"delivery_type": "APM",
"delivery_date": "2023-11-17T11:00:00.000Z",
"delivery_price": {
"net": 10.56,
"gross": 12.99,
"vat": 2.43
}
},
{
"delivery_type": "COURIER",
"delivery_date": "2023-11-17T11:00:00.000Z",
"delivery_price": {
"net": 10.56,
"gross": 12.99,
"vat": 2.43
}
}
],
"products": [
{
"product_id": "34567",
"ean": "678905432",
"product_name": "Cymbałki",
"product_description": "Dzwonki/cymbałki szkolne 12 tonowe z 2 pałeczkami w zestawie.",
"product_link": "https://p/cymbalki-dzwonki-szkolne-34567/",
"product_image": "https://o/cymbalki-dzwonki-szkolne34567.jpg",
"base_price": {
"net": 13.98,
"gross": 17.2,
"vat": 3.22
},
"quantity": {
"quantity": 1,
"quantity_type": "INTEGER",
"quantity_unit": "sztuka",
"available_quantity": 92,
"max_quantity": 92
}
}
],
"related_products": [
{
"product_id": "999",
"product_name": "Street Fire Mercedes-Benz",
"product_link": "https://p/street-fire-mercedes-benz-143/",
"product_image": "https://o/street-fire-mercedes-benz-143.jpg",
"base_price": {
"net": 59.53,
"gross": 73.22,
"vat": 13.69
},
"quantity": {
"quantity": 1,
"quantity_type": "INTEGER",
"quantity_unit": "sztuka",
"available_quantity": 2,
"max_quantity": 2
}
},
{
"product_id": "7643",
"product_name": "Golf",
"product_link": "https://p/golf-mk1-7643/",
"product_image": "https://o/golf-mk1-7643.jpg",
"base_price": {
"net": 54.1,
"gross": 66.54,
"vat": 12.44
},
"quantity": {
"quantity": 1,
"quantity_type": "INTEGER",
"quantity_unit": "sztuka",
"available_quantity": 9,
"max_quantity": 9
}
},
{
"product_id": "768",
"product_name": "Lamborghini yellow",
"product_link": "https://p/lamborghini-yellow-118/",
"product_image": "https://o/lamborghini-yellow-118.jpg",
"base_price": {
"net": 116.45,
"gross": 143.23,
"vat": 26.78
},
"quantity": {
"quantity": 1,
"quantity_type": "INTEGER",
"quantity_unit": "sztuka",
"available_quantity": 4,
"max_quantity": 4
}
},
{
"product_id": "324",
"product_name": "Figurka Gołąb",
"product_link": "https://p/golab-a-324/",
"product_image": "https://o/golab-a-324.jpg",
"base_price": {
"net": 22.37,
"gross": 27.52,
"vat": 5.15
},
"quantity": {
"quantity": 1,
"quantity_type": "INTEGER",
"quantity_unit": "sztuka",
"available_quantity": 19,
"max_quantity": 19
}
},
{
"product_id": "543",
"product_name": "Zestaw naczyń",
"product_link": "https://p/zestaw-naczyn-543/",
"product_image": "https://o/zestaw-naczyn-543.jpg",
"base_price": {
"net": 22.08,
"gross": 27.16,
"vat": 5.08
},
"quantity": {
"quantity": 1,
"quantity_type": "INTEGER",
"quantity_unit": "sztuka",
"available_quantity": 3,
"max_quantity": 3
}
},
{
"product_id": "678",
"product_name": "Alfa Romeo",
"product_link": "https://p/alfa-romeo-green-678/",
"product_image": "https://o/alfa-romeo-green-678.jpg",
"base_price": {
"net": 43.61,
"gross": 53.64,
"vat": 10.03
},
"quantity": {
"quantity": 1,
"quantity_type": "INTEGER",
"quantity_unit": "sztuka",
"available_quantity": 5,
"max_quantity": 5
}
},
{
"product_id": "111",
"product_name": "Lamborghini white ",
"product_link": "https://p/lamborghini-white-111/",
"product_image": "https://o/lamborghini-white-111.jpg",
"base_price": {
"net": 136.02,
"gross": 167.3,
"vat": 31.28
},
"quantity": {
"quantity": 1,
"quantity_type": "INTEGER",
"quantity_unit": "sztuka",
"available_quantity": 5,
"max_quantity": 5
}
},
{
"product_id": "909",
"product_name": "Porsche green",
"product_link": "https://p/porsche-909/",
"product_image": "https://o/porsche-909.jpg",
"base_price": {
"net": 49.31,
"gross": 60.65,
"vat": 11.34
},
"quantity": {
"quantity": 1,
"quantity_type": "INTEGER",
"quantity_unit": "sztuka",
"available_quantity": 2,
"max_quantity": 1
}
}
],
"consents": [
{
"consent_id": "11",
"consent_link": "https://regulamin/newsletter/",
"consent_description": "Regulamin usługi Newsletter",
"consent_version": "45677",
"requirement_type": "OPTIONAL"
},
{
"consent_id": "12",
"consent_link": "https://regulamin/klienci2023/",
"consent_description": "Informacja o przetwarzaniu danych osobowych",
"consent_version": "4567",
"requirement_type": "REQUIRED_ALWAYS"
},
{
"consent_id": "13",
"consent_link": "https://regulamin/regulamin-2023/",
"consent_description": "Regulamin zakupów w sklepie internetowym",
"consent_version": "6543",
"requirement_type": "REQUIRED_ALWAYS"
}
]
},
{
"basket_id": "111111",
"creation_date": "2023-11-15T00:21:18.372Z",
"update_date": "2023-11-15T00:21:18.368Z",
"summary": {
"basket_base_price": {
"net": 48.7,
"gross": 51.14,
"vat": 2.44
},
"basket_final_price": {
"net": 48.7,
"gross": 51.14,
"vat": 2.44
},
"currency": "PLN",
"basket_expiration_date": "2023-11-19T23:00:00.000Z",
"payment_type": [
"CARD",
"CARD_TOKEN",
"GOOGLE_PAY",
"APPLE_PAY",
"BLIK_CODE",
"BLIK_TOKEN",
"PAY_BY_LINK"
]
},
"delivery": [
{
"delivery_type": "APM",
"delivery_date": "2023-11-17T11:00:00.000Z",
"delivery_price": {
"net": 10.56,
"gross": 12.99,
"vat": 2.43
}
},
{
"delivery_type": "COURIER",
"delivery_date": "2023-11-17T11:00:00.000Z",
"delivery_price": {
"net": 10.56,
"gross": 12.99,
"vat": 2.43
}
}
],
"products": [
{
"product_id": "34556",
"ean": "01234567890",
"product_name": "Czwarte skrzydło",
"product_description": "Opis produktu",
"product_link": "https://b/czwarte-skrzydlo-3456/",
"product_image": "https://o/czwarte-skrzydlo-3456.jpg",
"base_price": {
"net": 48.7,
"gross": 51.14,
"vat": 2.44
},
"quantity": {
"quantity": 1,
"quantity_type": "INTEGER",
"quantity_unit": "sztuka",
"available_quantity": 100,
"max_quantity": 100
}
}
],
"related_products": [
{
"product_id": "8765",
"product_name": "Czegoś tu brakuje...",
"product_link": "https://b/czegos-tu-brakuje-8765/",
"product_image": "https://o/czegos-tu-brakuje-8765.jpg",
"base_price": {
"net": 29.93,
"gross": 31.43,
"vat": 1.5
},
"quantity": {
"quantity": 1,
"quantity_type": "INTEGER",
"quantity_unit": "sztuka",
"available_quantity": 16,
"max_quantity": 16
}
},
{
"product_id": "7777",
"product_name": "Opowiadania",
"product_link": "https://b/opowiadania-7777/",
"product_image": "https://o/opowiadania-7777.jpg",
"base_price": {
"net": 16.08,
"gross": 16.88,
"vat": 0.8
},
"quantity": {
"quantity": 1,
"quantity_type": "INTEGER",
"quantity_unit": "sztuka",
"available_quantity": 100,
"max_quantity": 100
}
},
{
"product_id": "9878",
"product_name": "Bajki",
"product_link": "https://b/bajki-tw-9878/",
"product_image": "https://o/bajki-tw-9878.jpg",
"base_price": {
"net": 36.77,
"gross": 38.61,
"vat": 1.84
},
"quantity": {
"quantity": 1,
"quantity_type": "INTEGER",
"quantity_unit": "sztuka",
"available_quantity": 9,
"max_quantity": 9
}
},
{
"product_id": "6543",
"product_name": "Baśnie",
"product_link": "https://b/basnie-tw-6543/",
"product_image": "https://o/basnie-tw-6543.jpg",
"base_price": {
"net": 18,
"gross": 18.9,
"vat": 0.9
},
"quantity": {
"quantity": 1,
"quantity_type": "INTEGER",
"quantity_unit": "sztuka",
"available_quantity": 87,
"max_quantity": 87
}
},
{
"product_id": "87654",
"product_name": "Nowy tytuł",
"product_link": "https://b/nowy-tytul-87654/",
"product_image": "https://o/nowy-tytul-87654.jpg",
"base_price": {
"net": 46.22,
"gross": 48.53,
"vat": 2.31
},
"quantity": {
"quantity": 1,
"quantity_type": "INTEGER",
"quantity_unit": "sztuka",
"available_quantity": 2,
"max_quantity": 2
}
},
{
"product_id": "7654",
"product_name": "Poradnik",
"product_link": "https://b/poradnik-7654/",
"product_image": "https://o/poradnik-7654.jpg",
"base_price": {
"net": 46.09,
"gross": 48.39,
"vat": 2.3
},
"quantity": {
"quantity": 1,
"quantity_type": "INTEGER",
"quantity_unit": "sztuka",
"available_quantity": 100,
"max_quantity": 100
}
},
{
"product_id": "45678",
"product_name": "Zadania",
"product_link": "https://b/zadania-45678/",
"product_image": "https://o/zadania-45678.jpg",
"base_price": {
"net": 26.67,
"gross": 28,
"vat": 1.33
},
"quantity": {
"quantity": 1,
"quantity_type": "INTEGER",
"quantity_unit": "sztuka",
"available_quantity": 8,
"max_quantity": 8
}
},
{
"product_id": "45670",
"product_name": "Codziennik",
"product_link": "https://b/codziennik-45670/",
"product_image": "https://codziennik-45670.jpg",
"base_price": {
"net": 18.52,
"gross": 19.45,
"vat": 0.93
},
"quantity": {
"quantity": 1,
"quantity_type": "INTEGER",
"quantity_unit": "sztuka",
"available_quantity": 2,
"max_quantity": 1
}
}
],
"consents": [
{
"consent_id": "120",
"consent_link": "https://regulamin/newsletter/",
"consent_description": "Regulamin usługi Newsletter",
"consent_version": "3456",
"requirement_type": "OPTIONAL"
},
{
"consent_id": "121",
"consent_link": "https://regulamin/klienci2023/",
"consent_description": "Informacja o przetwarzaniu danych osobowych",
"consent_version": "123456",
"requirement_type": "REQUIRED_ALWAYS"
},
{
"consent_id": "123",
"consent_link": "https://regulamin/regulamin-2023/",
"consent_description": "Regulamin zakupów w sklepie internetowym",
"consent_version": "34567",
"requirement_type": "REQUIRED_ALWAYS"
}
]
},
],
"page_size": 100,
"total_items": 2,
"page_index": 0
}
Example implementation in PHP
Entering the code -
Only the getBaskets 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
);
}
}
SDK.zip contains a code which includes the object of the request and of the endpoint response.