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.

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

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

string

O

"page_size":1

total_items

Total number of items

string

O

"total_items":159

page_index

Page index

string

O

"page_index":1

baskets

An object which returns the list of active baskets in Inpost Pay

object

Y

 

baskets.basket_id

Basket's unique ID assigned by the merchant

string

Y

 

baskets.creation_date

The date of creating/binding a basket with the Inpost Pay app

string($date-time)

O

"creation_date":"2023-09-14T08:55:34.777Z"

baskets.update_date

Date of the last basket update

string($date-time)

O

"update_date":"2023-09-14T09:05:26.190Z"

baskets.summary

Object intended to transfer the basket's key data

object

Y

 

baskets.summary.basket_base_price

Object intended to transfer the main price for the basket without the delivery costs

object

Y

 

baskets.summary.basket_base_price.net

Net price

number ($decimal) (10,2)

Y

"summary":{"basket_base_price":{"net":"250.00","gross":"307.50","vat":"57.5

baskets.summary.basket_base_price.gross

Gross Price (net + VAT)

number ($decimal) (10,2)

Y

baskets.summary.basket_base_price.vat

VAT

number ($decimal) (10,2)

Y

baskets.summary.basket_final_price

Object intended to transfer the basket's final price with any promotion and discount code taken into account without the delivery costs.
The discount value for products arising out from the application of a code (promotional code that is not regulated by the OMNIBUS directive) displayed in the basket summary will be the difference between the promo_price, and the final_price or the base_price, and the final_price when the products are not promoted.

object

O

 

baskets.summary.basket_final_price.net

Net price

number ($decimal) (10,2)

Y

"basket_final_price":{"net":"220.00","gross":"270.60","vat":"50.60"}

baskets.summary.basket_final_price.gross

Gross Price (net + VAT)

number ($decimal) (10,2)

Y

baskets.summary.basket_final_price.vat

VAT

number ($decimal) (10,2)

Y

baskets.summary.basket_promo_price

An object intended to transfer a basket's price taking into account any promotion without the delivery costs

object

O

 

baskets.summary.basket_promo_price.net

Net price

number ($decimal) (10,2)

Y

"basket_promo_price":{"net":"220.00","gross":"270.60","vat":"50.60"}

baskets.summary.basket_promo_price.gross

Gross Price (net + VAT)

number ($decimal) (10,2)

Y

baskets.summary.basket_promo_price.vat

VAT

number ($decimal) (10,2)

Y

baskets.summary.currency

Basket's currency. Currently, the only currency available PLN

string

Y

"currency":"PLN"

baskets.summary.basket_expiration_date

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

"basket_expiration_date":"2023-09-13T07:40:53.000Z"

baskets.summary.basket_additional_information

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

"basket_additional_information": "Order today, and receive a discount code for future purchases"

baskets.summary.payment_type

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

"payment_type":["CARD","CARD_TOKEN","APPLE_PAY","BLIK_CODE","BLIK_TOKEN","PAY_BY_LINK","SHOPPING_LIMIT","DEFERRED_PAYMENT","GOOGLE_PAY"],

baskets.summary.basket_notice

An object with additional information of the basket which the Merchant wants to transfer to the customer in the Inpost Pay app

object

O

 

baskets.summary.basket_notice.type

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

"type":"ATTENTION"

baskets.summary.basket_notice.description

The message presented to the customer in the InPost Pay app for the given notice.type

string

Y

"description": "the code has been activated"

baskets.delivery

Object intended to transfer information related to delivery methods preferred for the given basket

array

Y

 

baskets.delivery.delivery_type

Delivery method.. Two forms available [APM, COURIER]: APM – parcel locker device, COURIER – Inpost courier

string

Y

"delivery_type":"APM"

baskets.delivery.delivery_date

Suggested delivery date

string($date-time)

O

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

baskets.delivery.delivery_options

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

 

baskets.delivery.delivery_options.delivery_name

Name of additional delivery option

string

Y

"delivery_name": "Paczka w Weekend"

baskets.delivery.delivery_options.delivery_code_value

Additional delivery option code. Currently available, two codes:

PWW – parcel on weekend

COD – payment at delivery

 

string

Y

"delivery_code_value": "PWW"

baskets.delivery.delivery_options.delivery_option_price

Object intended to transfer information related to the cost of additional delivery options

object

Y

 

baskets.delivery.delivery_options.delivery_option_price.net

Net price

number ($decimal) (10,2)

 

Y

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

baskets.delivery.delivery_options.delivery_option_price.gorss

Gross Price (net + VAT)

number ($decimal) (10,2)

 

Y

 

baskets.delivery.delivery_options.delivery_option_price.vat

VAT

number ($decimal) (10,2)

 

Y

 

baskets.delivery.delivery_price

Object intended to transfer information related to the cost of delivery

object

Y

 

baskets.delivery.delivery_price.net

Net price

number ($decimal) (10,2)

 

Y

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

baskets.delivery.delivery_price.gross

Gross Price (net + VAT)

number ($decimal) (10,2)

 

Y

 

baskets.delivery.delivery_price.vat

VAT

number ($decimal) (10,2)

 

Y

 

baskets.delivery.free_delivery_minimum_gross_price

The minimum basket value from which the delivery cost will be PLN 0

number ($decimal) (10,2)

 

O

"free_delivery_minimum_gross_price": "100.00"

baskets.delivery.estimate_delivery_time

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

"estimate_delivery_time": [
{
"description": "Kup do 15:00 - dostawa jutro",
"days_available": [
"MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY"
],
"start_hour": "10:00",
"end_hour": "15:00"
}
]
}
],

