Pobranie listy koszyków

Artykuł zawiera opis metody zwracającej listę powiązanych koszyków wraz z przykładem implementacji metody w języku PHP.

Opis metody

Metoda zwracająca informacje o aktywnych koszykach powiązanych z aplikacją Inpost Pay. Metoda nie wykorzystywana w procesie wiązania i obsługi koszyków/zamówień przez klienta.

Parameters 

Nazwa pola 

Opis  

Typ 

Wymagalność 

Dodatkowe uwagi 

page_index

Indeks stron 

string 

 

page_size

Rozmiar strony 

string 

 

 

Request – brak 

Response 

Nazwa pola 

Opis  

Typ 

Wymagalność 

Dodatkowe uwagi 

page_size 

Rozmiar strony 

string 

"page_size":1 

total_items 

Całkowita liczba pozycji 

string 

"total_items":159 

page_index 

Indeks stron 

string 

"page_index":1 

baskets 

Obiekt zwracający listę aktywnych koszyków w Inpost Pay 

object 

 

baskets.basket_id 

Unikalny identyfikator koszyka nadawany przez merchanta 

string 

 

baskets.creation_date 

Data utworzenia/powiązania koszyka z aplikacją Inpost Pay 

string($date-time) 

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

baskets.update_date 

Data ostatniej aktualizacji koszyka 

string($date-time) 

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

baskets.summary 

Obiekt służący do przekazania podstawowych danych o koszyku 

object 

 

baskets.summary.basket_base_price 

Obiekt służący do przekazania ceny podstawowej za koszyk bez kosztów dostawy 

object 

 

baskets.summary.basket_base_price.net 

Cena netto 

number ($decimal)(10,2) 

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

baskets.summary.basket_base_price.gross 

Cena brutto (netto + VAT) 

number ($decimal)(10,2) 

baskets.summary.basket_base_price.vat 

VAT 

number ($decimal)(10,2) 

baskets.summary.basket_final_price 

Obiekt służący do przekazania ceny koszyka z uwzględnionym kodem rabatowym bez kosztów dostawy. Jeśli nie ma zastosowanego kodu rabatowego: final_price = promo_price 

object 

 

baskets.summary.basket_final_price.net 

Cena netto 

number ($decimal)(10,2) 

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

 

baskets.summary.basket_final_price.gross 

Cena brutto (netto + VAT) 

number ($decimal)(10,2) 

baskets.summary.basket_final_price.vat 

VAT 

number ($decimal)(10,2) 

baskets.summary.basket_promo_price 

Obiekt służący do przekazania ceny koszyka z uwzględnioną promocją bez kosztów dostawy 

object 

 

baskets.summary.basket_promo_price.net 

Cena netto 

number ($decimal)(10,2) 

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

baskets.summary.basket_promo_price.gross 

Cena brutto (netto + VAT) 

number ($decimal)(10,2) 

baskets.summary.basket_promo_price.vat 

VAT 

number ($decimal)(10,2) 

baskets.summary.currency 

Waluta koszyka. Obecnie obsługiwana tylko waluta PLN 

string 

"currency":"PLN"

baskets.summary.basket_expiration_date 

Data wygaśnięcia/ważności koszyka. Jest to data, po której koszyk zostanie automatycznie usunięty z aplikacji Inpost Pay (straci ważność). Data nie może być przeszła. 

string($date-time) 

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

baskets.summary.basket_additional_information 

Pole służy do przekazania dodatkowych informacji o koszyku, które z punktu widzenia merchanta mogą być istotne dla klienta 

string 

"basket_additional_information":"Zamów już dziś, a otrzymasz kod promocyjny na przyszłe zakupy" 

baskets.summary.payment_type 

Preferowane formy płatności dla koszyka. Merchant przekazuje listę preferowanych form płatności dla koszyka z których następnie klient mam możliwość wybrania form płatności. W przypadku przekazania pustej listy, klientowi zostanie zaprezentowana domyślna lista płatności zgodnie z konfiguracją merchnata.  

