Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
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.
On this page:
Table of Contents | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
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 1.0 - the column contains a list of methods required to implement Widget 1.0 (Widget - frontend [ENG] ), which is replaced by Widget 2.0. Recommended implementation is Widget 2.0.
Method | Description | Widget 2.0 | Widget 1.0 | |
Browser | The method removes the browser assigned or removes a phone number from the browser assigned. | ❌ | ✔️ | |
Basket | The method updates or creates a basket, e.g. changes the number of products, delivery type itp | ❌ | ✔️ | |
This method updates a basket e.g. change products quantity, delivery type etc. | ✔️ | ❌ | ||
Desynchronizing the basket and the phone number | ❌ ✔️ | ✔️ | ||
The method links a basket with the InPost app | ❌ | ✔️ | ||
Basket binding initialization. Returns a basket's binding API key to be set in widget options. | ✔️ | ❌ | ||
The method verifies whether or not a basket is connected to the InPost app | ✔️ | ✔️ | ||
Optional back office endpoint, returns the list of baskets for the Merchant | ✔️ | ✔️ | ||
Order | Order update | ✔️ | ✔️ | |
Optional back office endpoint, returns the list of orders for the Merchant | ✔️ | ✔️ | ||
Payment | Returns available payment types for merchant | ✔️ | ✔️ | |
Signature verification | Returns public signature keys | ✔️ | ✔️ | |
Returns public signature keys for the version | ✔️ | ✔️ |
Confluence open api |
---|
--- openapi: 3.0.3 info: title: Swagger description: 'Basket APP API for Merchant' version: 4.2.0 tags: - name: Browser description: Provides access to binding browsers. - name: Basket description: Provides access to managing baskets. - name: Order description: Provides access to managing orders. - name: Payment description: Payment - name: Signature verification description: Signature verification paths: /v2/izi/basket/{basket_id}/binding: put: tags: - Basket summary: Basket binding initialization. description: Basket binding initialization. Returns a basket's binding API key to be set in widget options.API generation is idempotent and consistent for given basket_id and merchant_id it'll return the same API key. operationId: bindingBasket parameters: - name: basket_id in: path description: ID basket assigned by merchant to update required: true style: simple explode: false schema: type: string responses: "200": description: Create or update basket response content: application/json: schema: $ref: '#/components/schemas/response_binding_basket' "401": content: application/json: example: error_code: UNAUTHORIZED error_message: Given user is not authorized to access the resource. schema: $ref: '#/components/schemas/error' description: Unauthorized. "403": content: application/json: example: error_code: FORBIDDEN error_message: Access to given resource is forbidden for current user. schema: $ref: '#/components/schemas/error' description: Forbidden. "500": description: Internal server error content: application/json: schema: $ref: '#/components/schemas/error' examples: internalServerError: $ref: '#/components/examples/internalServerError' "400": description: Bad request. content: application/json: schema: $ref: '#/components/schemas/error' examples: argumentNotValidError: $ref: '#/components/examples/argumentNotValidError' malformedRequest: $ref: '#/components/examples/malformedRequest' "404": description: Resource not found. content: application/json: schema: $ref: '#/components/schemas/error' examples: basketNotFound: $ref: '#/components/examples/basketNotFound' "409": description: Conflict. Request cannot be handled with the current state of the target resource. content: application/json: schema: $ref: '#/components/schemas/error' examples: merchantDisabledError: $ref: '#/components/examples/merchantDisabledError' /v2/izi/basket/{basket_id}: put: tags: - Basket summary: Create or update a basket. Consumer Basket App. description: This method updates or creates a basket e.g. change products quantity, delivery type etc. operationId: updateBasketv2 parameters: - name: basket_id in: path description: ID basket assigned by merchant to update required: true style: simple explode: false schema: type: string requestBody: content: application/json: schema: $ref: '#/components/schemas/basket_request_put_v2' required: true responses: "200": description: Create or update basket response content: application/json: schema: $ref: '#/components/schemas/response_put_basket' "401": content: application/json: example: error_code: UNAUTHORIZED error_message: Given user is not authorized to access the resource. schema: $ref: '#/components/schemas/error' description: Unauthorized. "403": content: application/json: example: error_code: FORBIDDEN error_message: Access to given resource is forbidden for current user. schema: $ref: '#/components/schemas/error' description: Forbidden. "500": description: Internal server error content: application/json: schema: $ref: '#/components/schemas/error' examples: internalServerError: $ref: '#/components/examples/internalServerError' "400": description: Bad request. content: application/json: schema: $ref: '#/components/schemas/error' examples: argumentNotValidError: $ref: '#/components/examples/argumentNotValidError' malformedRequest: $ref: '#/components/examples/malformedRequest' "404": description: Resource not found. content: application/json: schema: $ref: '#/components/schemas/error' examples: basketNotFound: $ref: '#/components/examples/basketNotFound' browserNotFound: $ref: '#/components/examples/browserNotFound' "409": description: Conflict. Request cannot be handled with the current state of the target resource. content: application/json: schema: $ref: '#/components/schemas/error' examples: merchantDisabledError: $ref: '#/components/examples/merchantDisabledError' basketExpired: $ref: '#/components/examples/basketExpired' /v1/izi/basket/{basket_id}: put: tags: - Basket summary: Create or update a basket. Consumer Basket App. description: This method updates or creates a basket e.g. change products quantity, delivery type etc. operationId: updateBasket parameters: - name: basket_id in: path description: ID basket assigned by merchant to update required: true style: simple explode: false schema: type: string requestBody: content: application/json: schema: $ref: '#/components/schemas/basket_request_put' required: true responses: "200": description: Create or update basket response content: application/json: schema: $ref: '#/components/schemas/response_put_basket' "401": content: application/json: example: error_code: UNAUTHORIZED error_message: Given user is not authorized to access the resource. schema: $ref: '#/components/schemas/error' description: Unauthorized. "403": content: application/json: example: error_code: FORBIDDEN error_message: Access to given resource is forbidden for current user. schema: $ref: '#/components/schemas/error' description: Forbidden. "500": description: Internal server error content: application/json: schema: $ref: '#/components/schemas/error' examples: internalServerError: $ref: '#/components/examples/internalServerError' "400": description: Bad request. content: application/json: schema: $ref: '#/components/schemas/error' examples: argumentNotValidError: $ref: '#/components/examples/argumentNotValidError' malformedRequest: $ref: '#/components/examples/malformedRequest' "404": description: Resource not found. content: application/json: schema: $ref: '#/components/schemas/error' examples: basketNotFound: $ref: '#/components/examples/basketNotFound' browserNotFound: $ref: '#/components/examples/browserNotFound' "409": description: Conflict. Request cannot be handled with the current state of the target resource. content: application/json: schema: $ref: '#/components/schemas/error' examples: merchantDisabledError: $ref: '#/components/examples/merchantDisabledError' basketExpired: $ref: '#/components/examples/basketExpired' /v1/izi/basket/{basket_id}/binding: delete: tags: - Basket summary: Desynchronisation of basket with telephone number description: Desynchronisation of basket with telephone number operationId: deleteBasketMerchant parameters: - name: basket_id in: path description: ID basket assigned by merchant to update required: true style: simple explode: false schema: type: string - name: if_basket_realized in: query description: If basket deleted because order completed at merchant required: false style: form explode: false schema: type: boolean responses: "204": description: basket deleted "401": content: application/json: example: error_code: UNAUTHORIZED error_message: Given user is not authorized to access the resource. schema: $ref: '#/components/schemas/error' description: Unauthorized. "403": content: application/json: example: error_code: FORBIDDEN error_message: Access to given resource is forbidden for current user. schema: $ref: '#/components/schemas/error' description: Forbidden. "404": description: Resource not found. content: application/json: schema: $ref: '#/components/schemas/error' examples: basketNotFound: $ref: '#/components/examples/basketNotFound' "500": description: Internal server error content: application/json: schema: $ref: '#/components/schemas/error' examples: internalServerError: $ref: '#/components/examples/internalServerError' "409": description: Conflict. Request cannot be handled with the current state of the target resource. content: application/json: schema: $ref: '#/components/schemas/error' examples: merchantDisabledError: $ref: '#/components/examples/merchantDisabledError' basketExpired: $ref: '#/components/examples/basketExpired' basketNotBoundError: $ref: '#/components/examples/basketNotBoundError' post: tags: - Basket summary: Binding basket and InPost app. description: This method connect basket with InPost app. operationId: createBasket parameters: - name: basket_id in: path description: ID basket assigned by merchant required: true style: simple explode: false schema: type: string requestBody: content: application/json: schema: $ref: '#/components/schemas/request_basket_binding' responses: "200": description: Basket response if binding_method = DEEP_LINK content: application/json: schema: $ref: '#/components/schemas/response_basket_binding' "202": description: Basket response if binding_method = PHONE "400": description: Bad request. content: application/json: schema: $ref: '#/components/schemas/error' examples: argumentNotValidError: $ref: '#/components/examples/argumentNotValidError' malformedRequest: $ref: '#/components/examples/malformedRequest' "401": content: application/json: example: error_code: UNAUTHORIZED error_message: Given user is not authorized to access the resource. schema: $ref: '#/components/schemas/error' description: Unauthorized. "403": content: application/json: example: error_code: FORBIDDEN error_message: Access to given resource is forbidden for current user. schema: $ref: '#/components/schemas/error' description: Forbidden. "500": description: Internal server error content: application/json: schema: $ref: '#/components/schemas/error' examples: internalServerError: $ref: '#/components/examples/internalServerError' "409": description: Conflict. Request cannot be handled with the current state of the target resource. content: application/json: schema: $ref: '#/components/schemas/error' examples: basketBoundError: $ref: '#/components/examples/basketBoundError' merchantDisabledError: $ref: '#/components/examples/merchantDisabledError' basketExpired: $ref: '#/components/examples/basketExpired' phoneBindingMethodUnavailableError: $ref: '#/components/examples/phoneBindingMethodUnavailableError' bindingRedundantPhoneError: $ref: '#/components/examples/bindingRedundantPhoneError' bindingPhoneRequiredError: $ref: '#/components/examples/bindingPhoneRequiredError' bindingBrowserRequiredError: $ref: '#/components/examples/bindingBrowserRequiredError' get: tags: - Basket summary: Information about basket bound with InPost Pay and trusted browser. description: This method verify if basket is connected with InPost app. operationId: verifyBasket parameters: - name: basket_id in: path description: ID basket assigned by merchant required: true style: simple explode: false schema: type: string - name: browser_id in: query description: ID basket to update required: false style: form explode: false schema: type: string responses: "200": description: Basket response content: application/json: schema: $ref: '#/components/schemas/response_basket_connected' "401": content: application/json: example: error_code: UNAUTHORIZED error_message: Given user is not authorized to access the resource. schema: $ref: '#/components/schemas/error' description: Unauthorized. "403": content: application/json: example: error_code: FORBIDDEN error_message: Access to given resource is forbidden for current user. schema: $ref: '#/components/schemas/error' description: Forbidden. "500": description: Internal server error content: application/json: schema: $ref: '#/components/schemas/error' examples: internalServerError: $ref: '#/components/examples/internalServerError' "409": description: Conflict. Request cannot be handled with the current state of the target resource. content: application/json: schema: $ref: '#/components/schemas/error' examples: merchantDisabledError: $ref: '#/components/examples/merchantDisabledError' basketExpired: $ref: '#/components/examples/basketExpired' /v1/izi/baskets: get: tags: - Basket summary: Returns baskets list for merchnat description: Returns baskets list for merchnat operationId: basketsList parameters: - name: page_index in: query required: false style: form explode: true schema: type: string - name: page_size in: query required: false style: form explode: true schema: type: string responses: "200": description: Basket details content: application/json: schema: $ref: '#/components/schemas/merchant_baskets' "401": content: application/json: example: error_code: UNAUTHORIZED error_message: Given user is not authorized to access the resource. schema: $ref: '#/components/schemas/error' description: Unauthorized. "403": content: application/json: example: error_code: FORBIDDEN error_message: Access to given resource is forbidden for current user. schema: $ref: '#/components/schemas/error' description: Forbidden. "500": description: Internal server error content: application/json: schema: $ref: '#/components/schemas/error' examples: internalServerError: $ref: '#/components/examples/internalServerError' "409": description: Conflict. Request cannot be handled with the current state of the target resource. content: application/json: schema: $ref: '#/components/schemas/error' examples: merchantDisabledError: $ref: '#/components/examples/merchantDisabledError' /v1/izi/browser/{browser_id}/binding: delete: tags: - Browser summary: Deletes a binded browser. description: Method deletes binded browser or removes phone from binded browser. operationId: deleteBrowserMerchant parameters: - name: browser_id in: path description: ID of browser required: true style: simple explode: false schema: type: string responses: "204": description: browser deleted "401": content: application/json: example: error_code: UNAUTHORIZED error_message: Given user is not authorized to access the resource. schema: $ref: '#/components/schemas/error' description: Unauthorized. "403": content: application/json: example: error_code: FORBIDDEN error_message: Access to given resource is forbidden for current user. schema: $ref: '#/components/schemas/error' description: Forbidden. "404": description: Resource not found. content: application/json: schema: $ref: '#/components/schemas/error' examples: browserNotFound: $ref: '#/components/examples/browserNotFound' "500": description: Internal server error content: application/json: schema: $ref: '#/components/schemas/error' examples: internalServerError: $ref: '#/components/examples/internalServerError' "409": description: Conflict. Request cannot be handled with the current state of the target resource. content: application/json: schema: $ref: '#/components/schemas/error' examples: merchantDisabledError: $ref: '#/components/examples/merchantDisabledError' /v1/izi/order/{order_id}/event: post: tags: - Order summary: Update order operationId: updateOrderMerchant parameters: - name: order_id in: path description: ID order assigned by merchant to update required: true style: simple explode: false schema: type: string requestBody: content: application/json: schema: $ref: '#/components/schemas/request_order_event_merchant' required: true responses: "200": description: Order update default: description: unexpected error content: application/json: schema: $ref: '#/components/schemas/error' "400": description: Bad request. content: application/json: schema: $ref: '#/components/schemas/error' examples: argumentNotValidError: $ref: '#/components/examples/argumentNotValidError' malformedRequest: $ref: '#/components/examples/malformedRequest' "404": description: Resource not found. content: application/json: schema: $ref: '#/components/schemas/error' examples: orderNotFound: $ref: '#/components/examples/orderNotFound' "409": description: Conflict. Request cannot be handled with the current state of the target resource. content: application/json: schema: $ref: '#/components/schemas/error' examples: merchantDisabledError: $ref: '#/components/examples/merchantDisabledError' orderStatusError: $ref: '#/components/examples/orderStatusError' "401": content: application/json: example: error_code: UNAUTHORIZED error_message: Given user is not authorized to access the resource. schema: $ref: '#/components/schemas/error' description: Unauthorized. "403": content: application/json: example: error_code: FORBIDDEN error_message: Access to given resource is forbidden for current user. schema: $ref: '#/components/schemas/error' description: Forbidden. /v1/izi/orders: get: tags: - Order summary: Returns orders list for merchant description: Returns orders list for merchant operationId: ordersList parameters: - name: page_index in: query required: false style: form explode: true schema: type: string - name: page_size in: query required: false style: form explode: true schema: type: string - name: order_id in: query description: order ID required: false style: form explode: false schema: type: string responses: "200": description: Get list of orders content: application/json: schema: $ref: '#/components/schemas/orders_list' "401": content: application/json: example: error_code: UNAUTHORIZED error_message: Given user is not authorized to access the resource. schema: $ref: '#/components/schemas/error' description: Unauthorized. "403": content: application/json: example: error_code: FORBIDDEN error_message: Access to given resource is forbidden for current user. schema: $ref: '#/components/schemas/error' description: Forbidden. "500": description: Internal server error content: application/json: schema: $ref: '#/components/schemas/error' examples: internalServerError: $ref: '#/components/examples/internalServerError' "409": description: Conflict. Request cannot be handled with the current state of the target resource. content: application/json: schema: $ref: '#/components/schemas/error' examples: merchantDisabledError: $ref: '#/components/examples/merchantDisabledError' /v1/izi/signing-keys/public: get: tags: - Signature verification summary: Returns public signing keys description: Returns public signing keys operationId: signingKeys responses: "200": description: Get list of orders content: application/json: schema: $ref: '#/components/schemas/response_signing_keys' "401": content: application/json: example: error_code: UNAUTHORIZED error_message: Given user is not authorized to access the resource. schema: $ref: '#/components/schemas/error' description: Unauthorized. "403": content: application/json: example: error_code: FORBIDDEN error_message: Access to given resource is forbidden for current user. schema: $ref: '#/components/schemas/error' description: Forbidden. "500": description: Internal server error content: application/json: schema: $ref: '#/components/schemas/error' examples: internalServerError: $ref: '#/components/examples/internalServerError' "409": description: Conflict. Request cannot be handled with the current state of the target resource. content: application/json: schema: $ref: '#/components/schemas/error' examples: merchantDisabledError: $ref: '#/components/examples/merchantDisabledError' /v1/izi/signing-keys/public/{version}: get: tags: - Signature verification summary: Returns public signing key for version description: Returns public signing key for version operationId: versionSigningKeys parameters: - name: version in: path description: version required: true style: simple explode: false schema: type: string responses: "200": description: Get list of orders content: application/json: schema: $ref: '#/components/schemas/response_version_signing_keys' "409": description: Conflict. Request cannot be handled with the current state of the target resource. content: application/json: schema: $ref: '#/components/schemas/error' examples: merchantDisabledError: $ref: '#/components/examples/merchantDisabledError' "404": description: Resource not found. content: application/json: schema: $ref: '#/components/schemas/error' examples: publicKeyNotFound: $ref: '#/components/examples/publicKeyNotFound' "401": content: application/json: example: error_code: UNAUTHORIZED error_message: Given user is not authorized to access the resource. schema: $ref: '#/components/schemas/error' description: Unauthorized. "403": content: application/json: example: error_code: FORBIDDEN error_message: Access to given resource is forbidden for current user. schema: $ref: '#/components/schemas/error' description: Forbidden. "500": description: Internal server error content: application/json: schema: $ref: '#/components/schemas/error' examples: internalServerError: $ref: '#/components/examples/internalServerError' /v1/izi/payment-methods: get: tags: - Payment summary: Returns returns available payment types for merchant description: Returns returns available payment types for merchant operationId: paymentsTypes responses: "200": description: Get list of orders content: application/json: schema: $ref: '#/components/schemas/responseGetPayments' "401": content: application/json: example: error_code: UNAUTHORIZED error_message: Given user is not authorized to access the resource. schema: $ref: '#/components/schemas/error' description: Unauthorized. "403": content: application/json: example: error_code: FORBIDDEN error_message: Access to given resource is forbidden for current user. schema: $ref: '#/components/schemas/error' description: Forbidden. "500": description: Internal server error content: application/json: schema: $ref: '#/components/schemas/error' examples: internalServerError: $ref: '#/components/examples/internalServerError' "409": description: Conflict. Request cannot be handled with the current state of the target resource. content: application/json: schema: $ref: '#/components/schemas/error' examples: merchantDisabledError: $ref: '#/components/examples/merchantDisabledError' components: examples: merchantDisabledError: value: error_code: MERCHANT_DISABLE error_message: 'Merchant with given id is DISABLED' summary: MERCHANT_DISABLE description: Service is temporarily disabled, because of to many incorrect requests or manual blockade basketBoundError: value: error_code: BASKET_IS_BINDED error_message: 'Basket already bound' summary: BASKET_IS_BINDED description: Basket already bound. basketExpired: value: error_code: BASKET_EXPIRED error_message: 'Basket expired' summary: BASKET_EXPIRED description: Basket expired and will be removed soon. basketNotBoundError: value: error_code: BASKET_NOT_BOUND error_message: 'Basket not bound' summary: BASKET_NOT_BOUND description: Basket not bound. bindingRedundantPhoneError: value: error_code: ERROR_VALIDATION_PHONE_NUMBER error_message: 'Phone number required for PHONE binding method only' summary: ERROR_VALIDATION_PHONE_NUMBER description: Phone number should not be passed for binding methods other than PHONE. bindingPhoneRequiredError: value: error_code: ERROR_VALIDATION_PHONE_NUMBER_REQUIRED error_message: 'Phone number is required' summary: ERROR_VALIDATION_PHONE_NUMBER_REQUIRED description: Phone number is required for PHONE method binding. bindingBrowserRequiredError: value: error_code: ERROR_VALIDATION_BROWSER_REQUIRED error_message: 'Browser is required for PHONE binding method' summary: ERROR_VALIDATION_BROWSER_REQUIRED description: Browser details are required for PHONE binding method phoneBindingMethodUnavailableError: value: error_code: PHONE_BINDING_METHOD_UNAVAILABLE error_message: 'Unavailable' summary: PHONE_BINDING_METHOD_UNAVAILABLE description: Phone binding method temporarily unavailable for requested number. orderStatusError: value: error_code: STATUS_ORDER_ERROR error_message: 'Unavailable' summary: STATUS_ORDER_ERROR description: Can't be changed ORDER_COMPLETED publicKeyNotFound: value: error_code: PUBLIC_KEY_NOT_FOUND error_message: 'Public key version {} not found' summary: PUBLIC_KEY_NOT_FOUND description: public key not found argumentNotValidError: value: error_code: BAD_REQUEST error_message: Invalid request. summary: BAD_REQUEST description: Request validation error. Error message might optionally contain information about constraint violations. malformedRequest: value: error_code: MALFORMED_REQUEST error_message: Request not readable. summary: MALFORMED_REQUEST description: The server was not able to read the request. notFound: value: error_code: NOT_FOUND error_message: Resource not found. summary: NOT_FOUND description: The server was not able to read the request. basketNotFound: value: error_code: BASKET_NOT_FOUND error_message: Basket not found. summary: BASKET_NOT_FOUND description: Basket not found. orderNotFound: value: error_code: ORDER_NOT_FOUND error_message: Order not found. summary: ORDER_NOT_FOUND description: Order not found. browserNotFound: value: error_code: BROWSER_NOT_FOUND error_message: Browser not found summary: BROWSER_NOT_FOUND description: Browser not found . internalServerError: value: error_code: INTERNAL_SERVER_ERROR error_message: Something went wrong. Please try again later. summary: INTERNAL_SERVER_ERROR description: The server encountered unexpected error. schemas: error: required: - errorCode type: object properties: error_code: type: string description: Code that indicates the nature of an error. error_message: type: string description: Additional information which may be useful. merchant_baskets: type: object properties: page_size: type: integer description: page size total_items: type: integer description: total items page_index: type: integer description: page index baskets: type: array description: baskets list items: $ref: '#/components/schemas/merchant_basket_details' request_order_event_merchant: type: object required: - event_id - event_data_time - event_data properties: event_id: type: string description: event id event_data_time: type: string description: event date time phone_number: $ref: '#/components/schemas/phone_number' event_data: $ref: '#/components/schemas/event_data_merchant' basket_request_put: type: object required: - summary - delivery - products - consents properties: browser_id: type: string description: browser id summary: $ref: '#/components/schemas/basket_summary' delivery: type: array description: delivery list items: $ref: '#/components/schemas/delivery_basket_response' promo_codes: type: array description: promo codes items: $ref: '#/components/schemas/promo_codes' promotions_available: type: array items: $ref: '#/components/schemas/promotion' products: type: array description: products order list items: $ref: '#/components/schemas/get_products' related_products: type: array description: related product information items: $ref: '#/components/schemas/get_related_products' consents: type: array description: consents list items: $ref: '#/components/schemas/consents' merchant_store: type: object required: - url - cookies properties: url: type: string description: Url of the merchant shop or direct address to cart example: "https://uat.outofthebox.pl/cart/" cookies: type: array items: $ref: '#/components/schemas/cookies' get_products: type: object required: - product_id - product_name - base_price - quantity properties: product_id: type: string description: product id product_category: type: string description: product category ean: type: string description: ean code product_name: type: string description: product name product_description: type: string description: product description product_link: type: string description: product link product_image: type: string description: product image additional_product_images: type: array description: additional product images. Object available in next version app items: $ref: '#/components/schemas/product_images' base_price: $ref: '#/components/schemas/base_price' promo_price: $ref: '#/components/schemas/base_price' lowest_price: $ref: '#/components/schemas/base_price' quantity: $ref: '#/components/schemas/quantity' product_attributes: type: array description: product attributes items: $ref: '#/components/schemas/product_attributes' delivery_product: type: array description: additional delivery information for product - object for use in next version app items: $ref: '#/components/schemas/delivery_product' get_related_products: type: object required: - product_id - product_name - base_price - quantity properties: product_id: type: string description: product id product_category: type: string description: product category ean: type: string description: ean code product_name: type: string description: product name product_description: type: string description: product description product_link: type: string description: product link product_image: type: string description: product image additional_product_images: type: array description: additional product images. Object available in next version app items: $ref: '#/components/schemas/product_images' base_price: $ref: '#/components/schemas/base_price' promo_price: $ref: '#/components/schemas/base_price' lowest_price: $ref: '#/components/schemas/base_price' quantity: $ref: '#/components/schemas/quantity' product_attributes: type: array description: product attributes items: $ref: '#/components/schemas/product_attributes' delivery_related_products: type: array description: additional delivery information for product - object for use in next version app items: $ref: '#/components/schemas/delivery_related_products' get_products_order: type: object required: - product_id - product_name - base_price - quantity properties: product_id: type: string description: product id product_category: type: string description: product category ean: type: string description: ean code product_name: type: string description: product name product_description: type: string description: product description product_link: type: string description: product link product_image: type: string description: product image additional_product_images: type: array description: additional product images. Object available in next version app items: $ref: '#/components/schemas/product_images' base_price: $ref: '#/components/schemas/base_price' lowest_price: $ref: '#/components/schemas/base_price' quantity: $ref: '#/components/schemas/quantity_order' product_attributes: type: array description: product attributes items: $ref: '#/components/schemas/product_attributes' consents: type: object description: Consents list required: - consent_id - consent_description - consent_version - requirement_type - consent_link properties: consent_id: type: string description: consent id consent_link: type: string description: consent link label_link: type: string description: label link presented in app additional_consent_links: type: array description: Object to additional links on consents. Available in next version of app items: $ref: '#/components/schemas/additional_consent_links' consent_description: type: string description: consent description consent_version: type: string description: consent version requirement_type: type: string enum: - OPTIONAL - REQUIRED_ONCE - REQUIRED_ALWAYS description: information on requirement consent additional_consent_links: type: object properties: consent_id: type: string description: consent id consent_link: type: string description: consent link label_link: type: string description: label link presented in app delivery: type: object description: delivery information required: - delivery_type - delivery_price - delivery_date properties: delivery_type: type: string enum: - APM - COURIER description: delivery type (APM; COURIER) delivery_date: description: delivery date type: string format: date-time delivery_options: type: array description: delivery options items: $ref: '#/components/schemas/delivery_options' mail: type: string description: email phone_number: $ref: '#/components/schemas/phone_number' delivery_point: type: string description: APM delivery point delivery_address: $ref: '#/components/schemas/delivery_address' delivery_price: $ref: '#/components/schemas/base_price' courier_note: type: string description: additional information for courier delivery_address: type: object description: delivery address required: - name - country_code - address - city - postal_code properties: name: type: string description: name country_code: type: string description: country code address: type: string description: address city: type: string description: city postal_code: type: string description: postal code client_address: type: object description: delivery address required: - country_code - address - city - postal_code properties: country_code: type: string description: country code address: type: string description: address city: type: string description: city postal_code: type: string description: postal code delivery_basket_response: type: object required: - delivery_type - delivery_date - delivery_price properties: delivery_type: type: string description: delivery type (APM; COURIER) enum: - APM - COURIER delivery_date: type: string format: date-time description: delivery date delivery_options: type: array description: delivery options items: $ref: '#/components/schemas/delivery_options' delivery_price: $ref: '#/components/schemas/base_price' free_delivery_minimum_gross_price: type: number format: decimal description: free delivery minimum gross price estimate_delivery_time: type: array description: estimate delivery time items: $ref: '#/components/schemas/delivery_time' delivery_options: type: object description: additional delivery options required: - delivery_name - delivery_code_value - delivery_option_price properties: delivery_name: type: string description: delivery name example: Paczka w Weekend delivery_code_value: type: string enum: - COD - PWW description: delivery code value. COD - option with payment on delivery, PWW - option with weekend delivery example: PWW delivery_option_price: $ref: '#/components/schemas/base_price' basket_summary: type: object required: - basket_base_price - currency - payment_type properties: basket_base_price: $ref: '#/components/schemas/base_price' basket_final_price: $ref: '#/components/schemas/base_price' basket_promo_price: $ref: '#/components/schemas/base_price' currency: type: string description: basket currency enum: - PLN free_basket: type: boolean description: flag inform if the basket without delivery costs is free basket_expiration_date: type: string format: date-time description: expiry date of basket basket_additional_information: type: string description: additional information payment_type: type: array description: payment type items: $ref: '#/components/schemas/payment_type' basket_notice: $ref: '#/components/schemas/information' payment_type: type: string description: payment type enum: - CARD - CARD_TOKEN - GOOGLE_PAY - APPLE_PAY - BLIK_CODE - BLIK_TOKEN - PAY_BY_LINK - SHOPPING_LIMIT - DEFERRED_PAYMENT - CASH_ON_DELIVERY invoice_details: type: object description: invoice details properties: legal_form: type: string description: legal form of customer enum: - PERSON - COMPANY country_code: type: string description: country code tax_id_prefix: type: string description: tax id prefix tax_id: type: string description: tax id company_name: type: string description: company name name: type: string description: name surname: type: string description: surname city: type: string description: city street: type: string description: street building: type: string description: number building flat: type: string description: number flat postal_code: type: string description: postal code mail: type: string description: email registration_data_edited: type: string description: registration data edited additional_information: type: string description: additional information account_info: type: object required: - name - surname - phone_number - client_address - mail properties: name: type: string description: name surname: type: string description: surname phone_number: $ref: '#/components/schemas/phone_number' mail: type: string description: email client_address: $ref: '#/components/schemas/client_address' consents_order: type: object description: consents order list required: - consent_id - is_accepted properties: consent_id: type: string description: consent id consent_version: type: string description: consent version is_accepted: type: boolean description: is accepted consent orders_list: type: object description: orders details list properties: page_size: type: integer description: page size total_items: type: integer description: total size page_index: type: integer description: page index orders: type: array items: $ref: '#/components/schemas/merchant_order_response' get_payment: required: - payment_type - payment_status properties: payment_type: type: string description: order status enum: - CARD - CARD_TOKEN - GOOGLE_PAY - APPLE_PAY - BLIK_CODE - BLIK_TOKEN - PAY_BY_LINK - SHOPPING_LIMIT - DEFERRED_PAYMENT - CASH_ON_DELIVERY - FREE_ORDER payment_status: type: string description: payment status. UNPAID - status after creation of order. unpaid (assigned by BasketApp), STARTED - status initiating payment reference process and returning payment type selected by customer (assigned by BasketApp), PENDING - start of process in PEGAZ/SDK with success (assigned by Basket or PEGAZ), AUTHORIZED - payment successfully completed, funds blocked (assigned by PEGAZ), DECLINED - payment refused (assigned by PEGAZ), CANCELLED - payment cancelled (assigned by PEGAZ), ERROR - error (assigned by PEGAZ or INPOST), COD- cash on delivery enum: - UNPAID - STARTED - PENDING - AUTHORIZED - DECLINED - CANCELLED - ERROR - COD available_payment_types: type: array description: available payment types for order items: $ref: '#/components/schemas/payment_type' payment_details: $ref: '#/components/schemas/payment_details' payment_details: type: object required: - payment_type - payment_status - payment_reference properties: payment_reference: type: string description: payment reference payment_id: type: string description: payment reference payment_sec_token: type: string description: security token used to payment process payment_type: type: string description: order status enum: - CARD - CARD_TOKEN - GOOGLE_PAY - APPLE_PAY - BLIK_CODE - BLIK_TOKEN - PAY_BY_LINK - SHOPPING_LIMIT - DEFERRED_PAYMENT - CASH_ON_DELIVERY payment_token: type: string description: card token or blik alias payment_card: $ref: '#/components/schemas/payment_card' payment_status: type: string description: payment status. UNPAID - status after creation of order. unpaid (assigned by BasketApp), STARTED - status initiating payment reference process and returning payment type selected by customer (assigned by BasketApp), PENDING - start of process in PEGAZ/SDK with success (assigned by Basket or PEGAZ), AUTHORIZED - payment successfully completed, funds blocked (assigned by PEGAZ), DECLINED - payment refused (assigned by PEGAZ), CANCELLED - payment cancelled (assigned by PEGAZ), ERROR - error (assigned by PEGAZ or INPOST), COD - cash on delivery enum: - UNPAID - STARTED - PENDING - AUTHORIZED - DECLINED - CANCELLED - ERROR - COD payment_code: type: string description: payment code payment_description: type: string description: payment description payment_error_code: type: string description: payment error code payment_message_code: type: string description: payment error code payment_date: type: string format: date-time description: payment date delivery_references: type: string description: delivery references promo_codes: type: object description: promo codes required: - name - promo_code_value properties: name: type: string description: promo code name promo_code_value: type: string description: promo code value regulation_type: type: string description: legal regulation for a promotional code for example. If the promo code is regulated by the Omnibus Directive then pass "OMNIBUS" example: OMNIBUS product_attributes: type: object description: product attributes required: - attribute_name - attribute_value properties: attribute_name: type: string description: attribute name attribute_value: type: string description: attribute value response_basket_binding: type: object required: - qr_code - deep_link - deep_link_hms properties: qr_code: type: string description: qr-code deep_link: type: string description: deep link deep_link_hms: type: string description: deep link response_basket_connected: type: object required: - basket_linked - browser_trusted properties: basket_linked: type: boolean description: is basket linked inpost_basket_id: type: string description: basket id created by BasketApp browser_trusted: type: boolean description: is browser trusted client_details: $ref: '#/components/schemas/client_details' client_details: type: object required: - phone_number - masked_phone_number - name - surname properties: phone_number: $ref: '#/components/schemas/phone_number' masked_phone_number: type: string description: masked phone number example: 60*****00 name: type: string description: client name surname: type: string description: client surname event_data_merchant: type: object description: Data on events properties: order_status: type: string description: order status - Merchant can change order status to; ORDER_COMPLETED - order completed in merchant's shop, ORDER_REJECTED - order rejected by merchant enum: - ORDER_COMPLETED - ORDER_REJECTED order_merchant_status_description: type: string description: order merchant status description delivery_references_list: type: array description: delivery references list items: $ref: '#/components/schemas/delivery_references' base_price: required: - net - gross - vat properties: net: type: number format: decimal description: net price gross: type: number format: decimal description: gross price vat: type: number format: decimal description: VAT quantity: type: object description: product quantity required: - quantity properties: quantity: type: number description: product quantity quantity_type: type: string enum: - DECIMAL - INTEGER description: product quantity type quantity_unit: type: string description: unit quantity available_quantity: type: number format: decimal description: product quantity available max_quantity: type: number format: decimal description: maximum product quantity min_quantity: type: number format: decimal description: minimum product quantity. Field available in next version app quantity_jump: type: number format: decimal description: quantity jump value in case of increase/decrease of product quantity by customer (e.g. 0.1 or 0.5 or 0.01) quantity_order: type: object description: product quantity required: - quantity properties: quantity: type: number description: product quantity quantity_type: type: string enum: - DECIMAL - INTEGER description: product quantity type quantity_unit: type: string description: unit quantity phone_number: type: object description: phone number required: - country_prefix - phone properties: country_prefix: type: string description: prefix example: '+48' phone: type: string example: 600123123 request_basket_binding: allOf: - type: object required: - browser properties: binding_method: type: string enum: - PHONE - DEEP_LINK description: binding method binding_place: type: string enum: - PRODUCT_CARD - BASKET_SUMMARY - ORDER_CREATE - BASKET_POPUP - THANK_YOU_PAGE - LOGIN_PAGE - CHECKOUT_PAGE - REGISTERFORM_PAGE - MINICART_PAGE description: client binding place phone_number: $ref: '#/components/schemas/phone_number' browser: $ref: '#/components/schemas/browser_details' browser_details: type: object description: browser details required: - browser_id - user_agent - platform - architecture - data_time - location - customer_ip - port properties: user_agent: type: string description: user agent description: type: string description: additional description platform: type: string description: platform architecture: type: string description: architecture data_time: type: string format: date-time description: tiem location: type: string description: location customer_ip: type: string description: browser id port: type: string description: port merchant_order_response: type: object required: - order_details - account_info - delivery - products - consents properties: order_details: $ref: '#/components/schemas/merchant_orders_details' account_info: $ref: '#/components/schemas/account_info' invoice_details: $ref: '#/components/schemas/invoice_details' delivery: $ref: '#/components/schemas/delivery' products: type: array description: products order list items: $ref: '#/components/schemas/get_products_order' consents: type: array description: consents list items: $ref: '#/components/schemas/consents_order' merchant_orders_details: type: object required: - order_id - merchant_order_id - pos_id - order_creation_date - merchant_id - basket_hash - payment_status - order_status - order_merchant_status_description - order_base_price - order_final_price - currency properties: order_comments: type: string description: order information order_id: type: string description: ID order assigned by merchant customer_order_id: type: string description: order ID presented to customer and used for payment. In case of lack of customer_order_id order_id will be used. pos_id: type: string description: POS identifier provided by Vodeno, allowing merchant to filter payments in the reporting tools order_creation_date: type: string format: date-time description: order creation date order_update_date: type: string format: date-time description: order update date payment: $ref: '#/components/schemas/get_payment' order_status: type: string description: order status. ORDER_PROCESSING - status given by Basket App when order is created, payment possible ORDER_COMPLETED - order completed at merchant, payment not possible, ORDER_REJECTED - order rejected by merchant or at Inpost app, payment not possible. enum: - ORDER_COMPLETED - ORDER_REJECTED - ORDER_PROCESSING order_merchant_status_description: type: string description: order merchant status description order_base_price: type: object description: price for order without delivery costs required: - net - gross - vat properties: net: type: number format: decimal description: net price gross: type: number format: decimal description: gross price vat: type: number format: decimal description: VAT order_final_price: type: object description: total order price with delivery costs required: - net - gross - vat properties: net: type: number format: decimal description: net price gross: type: number format: decimal description: gross price vat: type: number format: decimal description: VAT order_discount: type: number format: decimal description: Value used discount coupons on order currency: type: string description: basket currency enum: - PLN delivery_references_list: type: array description: delivery references list items: $ref: '#/components/schemas/delivery_references' merchant_basket_details: type: object required: - summary - delivery - products - consents properties: basket_id: type: string description: ID basket assigned by merchant creation_date: type: string format: date-time description: date basket creation update_date: type: string format: date-time description: date basket update summary: $ref: '#/components/schemas/basket_summary' delivery: type: array description: delivery list items: $ref: '#/components/schemas/delivery_basket_response' promo_codes: type: array description: promo codes items: $ref: '#/components/schemas/promo_codes' promotions_available: type: array items: $ref: '#/components/schemas/promotion' products: type: array description: products order list items: $ref: '#/components/schemas/get_products' related_products: type: array description: related product information items: $ref: '#/components/schemas/get_related_products' consents: type: array description: consents list items: $ref: '#/components/schemas/consents' information: type: object required: - type - description properties: type: type: string enum: - ATTENTION - ERROR description: type additional notice description: type: string description: basket additional notice payment_card: type: object required: - type - description properties: last_four_digits: type: string description: Last 4 digits of original PAN (card number) scheme: type: string description: Scheme in which the card operates card_type: type: string enum: - DEBIT - CREDIT - PREPAID - CHARGE - DEFERRED_DEBIT description: Scheme in which the card operates response_signing_keys: type: object properties: merchant_external_id: type: string description: merchant external id public_keys: type: array description: public keys items: $ref: '#/components/schemas/public_key' public_key: type: object required: - type - description properties: public_key_base64: type: string description: public key in format base64 version: type: string description: version response_version_signing_keys: type: object properties: merchant_external_id: type: string description: merchant external id public_key: properties: public_key_base64: type: string description: public key in format base64 version: type: string description: version response_put_basket: type: object required: - inpost_basket_id properties: inpost_basket_id: type: string description: basket id created by BasketApp delivery_product: type: object description: additional delivery information for product properties: delivery_type: type: string description: delivery type (APM; COURIER) enum: - APM - COURIER if_delivery_available: type: boolean description: if type of delivery available for product delivery_related_products: type: object description: additional delivery information for product properties: delivery_type: type: string description: delivery type (APM; COURIER) enum: - APM - COURIER if_delivery_free: type: boolean description: is free delivery for a type of delivery if_delivery_available: type: boolean description: if type of delivery available for product responseGetPayments: type: object required: - payment_type properties: payment_type: type: array description: payment type items: $ref: '#/components/schemas/payment_type' product_images: type: object description: additional product images required: - small_size - normal_size properties: small_size: type: string description: product image. Preferred size 360 x 352 normal_size: type: string description: product image. Preferred size 360 x 504 cookies: required: - domain - keyValue - key - value - path type: object properties: domain: type: string description: Domain of the cookie represented by pair key-value example: "uat.outofthebox.pl" key: type: string description: Cookie key example: "wp_woocommerce_session_f3cd21b400c074e165b59837d7a9d0a4" value: type: string description: Cookie value example: "t_f13664beda2ec455d97546c1ddab8b%7C%7C1699438060%7C%7C1699434460%7C%7Cf77d310ce1f0440cb4812f5043736989" path: type: string description: Cookie path example: "/" expires: type: string description: Cookie expiration time or maxAge example: "2025-01-16T14:17:02.486Z" format: date-time secure: type: boolean description: Cookie security information example: false http_only: type: boolean description: Cookie http information example: true same_site: type: string enum: - STRICT - LAX - NONE description: Cookie sameSite information example: "LAX" priority: type: string enum: - LOW - MEDIUM - HIGH description: Cookie priority example: "MEDIUM" max_age: type: integer description: Cookie max age example: 0 delivery_time: required: - description type: object properties: description: type: string description: message present to customer in inpostpay app example: "Kup do 15:00 - dostawa jutro" days_available: type: array description: days of week on which delivery information is to be present items: $ref: '#/components/schemas/day' start_hour: type: string description: start time of presentation of delivery date app example: "10:00" end_hour: type: string description: end time of presentation of delivery date app example: "15:00" day: type: string description: day example: "MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY" enum: - MONDAY - TUESDAY - WEDNESDAY - THURSDAY - FRIDAY - SATURDAY - SUNDAY promotion: required: - type - promo_code_value - description - details type: object properties: type: type: string description: type proco code. MERCHANT - merchant promo code; ONLY_IN_APP - merchant promo code which is only available in the InPost pay app enum: - MERCHANT - ONLY_IN_APP promo_code_value: type: string description: promo code value description: type: string description: description start_date: type: string description: image url format: date-time end_date: type: string description: image url format: date-time priority: type: integer description: image url details: $ref: '#/components/schemas/details' details: type: object required: - link properties: link: type: string description: link to details basket_request_put_v2: type: object required: - summary - delivery - products - consents properties: summary: $ref: '#/components/schemas/basket_summary' delivery: type: array description: delivery list items: $ref: '#/components/schemas/delivery_basket_response' promo_codes: type: array description: promo codes items: $ref: '#/components/schemas/promo_codes' promotions_available: type: array items: $ref: '#/components/schemas/promotion' products: type: array description: products order list items: $ref: '#/components/schemas/get_products' related_products: type: array description: related product information items: $ref: '#/components/schemas/get_related_products' consents: type: array description: consents list items: $ref: '#/components/schemas/consents' merchant_store: type: object required: - url - cookies properties: url: type: string description: Url of the merchant shop or direct address to cart example: "https://uat.outofthebox.pl/cart/" cookies: type: array items: $ref: '#/components/schemas/cookies' response_binding_basket: required: - basket_binding_api_key type: object properties: basket_binding_api_key: type: string description: basket binding api key |
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.
Code Block <?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; }
View file | ||
---|---|---|
|
We create an url interface for the creator, which will be responsible for obtaining the right url address to InPostPay's API.
Code Block <?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; }
View file | ||
---|---|---|
|
We create an implementation of the creator's url service for the Sandbox environment.
Code Block <?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/'); } }
View file | ||
---|---|---|
|
We create an implementation of the creator's url service for the Production environment.
Code Block <?php declare(strict_types=1); namespace Iteo\InpostPayClient\Client; /** * PHP URL Creator Service implementation used for creating url to Production InpostPay. */ final class ProductionInPostPayURLCreator implements InpostPayURLCreatorInterface { /** * {@inheritdoc} */ public function create(): InpostPayURL { return new InpostPayURL('https://api.inpost.pl/v1/izi/'); } }
View file | ||
---|---|---|
|
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.
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; } /** * @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 ); } }
View file | ||
---|---|---|
|