baskets.delivery.estimate_delivery_time.description

Message presented to the customer in application

string

Y

baskets.delivery.estimate_delivery_time.days_available

Days of the week on which the message is presented

array

O

baskets.delivery.estimate_delivery_time.start_hour

The time from which the message is presented

string

O

baskets.delivery.estimate_delivery_time.end_hour

The time until which the message is presented

string

O

baskets.promo_codes

List of promotional codes applied for the basket

array

O

 

baskets.promo_codes.name

Code name (in the subsequent version the field not required)

string

Y

"name ": "Promotion 5%"

baskets.promo_codes.promo_code_value

Promotion code

string

Y

"promo_code_value": "INPOST10"

baskets.promo_codes.regulation_type

Specifies the type of regulation or restriction that the promotional code is subject to.
NOTE:  If the promo code is regulated by the Omnibus Directive then pass "OMNIBUS".

string

O

"regulation_type": "OMNIBUS"

baskets.promotions_available

An object used to provide a list of available promotions for the cart.

array

O

"promotions_available": [

    {

      "type": "MERCHANT",

      "promo_code_value": "IZI",

      "description": "Super promocja – 20 PLN ",

      "start_date": "2024-10-03T07:33:13.942Z",

      "end_date": "2024-11-03T07:33:13.942Z",

      "priority": 0,

      "details": {

        "link": " https://inpostpay.pl/ "

      }

    }

  ],

baskets.promotions_available.type

Code type:
Enum:[ MERCHANT, ONLY_IN_APP ]
 
MERCHANT -  code available in the merchant store and InPost Pay app (KOD SKLEPU)

ONLY_IN_APP - code available only in InPost Pay app (TYLKO W APCE).

string 

Y

baskets.promotions_available.promo_code_value

Code value e.g. DOSTAWA

string 

Y

baskets.promotions_available.description

Code description

Max: 60 characters

string 

Y

baskets.promotions_available.start_date

Start date from which the code is valid

string($date-time)

O

baskets.promotions_available.end_date

End date until which the code is valid

string($date-time)

O

baskets.promotions_available.priority

Code priority
Priority is used to determine the order in which codes are presented in the cart details (the lowest value has the highest priority).

integer

O

baskets.promotions_available.details

Code details

object

Y

baskets.promotions_available.details.link

