Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The InPost Pay widget offers coupling shopping baskets at stores with the InPost Mobile application. The frontend layer is delivered in the form of a JavaScript plug for embedding on the website, and of this documentation.

A correct integration requires providing a backend layer, html embedding of the plug, and control over the status of the front-end layer by providing the methods described below.

 

A list of methods to be implemented by the merchant's backend, in order to use the plug:

iziGetBindingData
iziGetIsBound
iziGetOrderComplete
iziBindingDelete
iziCanBeBound
iziAddToCart


On this page:

Table of Contents

Script download

The script of the plug is available at: https://izi.inpost.pl/inpostizi.js https://izi.inpost.pl/inpostizi.js

Embed it in your website by:

Code Block
<script src="https://izi.inpost.pl/inpostizi.js"></script>

Html embedding

In order to display the widget, embed the following code in html:

Code Block
languagehtml
<inpost-izi-button name="" masked_phone_number=""
Code Block

data-product-id="" language="pl" variant="primary" basket="true"
Code Block

dark_mode="true" count="5"></inpost-izi-button>

Parameter

Description

name

The buyer's forename, enter if the baskets are paired.

data-product-id

Product ID, required when you want to add a product with the stated ID to the basket at pairing.

masked_phone_number

Masked telephone number, required if the baskets are paired.

variant

Button appearance variant. "Secondary" orr or "primary" available.

basket

It determines whether or not the button is located on the basket's page. Acceptable value "true".

dark_mode

Specifies the display mode. Acceptable value "true".

count

Specifies the initial number of products to be displayed in the basket.

binding_place

Specifies where the bind occurs. This information goes to iziGetBindingData as a parameter.

Available options are:

  • PRODUCT_CARD

  • BASKET_SUMMARY

  • ORDER_CREATE

  • BASKET_POPUP

  • THANK_YOU_PAGE


iziGetBindingData

Downloads the data necessary to pair baskets. The prefix and phoneNumber parameters are not compulsory. The calls with 1 parameter are used to procure a qr code. The calls with all 3 parameters are used to pair using a phone number.

Parameters

id - product identifier
prefix - phone number prefix
phoneNumber - phone number

Returns

Promise

Value

Data from backend query basket-app/api/v1/izi/basket/{basketId}/binding

Code Block
languagehtml
function iziGetBindingData(id, prefix, phoneNumber, bindingPlace)
{

Code Block


return Promise.resolve({

Code Block


qr_code: 'string',

Code Block


deep_link: 'string',

Code Block


deep_link_hms: 'string',

Code Block


});

Code Block


}


iziGetIsBound

Calls after displaying a qr code or a deep link in order to check whether the coupling was successful. On the developer's side, the communication must be handled so that the server is not loaded too much by applying websocket orr long pooling.

Parameters

none

Returns

Promise

Value

Data obtained from InPost Pay to the inquiry /inpost/v1/izi/basket/{basketId}/confirmation

Code Block
languagehtml
function iziGetIsBound () {
Code Block

return Promise.resolve({
Code Block

"phone_number": {
Code Block

"country_prefix": "string",
Code Block

"phone": "string"
Code Block


},
Code Block

"browser_trusted": boolean,
Code Block

"name": "string",
Code Block

"surname": "string"
Code Block

});
Code Block


}

iziGetOrderComplete

The method called upon pairing a basket and on each page with a basket already paired. Looks for the finish of ordering in the app. As a reply, we get the URL of a page such as thank you page with a thank you for the purchase message.

Parameters

none

Returns

Promise

Value

{redirect: ‘url’}

Code Block
languagehtml
function iziGetOrderComplete

() {

Code Block


return Promise.resolve({

Code Block


redirect: '

string'

' Code Block

})

Code Block


}


iziBindingDelete

The method called at pairing removal.

Parameters

none

Returns

Promise

Value

void

Code Block
languagehtml
function iziBindingDelete () {
Code Block

return Promise.resolve();
Code Block

}

iziCanBeBound

The method determines whether or not the product may be added to the basket and paired. Used for variable products in order to determine whether or not the product parameters have already been specified.

Parameters

productId - product identifier

Returns

Bool

Value

true || false

Code Block
languagehtml
function iziCanBeBound(productId) {

Code Block


return true || false;
}


iziAddToCart

The method used to add a product after clicking on the widget.

Parameters

id - product identifier

Returns

void

Value

Code Block
languagehtml
async function iziAddToCart(id) {
return void;
}

SPA

The plug has been developed for use with SPA applications. For the purpose of integrating the store with InPost Pay, the initiation of the Pay button must be handled within the app's life cycle.
Upon its first loading, the script automatically initiates all the instances of <inpost-izi-button/> W found in the code to initiate the widget after DOM update
use the method:

Code Block
window.handleInpostIziButtons();

Below is an example for the ReactJs component:

Code Block
languagehtml
import React, { useEffect } from "react";
Code Block

import { useLocation } from "react-router-dom";
Code Block


export...= ({ children }) => {
Code Block

const location = useLocation();
Code Block

useEffect(() => {
Code Block

window.handleInpostIziButtons();
Code Block

}, [location]);
Code Block

return <>{children}</>;
Code Block

};