Verification of the binding between the shopping cart and InPost Pay
The Client goes to the Merchant's website.
The Merchant builds the store's website with an embedded widget with the message:
"Utwórz koszyk z InPost Pay (create a basket with InPost Pay)" - the widget embedded on the product card
"Kup z InPost Pay (Buy with InPost Pay)" -the widget embedded in the basket.
The customer presses the widget "Utwórz koszyk z InPost Pay (create a basket with InPost Pay) "or "Kup z InPost Pay (Buy with InPost Pay)".
The Widget verifies in the Merchant's backend, whether or not the chosen product is available for adding to the basket (iziCanBeBound).
At the first method called by the Widget, the Merchant's backend calls the method to InPost Pay to verify whether or not the customer's basket is bound to InPost Pay, and whether or not the browser the customer currently uses is among the trusted ones. The verification takes place through the request GET/v1/izi/basket/{basket_id}/binding.
InPost Pay returns the information that the basket is linked (basket_linked=true), and the browser is trusted (browser_trusted=true) or the browser is not trusted (browser_trusted=false).
The Merchant's backend refreshes the store's website together with the updated Widget, to which the message is transferred:
The Widget adds the product to the basket in the Merchant's store (iziAddToCart)
Upon receiving the request PUT/v1/izi/basket/{basket_id}, Inpost Pay updates the existing basket, or binds it to the phone number assigned to the trusted browser. Then, it notifies the Merchant's backend of the successful operation (response 200).
The Merchant's backend calls inpost-update-count that authorizes updating the number of products on the button.
The widget presents the updated number of products in the basket.
After obtaining the information that the basket is now linked, the Widget starts observing the Merchant's backend (with the use of iziGetOrderComplete and one of the looping or websocket methods), to see if the order was completed for the basket.
Binding the basket to another phone number (Removing /desynchronizing the basket associated with InPost Pay)
The customer presses "Produkty w koszyku InPost Pay (Products in InPost Pay basket)".
The widget presents the screen "Twoje zakupy czekają już na Ciebie w aplikacji InPost Mobile (Your products await you already in the InPost Mobile App)" along with the masked telephone number bound to the basket in the InPost Pay app.
The Customer selects "Połącz te zakupy z innym kontem (Connect these purchases with another account)".
The Widget presents the popup "Czy na pewno chcesz powiązać te zakupy z numerem telefonu innym niż (Do you really want to bind these purchases with a phone number different than)..".
The Customer selects "Połącz z innym numerem telefonu (Bind to another phone number)".
The Widget calls iziBindingDelete to the Merchant's backend.
The Merchant's backend calls DELETE/v1/izi/basket/{basket_id}/binding to InPost Pay.
InPost Pay removes the binding between the basket and the phone number, and notifies the Merchant's backend of the correct completion of the task.
The Merchant's backend calls DELETE/v1/izi/browser/{browser_id}/binding to InPost Pay.
InPost Pay removes the binding between the browser and the phone number and notifies the Merchant's backend of the correct completion of the task.
The Merchant notifies the Widget (Promise.resolve in the response iziBindingDelete), which then presents the customer with a screen with the basket's association based on the updated/amended phone number.