Link to code information details on the merchant's website

string 

Y

baskets.products

List for providing information of the products in the basket

array

Y

 

baskets.products.product_id

Product ID assigned by the merchant

string

Y

"product_id": 26

baskets.products.product_category

Product category assigned by the merchant

string

O

"product_category":20

baskets.products.ean

Ean

string

O

"ean":"0"

baskets.products.product_name

Product name

string

Y

"product_name": "washpapa backpack"

baskets.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."

baskets.products.product_link

Link to the product on the merchant's website

string

O

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

baskets.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"

baskets.products.additional_product_images

Object to pass additional product images (list)

object

O

-

baskets.products.additional_product_images. small_size

Product image.
Preferred size 360 x 352

string

Y

-

baskets.products.additional_product_images. normal_size

Product image.
Preferred size 360 x 504

string

Y

-

baskets.products.base_price

Product's base price

object

Y

 

baskets.products.base_price.net

Net price

number ($decimal) (10,2)

 

Y

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

baskets.products.base_price.gross

Gross Price (net + VAT)

number ($decimal) (10,2)

 

Y

baskets.products.base_price.vat

VAT

number ($decimal) (10,2)

 

Y

baskets.products.promo_price

Promotional price of the product

object

O

 

baskets.products.promo_price.net

Net price

number ($decimal) (10,2)

 

Y

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

baskets.products.promo_price.gorss

Gross Price (net + VAT)

number ($decimal) (10,2)

 

Y

baskets.products.promo_price.vat

VAT

number ($decimal) (10,2)

 

Y

baskets.products.lowest_price

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

 

baskets.products.lowest_price.net

Net price

number ($decimal) (10,2)

 

Y

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

baskets.products.lowest_price.gorss

Gross Price (net + VAT)

number ($decimal) (10,2)

 

Y

baskets.products.lowest_price.vat

VAT

number ($decimal) (10,2)

 

Y

baskets.products.quantity

Object for reporting the product quantity

object

Y

 

baskets.products.quantity.quantity

product quantity 

number ($decimal)

 

Y

"quantity":1

baskets.products.quantity.quantity_type

Type quantity. Available values: [DECIMAL, INTEGER]

 

string

Y

"quantity_type":"INTEGER"

baskets.products.quantity.quantity_unit

Quantity unit of the product

string

O

"quantity_unit":"pcs"

baskets.products.quantity.available_quantity

The quantity available at the store

number ($decimal)

 

O

"available_quantity":26

baskets.products.quantity.min_quantity 

The minimum number of the product a Customer can order e.g. at one order

number ($decimal) 

 

"min_quantity": 2

baskets.products.quantity.max_quantity

The maximum number of the product a Customer can order e.g. at one order

number ($decimal)

 

O

"max_quantity":26

baskets.products.quantity.quantity_jump

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

"quantity_jump": 0.5

baskets.products.product_attributes

Object intended to determine the product's attributes

array

O

 

baskets.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"}]

baskets.products.product_attributes.attribute_value

Attribute value

string

Y

 

baskets.products.delivery_product

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

 

baskets.products.delivery_product.delivery_type

Delivery type

string

O

 

baskets.products.delivery_product.if_delivery_available

Flag indicating whether the delivery type is available.

string

O

 

baskets.related_products

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

 

baskets.related_products.product_id

Product ID assigned by the merchant

string

Y

"product_id": 26

baskets.related_products.product_category

Product category assigned by the merchant

string

O

"product_category":20

baskets.related_products.ean

Ean

string

O

"ean":"0"

baskets.related_products.product_name

Product name

string

Y

"product_name": "washpapa backpack"

baskets.related_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."

baskets.related_products.product_link

Link to the product on the merchant's website

string

O

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

baskets.related_products.product_image

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

string

  

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

baskets.related_products.additional_product_images

Object to pass additional product images (list)

object

O

-

baskets.related_products.additional_product_images. small_size

Product image. Preferred size 360 x 352

string

Y

-

