InPost Pay (Basket_App)

InPost Pay (Basket App) - this is a module which provides access to the API, which makes it possible to exchange information regarding the basket and the processing of the orders. This section contains any information regarding the API methods made available by InPost used to communicate between the Merchant and InPost Pay.

InPost Pay API

Production environment

 address: https://api.inpost.pl

Sandbox environment

Test environment address: https://sandbox-api.inpost.pl

List of endpoints

The table below presents a list of endpoints issued by the InPost Pay app, used for communicating between the Merchant and the InPost Pay app.

 

Widget 2.0 - the column contains a list of methods required to implement Widget 2.0 (Widget 2.0 [ENG])

Widget 1.0 - the column contains a list of methods required to implement Widget 1.0 (Widget 1.0 (old version) [ENG]), which is replaced by Widget 2.0. Recommended implementation is Widget 2.0 (Widget 2.0 [ENG]).

 

Method

Description

Widget 2.0

Widget 1.0

Browser

DELETE /v1/izi/browser/{browser_id}/binding

The method removes the browser assigned or removes a phone number from the browser assigned.

Basket

PUT /v1/izi/basket/{basket_id}

The method updates or creates a basket, e.g. changes the number of products, delivery type itp

PUT /v2/izi/basket/{basket_id}

This method updates a basket e.g. change products quantity, delivery type etc.

DELETE /v1/izi/basket/{basket_id}/binding

Desynchronizing the basket and the phone number

POST /v1/izi/basket/{basket_id}/binding

The method links a basket with the InPost app

PUT /v2/izi/basket/{basket_id}/binding

Basket binding initialization. Returns a basket's binding API key to be set in widget options.

GET /v1/izi/basket/{basket_id}/binding

The method verifies whether or not a basket is connected to the InPost app

GET /v1/izi/baskets

Optional back office endpoint, returns the list of baskets for the Merchant

Order

POST /v1/izi/order/{order_id}/event

Order update

GET /v1/izi/orders

Optional back office endpoint, returns the list of orders for the Merchant

Payment

GET /v1/izi/payment-methods

Returns available payment types for merchant

Signature verification

GET /v1/izi/signing-keys/public

Returns public signature keys

GET /v1/izi/signing-keys/public/{version}

Returns public signature keys for the version

 