Lista z możliwymi typami płatności: [ CARD, CARD_TOKEN, GOOGLE_PAY, APPLE_PAY, BLIK_CODE, BLIK_TOKEN, PAY_BY_LINK, SHOPPING_LIMIT, DEFERRED_PAYMENT, CASH_ON_DELIVERY ] 

object 

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

baskets.summary.basket_notice 

Obiekt z informacją dodatkową o koszyku, o której merchant chce poinformować klienta w aplikacji Inpost Pay 

object 

 

baskets.summary.basket_notice.type 

Typ informacji. Wyróżniamy dwa typy informacji, na podstawie której, aplikacjia zaprezentuje odpowiedni format komunikatu Enum: [ ATTENTION, ERROR ]: 

ATTENTION – wykorzystujemy w przypadku, gdy chcemy poinformować klient o istotnych informacjach na koszyku, np. zastosowanie kodu promocyjnego, dodanie produktu gratis etc. 

ERROR – wykorzystujemy w przypadku, gdy nie udało się wykonać jakiegoś działania na koszyku np. niepoprawny kod promocyjny lub nie udana próba dodania produktu sugerowanego. 

  

string 

"type":"ATTENTION"

baskets.summary.basket_notice.description 

Treść komunikatu prezentowana klientowi w aplikacji Inpost Pay dla danego notice.type 

string 

"description":"Kod został aktywowany"

baskets.delivery 

Obiekt służący do przekazania informacji o preferowanych formach dostawy dla danego koszyka 

array 

 

baskets.delivery.delivery_type 

Forma dostawy. Dostępne dwie formy [ APM, COURIER ]: APM – paczkomat, COURIER – kurier Inpost 

string 

"delivery_type":"APM" 

baskets.delivery.delivery_date 

Sugerowana data dostawy 

string($date-time) 

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

baskets.delivery.delivery_options 

Obiekt służący do przekazania dodatkowych opcji dostawy.  Obecnie dostępne dwie dodatkowe opcje dostawy: 

PWW – paczka w weekend; 

COD – płatność przy odbierze.  

W przypadku, gdy dla danego koszyka w payment_type zostanie przekazana wartość CASH_ON_DELIVERY, obligatoryjnie należy przekazać COD jako dodatkową, opcje dostawy. 

 

array

 

baskets.delivery.delivery_options.delivery_name 

Nazwa dodatkowej opcji dostawy 

string 

"delivery_name": "Paczka w Weekend"

baskets.delivery.delivery_options.delivery_code_value 

Kod dodatkowej opcji dostawy. Obecnie dostępne dwa kody: 

PWW – paczka w weekend  

COD – płatność przy odbierze 

 

string 

"delivery_code_value": "PWW"

 

baskets.delivery.delivery_options.delivery_option_price 

Obiekt służący do przekazania informacji o koszcie dodatkowych opcji dostawy 

object 

 

baskets.delivery.delivery_options.delivery_option_price.net 

Cena netto 

number ($decimal)(10,2) 

 

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

baskets.delivery.delivery_options.delivery_option_price.gorss 

Cena brutto (netto + VAT) 

number ($decimal)(10,2) 

 

 

baskets.delivery.delivery_options.delivery_option_price.vat 

VAT 

number ($decimal)(10,2) 

 

 

baskets.delivery.delivery_price 

Obiekt służący do przekazania informacji o koszcie dostawy  

object 

 

baskets.delivery.delivery_price.net 

Cena netto 

number ($decimal)(10,2) 

 

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

baskets.delivery.delivery_price.gross 

Cena brutto (netto + VAT) 

number ($decimal)(10,2) 

 

 

baskets.delivery.delivery_price.vat 

VAT 

number ($decimal)(10,2) 

 

 

baskets.delivery.free_delivery_minimum_gross_price 