baskets.related_products.additional_product_images. normal_size

Product image. Preferred size 360 x 504

string

Y

-

baskets.related_products.base_price

Product's base price

object

Y

 

baskets.related_products.base_price.net

Net price

number ($decimal) (10,2)

Y

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

baskets.related_products.base_price.gross

Gross Price (net + VAT)

number ($decimal) (10,2)

Y

baskets.related_products.base_price.vat

VAT

number ($decimal) (10,2)

Y

baskets.related_products.promo_price

Promotional price of the product

object

O

 

baskets.related_products.promo_price.net

Net price

number ($decimal) (10,2)

Y

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

baskets.related_products.promo_price.gross

Gross Price (net + VAT)

number ($decimal) (10,2)

Y

baskets.related_products.promo_price.vat

VAT

number ($decimal) (10,2)

Y

baskets.related_products.lowest_price

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

 

baskets.related_products.lowest_price.net

Net price

number ($decimal) (10,2)

Y

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

baskets.related_products.lowest_price.gorss

Gross Price (net + VAT)

number ($decimal) (10,2)

Y

baskets.related_products.lowest_price.vat

VAT

number ($decimal) (10,2)

Y

baskets.related_products.quantity

Object for reporting the product quantity

object

Y

 

baskets.related_products.quantity.quantity

product quantity 

number ($decimal)

 

Y

"quantity":1

baskets.related_products.quantity.quantity_type

Type quantity. Available values: [DECIMAL, INTEGER]

 

string

Y

"quantity_type":"INTEGER"

baskets.related_products.quantity.quantity_unit

Quantity unit of the product

string

O

"quantity_unit":"pcs"

baskets.related_products.quantity.available_quantity

The quantity available at the store

number ($decimal)

O

"available_quantity":26

baskets.related_products.quantity.min_quantity 

The minimum number of the product a Customer can order e.g. at one order

number ($decimal) 

"min_quantity":2 

baskets.related_products.quantity.max_quantity

The maximum number of the product a Customer can order e.g. at one order

number ($decimal)

O

"max_quantity":26

baskets.related_products.quantity.quantity_jump

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

"quantity_jump": 0.5

baskets.related_products.product_attributes

Object intended to determine the product's attributes

array

O

 

baskets.related_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"}]

baskets.related_products.product_attributes.attribute_value

Attribute value

string

Y

baskets.related_products.delivery_related_products

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

 

baskets.related_products.delivery_related_products.delivery_type

Delivery type

string

O

 

baskets.related_products.delivery_related_products.if_delivery_available

Flag indicating whether the delivery type is available.

boolean

O

 

related_products.delivery_related_products.if_delivery_free

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

 

baskets.consents

An object intended to transfer the list of consents for a given basket

array

 Y

 

baskets.consents.consent_id

Consent IDs assigned by the merchant

string

 Y

"consent_id":3

baskets.consents.label_link

Label to the link passed in consent_link

string

O

"label_link": "Regulaminu",

baskets.consents.additional_consent_links

Object used to provide an additional link to the consent/regulations

object

O

 

baskets.consents.additional_consent_links.id

Consent ID assigned by the merchant

string

O

"id": "0"

baskets.consents.additional_consent_links.consent_link

Link redirecting to the full content, e.g. to the merchant’s website

string

O

"consent_link": "https://uat.outofthebox.pl/privacy-policy/",

baskets.consents.additional_consent_links.label_link

Label to the link passed in consent_link

string

O

"label_link": "Polityką prywatności"

baskets.consents.consent_link

The link which redirects to the full content of a consent eg. to the Merchant

string

 Y

"consent_link":"https://test.outofthebox.pl/zwroty-i-reklamacje/"

baskets.consents.consent_description

Description of the consent, not more than 500 characters

string

 Y

"consent_description": "zwroty i reklamacje"

baskets.consents.consent_version

Consent version 

string

 Y

"consent_version":1

baskets.consents.requirement_type

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

"requirement_type":"OPTIONAL"


 

 

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.