Example implementation in PHP

  • We create an interface for the website of a customer, which will be responsible for Merchant-> InPost- InPost Pay (Basket App) communication.

    <?php declare(strict_types=1); namespace Iteo\InpostPayClient\Client; use Iteo\InpostPayClient\SDK\Basket\BasketApp\Basket; use Iteo\InpostPayClient\SDK\Basket\Binding\BindingBasket; use Iteo\InpostPayClient\SDK\Basket\Binding\QrCode\QrCodeData; use Iteo\InpostPayClient\SDK\Basket\Binding\Request\BasketApp\BasketBindingRequest; use Iteo\InpostPayClient\SDK\Basket\Response\BasketsResponse; use Iteo\InpostPayClient\SDK\Basket\Response\InpostBasketId; use Iteo\InpostPayClient\SDK\Core\Exceptions\InpostPayEndpointException; use Iteo\InpostPayClient\SDK\Core\Exceptions\InpostPayPostBasketBindingException; use Iteo\InpostPayClient\SDK\Core\Exceptions\InpostPayPostOrderEventException; use Iteo\InpostPayClient\SDK\Order\Request\BasketApp\OrderEventRequest; use Iteo\InpostPayClient\SDK\Order\Response\BasketApp\OrdersResponse; use Iteo\InpostPayClient\SDK\SignatureVerification\SigningKeys\SigningKeysResponse; use Iteo\InpostPayClient\SDK\SignatureVerification\SigningVersionKey\SigningKeyResponse; /** * Client interface used for communication between Merchant and InPost Pay application. */ interface InpostPayClientInterface { /** * This method verify if basket is connected with InPost app. * * @param string $basketId ID basket assigned by merchant * @param string|null $browserId Browser ID from cookie * * @return BindingBasket Object with information about whether the browser is trusted * and whether the basket is linked * * @throws InpostPayEndpointException */ public function getBasketBinding(string $basketId, ?string $browserId): BindingBasket; /** * This method connect basket with InPost app. * * @param string $basketId ID basket assigned by merchant * @param BasketBindingRequest $requestBody Request data, needed for binding basket * * @return ?QrCodeData Object with data for QR Code when successful binding with QR Code or null * when successful binding with phone number * * @throws InpostPayPostBasketBindingException|InpostPayEndpointException */ public function postBasketBinding(string $basketId, BasketBindingRequest $requestBody): ?QrCodeData; /** * This method desynchronize basket with Inpost Pay mobile app. * * @param string $basketId ID basket assigned by merchant * @param ?bool $ifBasketRealized Information about the fact that the basket will be deleted because * it has been realized * * @throws InpostPayEndpointException */ public function deleteBasketBinding(string $basketId, ?bool $ifBasketRealized): void; /** * This method updates or creates a basket e.g. change products quantity, delivery type etc. * * @param string $basketId ID basket assigned by merchant * @param Basket $basket All Basket data * * @return InpostBasketId Object with basket ID created from Inpost mobile app * * @throws InpostPayEndpointException */ public function putBasket(string $basketId, Basket $basket): InpostBasketId; /** * This method update order. * * @param string $orderId ID order assigned by merchant * @param OrderEventRequest $orderEventRequest Information about order event, that will change order status * * @throws InpostPayPostOrderEventException|InpostPayEndpointException */ public function postOrderEvent(string $orderId, OrderEventRequest $orderEventRequest): void; /** * This method deletes binded browser from Inpost Pay mobile app. * * @param string $browserId ID browser from cookie * * @throws InpostPayEndpointException */ public function deleteBrowserBinding(string $browserId): void; /** * This method get baskets list for merchant. * * @param ?int $pageIndex Information about page index of merchant baskets list * @param ?int $pageSize Information about page size of merchant baskets list page * * @return BasketsResponse Object containing list of baskets for merchant for strict page index * * @throws InpostPayEndpointException */ public function getBaskets(?int $pageIndex, ?int $pageSize): BasketsResponse; /** * This method get orders list for merchant. * * @param ?int $pageIndex Information about page index of merchant orders list * @param ?int $pageSize Information about page size of merchant orders list page * * @return OrdersResponse Object containing list of orders for merchant for strict page index * * @throws InpostPayEndpointException */ public function getOrders(?int $pageIndex, ?int $pageSize): OrdersResponse; /** * This method get public signing keys. * * @return SigningKeysResponse Object containing list of public signing keys * * @throws InpostPayEndpointException */ public function getSigningKeys(): SigningKeysResponse; /** * This method get public signing key for version. * * @param string $version Version of signing-key * * @return SigningKeyResponse Object containing public signing key * * @throws InpostPayEndpointException */ public function getSigningKey(string $version): SigningKeyResponse; }

  • We create an url interface for the creator, which will be responsible for obtaining the right url address to InPostPay's API.

    <?php declare(strict_types=1); namespace Iteo\InpostPayClient\Client; /** * Interface used for creating url for communication with Inpost Pay. */ interface InpostPayURLCreatorInterface { /** * Method that return url for Inpost Pay. * * @return InpostPayURL url for Inpost Pay */ public function create(): InpostPayURL; }

  • We create an implementation of the creator's url service for the Sandbox environment.

    <?php declare(strict_types=1); namespace Iteo\InpostPayClient\Client; /** * PHP URL Creator Service implementation used for creating url to Sandbox InpostPay. */ final class SandboxInPostPayURLCreator implements InpostPayURLCreatorInterface { /** * {@inheritdoc} */ public function create(): InpostPayURL { return new InpostPayURL('https://sandbox-api.inpost.pl/v1/izi/'); } }

  • We create an implementation of the creator's url service for the Production environment.

  • We create an implementation of the customer's website, by using a PSR client for REST communication, and the creator's url interface implemented in advance, in order to obtain the url to InpostPay's API, and the interface of the bearer's service in order to obtain an access token. For the Client to be fully functional, it is necessary to implement the functions described in the interface, responsible for the particular endpoints in the List of Endpoints.

 

 

Related pages