Minimalna wartość koszyka od jakiej koszt dostawy będzie wynosił 0 PLN 

number ($decimal)(10,2) 

 

"free_delivery_minimum_gross_price": "100.00"

baskets.promo_codes 

Lista kodów promocyjnych zastosowanych na koszyku 

array 

 

baskets.promo_codes.name 

Nazwa kodu (w kolejnej wersji aplikacji pole nie wymagalne) 

string 

"name": "Promocja 5%" 

 

baskets.promo_codes.promo_code_value 

Kod promocyjny 

string 

"promo_code_value": "INPOST10"

baskets.products 

Lista do przekazania informacji o produktach w koszyku 

array 

 

baskets.products.product_id 

Identyfikator produktu nadany przez merchanta 

string 

"product_id":26

baskets.products.product_category 

Kategoria produktu nadana przez merchanta 

string 

"product_category":20

baskets.products.ean 

Ean 

string 

"ean":"0"

baskets.products.product_name 

Nazwa produktu  

string 

"product_name":"Plecak washpapa"

baskets.products.product_description 

Opis produktu 

string 

"product_description":" \r\n\r\nCzasem masz ochotę rzucić wszystko, spakować się i wyjechać w Bieszczady? Jest to dobry plan na wakacje. A w ciągu roku po prostu odkrywaj swoje miasto na nowo.\r\n\r\nUdana eksploracja nie obędzie się bez solidnego plecaka ze zwijanym zamknięciem i uszytego z wysokiej jakości materiałów, takiego jak nasz.\r\n\r\nBawełniane pasy zapewnią wygodę noszenia, a washpapa wyrazi Twoje przywiązanie do natury. Pamiętaj! Za każdą przygodą stoi dobry plecak."

baskets.products.product_link 

Link do produktu na stronie merchanta 

string 

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

baskets.products.product_image 

Link do zdjęcia produktu. Preferowane format: png, jpg (rekomendacja: png bez tła) 

 

string 

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

baskets.products.additional_product_images

Obiekt do przekazania dodatkowych zdjęć produktu (lista)

object

O

-

baskets.products.additional_product_images. small_size

Zdjęcie produktu. Preferowany rozmiar 360 x 352

string

Y

-

baskets.products.additional_product_images. normal_size

Zdjęcie produktu. Preferowany rozmiar 360 x 504

string

Y

-

baskets.products.base_price 

Cena podstawowa z produkt 

object 

 

baskets.products.base_price.net 

Cena netto 

number ($decimal)(10,2) 

 

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

baskets.products.base_price.gross 

Cena brutto (netto + VAT) 

number ($decimal)(10,2) 

 

baskets.products.base_price.vat 

VAT 

number ($decimal)(10,2) 

 

baskets.products.promo_price 

Cena promocyjna produktu 

object 

 

baskets.products.promo_price.net 

Cena netto 

number ($decimal)(10,2) 

 

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

baskets.products.promo_price.gorss 

Cena brutto (netto + VAT) 

number ($decimal)(10,2) 

 

baskets.products.promo_price.vat 

VAT 

number ($decimal)(10,2) 

 

baskets.products.lowest_price 

Obiekt służący do przekazania najniższej ceny produktu z ostatnich 30 dni. Wymagane w celu obsłużenia dyrektywy Omibus. Obiekt należy przekazać obligatoryjnie w przypadku, gdy została przekazania cena promocyjna produktu (obiekt promo_price).

object 

 

baskets.products.lowest_price.net 

Cena netto 

number ($decimal)(10,2) 

 

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

baskets.products.lowest_price.gorss 

Cena brutto (netto + VAT) 

number ($decimal)(10,2) 

 

baskets.products.lowest_price.vat 

VAT 

number ($decimal)(10,2) 

 

baskets.products.quantity 

Obiekt do przekazania informacji o ilości produktu 

object 

 

