Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
The article contains a description of the method used to update a basket together with an example implementation of the method in PHP.
On this page:
Table of Contents | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Description of the method
A method used to update a basket in the InPost Pay App. If a customer uses a trusted browser, and has a basket not associated with the InPost Pay app, the method also used to create and link the basket to InPost Pay.
Parameters
Field name | Description | Type | Requirement status | Additional remarks |
| Basket's unique ID assigned by the merchant | string | Y |
|
Request
Field name | Description | Type | Requirement status | Additional remarks |
| Unique ID of the trusted browser assigned by the Inpost app. A field only used when the customer uses a trusted browser, and doesn't have a basket linked. In this case, after selecting "Kup z Inpost Pay", the PUT method should be called with the browser_id parameter. | string | 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 | |
| Object intended to transfer the basket's price taken into account any promotion, but without any rebate code and 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 the basket from which the client selects the 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 merchnat'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 |
|
| Object intended to transfer information related to delivery methods preferred for the given basket | array | Y | |
| Delivery method.. Enum:[APM, COURIER]. APM – parcel locker device, COURIER – Inpost courier | string | Y |
|
| Suggested delivery date | string($date-time) | Y |
|
| Object intended to transfer additional description of the delivery. Currently two additional delivery options available: PWW – parcel on weekend COD – payment at delivery. When for a given basket the payment_type is CASH_ON_DELIVERY, it is required to enter COD as the additional delivery option
| array | 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 app's next 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 |
Formats preferable: png, jpg (recommendation: png without background) |
| 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] If the quantity_type of the product is INTEGER, then the Merchant provides the price for 1 piece. If the quantity_type of the product is DECIMAL, then the Merchant provides the price for the product quantity selected. · Example 1) We have 5 pcs of shirts 10 PLN a piece. In such a case, the quantity_type, is INTEGER and the product's price is PLN 10. · Example 2) We have 0.35 kg of flour, costing PLN 5. In such a case, the quantity_type, is DECIMAL and the product's price is PLN 5. | 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 |
|
| Object intended to determine the product's attributes | array | O | |
| Attribute name | string | Y |
|
| Attribute value | string | Y | |
| An object used to provide information about available delivery methods for a product. If there is no | array | O |
|
| Delivery type | string | O |
|
| A flag indicating whether the delivery type is available. | boolean | 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 |
|
| Link to a photograph of the product. Formats preferable: png, jpg (recommendation: png without background) | string | O |
Formats preferable: png, jpg (recommendation: png without background) |
| 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 | |
| An 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 | array | 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 | boolean | O | |
| Object intended to transfer the list of consents for a given basket | array | Y | |
| Consent IDs assigned by the merchant | string | Y |
|
| The link which redirects to the full content of a consent eg. to the merchant's website | string | Y |
|
| Label to the link passed in | string | O |
|
| An object used to provide an additional link to the consent | object | O |
|
| Consent IDs assigned by the merchant | string | O |
|
| The link which redirects to the full content of a consent eg. to the merchant's website | string | O |
|
| Label to the link passed in | string | O |
|
| 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 |
|
| Object used to pass the customer's shopping cart cookie in order to enable redirection from the application to the shopping cart in the merchant's store. | object | O |
|
| Url of the merchant shop | string | Y |
|
| Object used to pass the cookie | array | Y |
|
| The cookie domain represented by pair key-value | string | Y |
|
| Cookie key | string | Y |
|
| Cookie value | string | Y |
|
| Cookie path | string | Y |
|
| Cookie expiration time or maxAge | string($date-time) | O |
|
| Cookie security information | boolean | O |
|
| Cookie http information | boolean | O |
|
| Cookie sameSite information [ STRICT, LAX, NONE ] | string | O |
|
| Cookie priority [ LOW, MEDIUM, HIGH ] | string | O |
|
| Cookie max age | integer($int32) | O |
|
Response
Field name | Description | Type | Requirement status | Additional remarks |
| The identifier of the basket assigned by the Inpost Pay app The data piece not to be used by the merchant. ID additionally used by the widget in order to make it possible to correctly redirect from the widget level to the Inpost Pay app | string | Y |
|
Status | ||||
---|---|---|---|---|
|
/v1/izi/basket/{basket_id}
Example request
Code Block | ||
---|---|---|
| ||
{ "browser_id": "xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx", "summary": { "basket_base_price": { "net": "80.49", "gross": "99.00", "vat": "18.51" }, "basket_final_price": { "net": "80.49", "gross": "99.00", "vat": "18.51" }, "basket_promo_price": { "net": "80.49", "gross": "99.00", "vat": "18.51" }, "currency": "PLN", "basket_expiration_date": "2023-08-24T07:58:30.062Z", "basket_additional_information": "string", "payment_type": ["CARD","CARD_TOKEN","APPLE_PAY","BLIK_CODE","BLIK_TOKEN","PAY_BY_LINK","SHOPPING_LIMIT","DEFERRED_PAYMENT","GOOGLE_PAY","CASH_ON_DELIVERY"], "basket_notice": null }, "delivery": [ { "delivery_type": "APM", "delivery_date": "2023-08-24T07:58:30.062Z", "delivery_options": [], "delivery_price": { "net": "0.00", "gross": "0.00", "vat": "0.00" } } ], "promo_codes": [], "products": [ { "product_id": "585", "product_category": "20", "ean": "0", "product_name": "Drewniane bule", "product_description": " \r\n\r\nCo to są bule? Na mieście mówią, że „bule to kule na nudy bóle". To gra, w której zasady są proste, a emocje sięgają 10 piętra. Bule to kule. W tym przypadku -- drewniane, z twardego drewna bukowego. Jedna z nich to świnka zwana prosiaczkiem. Taka kruszynka-wieprzowinka.\r\n\r\nCo trzeba mieć, żeby zagrać w bule? Przynajmniej jednego przyjaciela. Albo przyjaciółkę. Albo sąsiada, wujka, kuzynkę, znajomego, brata, siostrę, kolegę. Trzeba też mieć kawałek trawnika, może być bez trawy. Bule to rzucanie kulami w świnkę. Kto rzuci najbliżej, ten wygrywa. Gra w bule jest prosta, choć kule są okrągłe. Dziwne, co nie?", "product_link": "https://outofthebox.pl/product/drewniane-bule/", "product_image": "https://outofthebox.pl/app/uploads/2022/10/INPOST_aranzacje3-1.jpg", "base_price": { "net": 80.49, "gross": 99.00, "vat": 18.51 }, "quantity": { "quantity": 1, "quantity_type": "INTEGER", "quantity_unit": "pcs", "available_quantity": 275, "max_quantity": 275 }, "product_attributes": [], "variants": [] } ], "related_products": [ { "product_id": "567", "product_category": "20", "ean": "0", "product_name": "Mata do ćwiczeń", "product_description": " \r\n\r\nNie wiemy, ile korków wystrzelonych w Sylwestra potrzeba do stworzenia korkowej maty do jogi. Ale wiemy, że dzięki niej możesz zacząć całkiem nowy czas w swoim życiu.\r\n\r\nĆwiczenia na niej to prawdziwy body & soul balance.\r\n\r\nZatem rusz swe "body" po naturalny zastrzyk energii i zadbaj o relaks swojej "soul". Warto wiedzieć, że mata korkowa z naturalnego kauczuku ma najlepsze właściwości antypoślizgowe.", "product_link": "https://outofthebox.pl/product/mata-do-cwiczen/", "product_image": "https://outofthebox.pl/app/uploads/2022/10/INPOST_aranzacje25.jpg", "base_price": { "net": 202.44, "gross": 249.00, "vat": 0.00 }, "quantity": { "quantity": 1, "quantity_type": "INTEGER", "quantity_unit": "pcs", "available_quantity": 197485, "max_quantity": 197485 }, "product_attributes": [ { "attribute_name": "Wymiary/Pojemność", "attribute_value": "183x61 cm, 4 mm grubości" }, { "attribute_name": "Materiał", "attribute_value": "Korek i naturalny kauczuk" }, { "attribute_name": "Waga", "attribute_value": "2.6 kg" } ], "variants": [] }, { "product_id": "554", "product_category": "20", "ean": "0", "product_name": "Paryżanka", "product_description": " \r\n\r\nCzy wiesz, co tak naprawdę widzą ludzie, kiedy idziesz sobie z paryżanką?\r\n\r\nWidzą, że jesteś EKO. Nie używasz foliowych woreczków jednorazowego użytku.\r\n\r\nWidzą, że jesteś modna. W końcu Paryż to miejsce, w którym od dawna decyduje się o tym, co warto ze sobą nosić.\r\n\r\nParyżanka nie kryje się z tym, że wygląda rewelacyjnie, kiedy jest wypełniona świeżymi owocami.\r\n\r\nWidzą też, że lubisz naturalne materiały, bo paryżanka wykonana jest w 100 procentach z bawełny.\r\n\r\nI że w swoim życiu działasz zgodnie z zasadą out of the box.\r\nPo swojemu. Jak InPost.", "product_link": "https://outofthebox.pl/product/paryzanka/", "product_image": "https://outofthebox.pl/app/uploads/2022/10/INPOST_aranzacje11-1.jpg", "base_price": { "net": 23.58, "gross": 29.00, "vat": 0.00 }, "quantity": { "quantity": 1, "quantity_type": "INTEGER", "quantity_unit": "pcs", "available_quantity": 468, "max_quantity": 468 }, "product_attributes": [], "variants": [] } ], "consents": [ { "consent_id": "3", "consent_link": "https://outofthebox.pl/zwroty-i-reklamacje/", "consent_description": "zwroty i reklamacje", "consent_version": "1", "requirement_type": "OPTIONAL" } ] } |
Response
Code Block | ||
---|---|---|
| ||
"inpost_basket_id": "866e5bf6-4e8a-443e-98f5-f9b0c5c149dd" |
Example implementation in PHP
Entering the code -
View file name implementacjaKlienta.txt
Info |
---|
In the implementacjaKlienta.txt file, only the putBasket function was added. |
Code Block | ||
---|---|---|
| ||
/** * 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 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.
View file | ||
---|---|---|
|