baskets.products.quantity.quantity 

Ilość produktu 

number ($decimal) 

 

"quantity":1 

baskets.products.quantity.quantity_type 

Typ quantity. Dostępne wartości: [ DECIMAL, INTEGER ] 

 

string 

"quantity_type":"INTEGER" 

baskets.products.quantity.quantity_unit 

Jednostka ilości produktu 

string 

"quantity_unit":"pcs" 

baskets.products.quantity.available_quantity 

Ilość dostępnego produktu sklepie 

number ($decimal) 

 

"available_quantity":26 

baskets.products.quantity.min_quantity 

Minimalna ilość produktu jaką klient może zamówić np. przy jednym zamówieniu 

number ($decimal) 

 

"min_quantity": 2

baskets.products.quantity.max_quantity 

Maksymalna ilość produktu jaką klient może zamówić np. przy jednym zamówieniu 

number ($decimal) 

 

"max_quantity": 26 

baskets.products.quantity.quantity_jump

Wartość skoku ilości w przypadku zwiększenia/zmniejszenia ilości produktu przez klienta (np. 0,1 lub 0,5 lub 0,01)

number ($decimal)    

O

"quantity_jump": 0.5

baskets.products.product_attributes 

Obiekt służący do określenia atrybutów produktu 

array 

 

baskets.products.product_attributes.attribute_name 

Nazwa atrybutu 

string 

"product_attributes":[{"attribute_name":"Wymiary/Pojemność","attribute_value":"54 cm x 38 cm x 10 cm"},{"attribute_name":"Materiał","attribute_value":"Washable paper standard + kodura + pasy bawełniane tkane"}]

baskets.products.product_attributes.attribute_value 

Wartość atrybutu 

string 

 

baskets.products.variants 

Obiekt służący do przekazania wariantów produktów. Obiekt obecnie nie wykorzystywany. Funkcjonalność będzie wdrażana w kolejnych wersjach aplikacji. 

object 

 

baskets.products.variants.variant_id 

Id wariantu 

string 

 

baskets.products.variants.variant_name 

Nazwa wariantu 

string 

 

baskets.products.variants.variant_description 

Opis szczegółowy wariantu 

string 

 

baskets.products.variants.variant_type 

Typ wariantu 

string 

 

baskets.products.variants.variant_values 

Wartość wariantu 

string 

 

baskets.products.delivery_product

Obiekt służący do przekazania informacji o dostępnych formach dostawy dla produktu. Jeśli brak obiektu delivery_product oznacza że dostawa dostępna wszystkimi typami

object

O

 

baskets.products.delivery_product.delivery_type

Typ dostawy

string

O

 

baskets.products.delivery_product.if_delivery_available

Flaga informująca czy typ dostawy dostępna

boolean

O

 

baskets.related_products 

Obiekt służący do przekazania listy produktów sugerowanych dla danego koszyka, które klient może dodać z poziomu aplikacji Inpost Pay 

array 

 

baskets.related_products.product_id 

Identyfikator produktu nadany przez merchanta 

string 

"product_id":26 

baskets.related_products.product_category 

Kategoria produktu nadana przez merchanta 

string 

"product_category":20 

baskets.related_products.ean 

Ean 

string 

"ean":"0" 

baskets.related_products.product_name 

Nazwa produktu  

string 

"product_name":"Plecak washpapa"

baskets.related_products.product_description 

Opis produktu 

string 

"product_description":" \r\n\r\nCzasem masz ochotę rzucić wszystko, spakować się i wyjechać w Bieszczady? Jest to dobry plan na wakacje. A w ciągu roku po prostu odkrywaj swoje miasto na nowo.\r\n\r\nUdana eksploracja nie obędzie się bez solidnego plecaka ze zwijanym zamknięciem i uszytego z wysokiej jakości materiałów, takiego jak nasz.\r\n\r\nBawełniane pasy zapewnią wygodę noszenia, a washpapa wyrazi Twoje przywiązanie do natury. Pamiętaj! Za każdą przygodą stoi dobry plecak." 

baskets.related_products.product_link 

Link do produktu na stronie merchanta 

string 

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

baskets.related_products.product_image 

Url do zdjęcia produktu. Preferowany format: png, jpg (rekomendacja: png bez tła) 

string 

  

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

baskets.related_products.additional_product_images

Obiekt do przekazania dodatkowych zdjęć produktu (lista)

object

O

-

baskets.related_products.additional_product_images. small_size

zdjęcie produktu. Preferowany rozmiar 360 x 352

string

Y

-

baskets.related_products.additional_product_images. normal_size

zdjęcie produktu. Preferowany rozmiar 360 x 504

string

Y

-

baskets.related_products.base_price 

Cena podstawowa z produkt 

object 

 

 

baskets.related_products.base_price.net 

Cena netto 

number ($decimal)(10,2) 

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

baskets.related_products.base_price.gross 

Cena brutto (netto + VAT) 

number ($decimal)(10,2) 

baskets.related_products.base_price.vat 

VAT 

number ($decimal)(10,2) 

baskets.related_products.promo_price 

Cena promocyjna produktu 

object 

 

baskets.related_products.promo_price.net 

Cena netto 

number ($decimal)(10,2) 

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

baskets.related_products.promo_price.gross 

Cena brutto (netto + VAT) 

number ($decimal)(10,2) 

baskets.related_products.promo_price.vat 

VAT 

number ($decimal)(10,2) 

baskets.related_products.lowest_price 

Obiekt służący do przekazania najniższej ceny produktu z ostatnich 30 dni. Wymagane w celu obsłużenia dyrektywy Omibus. Obiekt należy przekazać obligatoryjnie w przypadku, gdy została przekazania cena promocyjna produktu (obiekt promo_price).

object 

 

baskets.related_products.lowest_price.net 

Cena netto 

number ($decimal)(10,2) 

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

baskets.related_products.lowest_price.gorss 

Cena brutto (netto + VAT) 

number ($decimal)(10,2) 

baskets.related_products.lowest_price.vat 

VAT 

number ($decimal)(10,2) 

baskets.related_products.quantity 

Obiekt do przekazania informacji o ilości produktu 

object 

 

baskets.related_products.quantity.quantity 

Ilość produktu 

number ($decimal) 

 

"quantity":1

baskets.related_products.quantity.quantity_type 

Typ quantity. Dostępne wartości: [ DECIMAL, INTEGER ] 

 

string 

"quantity_type":"INTEGER" 

baskets.related_products.quantity.quantity_unit 

Jednostka ilości produktu 

string 

"quantity_unit":"pcs" 

baskets.related_products.quantity.available_quantity 

Ilość dostępnego produktu sklepie 

number ($decimal) 

"available_quantity":26 

baskets.related_products.quantity.min_quantity

Minimalna  ilość produktu jaką klient może zamówić np. przy jednym zamówieniu 

number ($decimal) 

"min_quantity": 2 

baskets.related_products.quantity.max_quantity

Maksymalna ilość produktu jaką klient może zamówić np. przy jednym zamówieniu 

number ($decimal) 

"max_quantity": 26 

baskets.related_products.quantity.quantity_jump

Wartość skoku ilości w przypadku zwiększenia/zmniejszenia ilości produktu przez klienta (np. 0,1 lub 0,5 lub 0,01)

number ($decimal)    

O

"quantity_jump": 0.5

baskets.related_products.product_attributes 

Obiekt służący do określenia atrybutów produktu 

array 

 

baskets.related_products.product_attributes.attribute_name 

Nazwa atrybutu 

string 

"product_attributes":[{"attribute_name":"Wymiary/Pojemność","attribute_value":"54 cm x 38 cm x 10 cm"},{"attribute_name":"Materiał","attribute_value":"Washable paper standard + kodura + pasy bawełniane tkane"}] 

 

baskets.related_products.product_attributes.attribute_value 

Wartość atrybutu 

string 

baskets.related_products.variants 

Obiekt służący do przekazania wariantów produktów. Obiekt obecnie nie wykorzystywany. Funkcjonalność będzie wdrażana w kolejnych wersjach aplikacji. 

object 

 

baskets.related_products.variants.variant_id 

Id wariantu 

string 

 

baskets.related_products.variants.variant_name 

Nazwa wariantu 

string 

 

baskets.related_products.variants.variant_description 

Opis szczegółowy wariantu 

string 

 

baskets.related_products.variants.variant_type 

Typ wariantu 

string 

 

baskets.related_products.variants.variant_values 

Wartość wariantu 

string 

 

baskets.related_products.delivery_related_products

Obiekt służący do przekazania informacji o dostępnych formach dostawy dla produktu. Jeśli brak obiektu delivery_product oznacza że dostawa dostępna wszystkimi typami

object

O

 

baskets.related_products.delivery_related_products.delivery_type

Typ dostawy

string

O

 

baskets.related_products.delivery_related_products.if_delivery_available

Flaga informująca czy typ dostawy dostępna

boolean

O

 

related_products.delivery_related_products.if_delivery_free

Flaga informująca czy po dodaniu produktu sugerowanego do koszyka, klient będzie miał darmową dostawę. W przypadku, gdy if_delivery_free=true jest na danym produkcie sugerowanym, klientowi zostanie zaprezentowany odpowiedni komunikat na tym produkcie.

boolean

O

 

baskets.consents 

Obiekt służący do przekazania listy zgód dla danego koszy 

array 

  Y

 

baskets.consents.consent_id 

Id zgody nadawane przez merchanta 

string 

  Y

"consent_id":3 

baskets.consents.consent_link 

Link przekierowujący do pełnej treści zgodny np. do strony merchnata 

string 

  Y

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

consents.label_link

Label do linku przekazanego w label_link

string

O

"label_link": "Regulaminu",

consents.additional_consent_links

Obiekt służący do przekazania dodatkowego linku do zgody/regulaminu

object

O

 

consents.additional_consent_links.id

Id zgody nadawane przez merchanta

string

O

"id": "0"

consents.additional_consent_links.consent_link

Link przekierowujący do pełnej treści zgodny np. do strony merchanta

string

O

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

consents.additional_consent_links.label_link

Label do linku przekazanego w label_link

string

O

"label_link": "Polityką prywatności"

baskets.consents.consent_description 

Opis zgody, nie więcej niż 500 znaków 

string 

  Y

"consent_description":"zwroty i reklamacje" 

baskets.consents.consent_version 

Wersja zgody 

string 

  Y

"consent_version":1

baskets.consents.requirement_type 

Typ zgody. Dostępne wartości: Enum: [OPTIONAL, REQUIRED_ONCE, REQUIRED_ALWAYS ] 

OPTIONAL – Zgoda opcjonalna  

REQUIRED_ONCE - wymagana jednorazowo. Zgoda o takim typie i wersji będzie zapisana w profilu użytkownika, z informacją, że klient wyraził zgodę i w przypadku kolejnych koszyków będzie domyślnie zaznaczona. 

REQUIRED_ALWAYS - wymagana zawsze. Zgoda o takim typie i wersji nie jest zapisywana w profilu użytkownika. Klient za każdym razem musi wyrazić zgodę. 

string 

  Y

"requirement_type":"OPTIONAL"

GET /v1/izi/baskets

Przykładowy 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 }

Przykład implementacji w języku PHP

  • Podanie kodu -

W pliku implementacjaKlienta.txt została dodana tylko funkcja getBaskets.

/** * 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 ); } }
  • W SDK.zip zawiera się kod zawierający obiekt requestu oraz response endpointu.