4WS Suite
Home
API Reference
  • Data mangement API
  • Documents API
Home
API Reference
  • Data mangement API
  • Documents API
Fourwayshop
  1. Use cases
  • Four Way Shop API
  • Before start develop
  • Why we use Resource-oriented design
  • Technical Prerequisites
  • Concepts
    • Date Handling
    • Managing Languages
    • Handling Field Updates and Null Values in Service Requests
    • ISO Code
    • Vat rates
    • Product structure
    • Product Images
    • Product dimensions
    • Product pricing
    • Dimension group vs Dimension grouping
    • Subjects overview
    • Documents structure
  • Best Practices
    • Best Practices for Error Handling in External System
    • How Testing callback response
    • Best Practices for delopers
  • Data management
    • Authentication
    • Rate Limits
    • Paginated Responses
    • Getting Started
    • API Changelog
    • Use cases
      • Cataloging a Dimension
      • Creating a New Product
      • Retriving a product details
      • Defining Product Pricing
      • Updating External System Product Catalog
      • Activate product variants and add barcodes to SKUs
      • Move a Barcode from One Product to Another
    • API
      • Login
        • login
      • Product
        • Brand
          • Get All Brands
          • Get A Brand
          • Insert brand
          • Update brand
        • Season
          • Get All Seasons
          • Get A Season
          • Insert season
          • Update season
        • Attribute
          • Get All Attribute Types
          • Get Attribute Type
          • Get Attribute
          • Insert attribute
          • Update attribute
        • Hierarchy
          • Insert hierarchy
          • Update hierarchy
        • Dimension groups
          • Insert dimension group
          • Update dimension group
        • Dimension
          • Insert dimension
          • Update dimension
          • Delete dimension
        • Product
          • Get products
          • Get product
          • Get product grouping
          • Get SKU's barcodes
          • Get product stock
          • Insert product
          • Update product
        • Activate dimensions on products
          • Insert active dimensions
          • Delete active dimensions
        • Barcode
          • Get SKU from barcode
          • Generate missing barcodes
          • Generate missing barcode for SKU
          • Insert barcode
          • Delete barcode
        • Prices
          • Get product prices
        • Price dimension groupings
          • Get Dimension Price Grouping
          • Get All Dimension Price Grouping
          • Insert dimension grouping
          • Update dimension grouping
          • Delete dimension grouping
        • Assortment
          • insert product assortment
          • delete product assortment
        • Image
          • Get images
          • Add image
          • Replace image
          • Delete image
        • Supplier
          • Get Item suppliers
          • Insert item supplier
          • Delete item supplier
          • Update item supplier
        • Custom category
          • Get Custom code
          • Insert Custom code
          • Update Custom code
        • Vat
          • Vat types
            • Get VAT type
            • Get VAT types
          • VATs
            • Get VATs
            • Get VATs by type
            • Get VAT
          • Vat rates
            • Get VAT rates
            • Get single VAT rates
        • Stock
          • Insert stock
          • Get stock
      • Price lists
        • Get price lists
        • Get price lists by type
        • Get price list
        • Get prices from price list
        • Get entities from price lists
        • Insert Price List
        • Insert Product Price
        • Insert Entity On Price Lists
        • Update price list
        • Delete all product prices
        • Delete single product price
        • Delete entity from a price lists
      • Supplier
        • Supplier contacts
        • Supplier addresses
        • Get Suppliers
        • Get A Specific Supplier
        • Insert supplier
        • Update supplier
      • Entities
        • Get entities
        • Get entity
        • Insert entity
        • Update entity
      • Miscellaneous
        • Get requests rate limits
      • Catalog
        • Get Catalogs details
        • Get Catalog details by Code
        • Get products by Catalog Code
      • Export
        • Get bulk CSV Export
  • Documents
    • Authentication
    • Paginated responses
    • Managing API Callbacks
    • Document notifications
    • Customer promo data notifications
    • Use cases
      • Updating External System Stock
      • E-commerce Recipt Processing
      • E-commerce Return Receipt Processing
      • E-commerce Order sale Processing
      • E-commerce Return Order Processing
      • E-commerce Order Handling and Internal Stock Transfer
      • E-commerce & Gift Card
      • Creating a free entry
      • Retrieving a Document by Identifier
      • Cart Validation Service
      • Sale and Shipping costs
      • Handling Line Item Discounts
      • Managing Price Forcing in Cart Items
      • Purchase Order Registration
      • Supplier Goods Entry From Purchase Order
      • Update an Orchestrated Order
      • New Orchestrated Return Orders
    • API
      • Document Manager
        • Orders
          • Save Sale Order
          • Save Return Order
        • Orchestrated Orders
          • Orchestrated Order
          • Orchestrated Return order
          • Orchestrated Update order
        • Cart
          • Cart Validation
          • Cart Full Validation
        • Sales
          • Save receipt
          • Salve only Order
          • Replace or update sale
          • Get last digital order
        • Warehouse
          • Save Entry from supplier
          • Save Transfer document
          • Save Free Entry
        • Purchase
          • Save Purchase
        • Get Document
        • Update Document external references
      • Customer
        • Get Customer
        • Set Customer Opt-in
      • Loyalty vouchers
        • Get customer loyalty vouchers
        • Get loyalty vouchers at a time interval
        • Get last loyalty vouchers
      • Giftcard
        • Get Giftcard
        • Update Giftcard
        • Generate Gift Card Barcode
        • Gift Card PDF Generation
      • Stock
        • Get Stock
        • Get last stock
        • Insert Stock
  • 🚫 KeepIT
    • Authentication
    • Use cases
    • Articles (deprecated)
      • Get Articles
      • Insert/Update dimensional groups
      • Insert/Update price groupings
      • Insert/Update dimensions
      • Insert/Update attributes
      • Insert/Update hieararchies
      • Insert/Update seasons
      • Insert/Update articles
      • Insert/Update Articles Master data
      • Insert/Update Lists
      • Insert/Update Dimensions Groups
      • Create EAN13 barcode
      • Insert/Update Barcode
      • Assign dimensions to groupings
    • Price Lists (deprecated)
      • Insert price list
      • Add entity to price list
      • Add item price to price list
      • Insert sale profile
      • Insert sale period
      • Add item price to sale period
    • Stock (deprecated)
      • Get Stock
      • Get Stock Date
      • Get Stock CSV
      • Insert/Update Stock
    • Sales (deprecated)
      • Insert/Update sales
      • Delete sales
      • Upload printer sales archive
    • Deposit (deprecated)
      • Insert/Update deposits
    • Services
      • Insert/Update services
      • Delete services
    • Points
      • Insert/Update points
      • Calculate and Insert/Update Points
      • Delete points
    • Subjects
      • Check customers
      • Anonymize customers
      • Get subject data
      • Get customer discount
      • Insert/Update customer
      • Insert/Update billing customers
      • Insert/Update CRM customer
      • Insert/Update children
      • Change/Replacement card
      • Insert CRM user
    • Giftcards & Vouchers
      • Get giftcard
      • Insert/Update giftcards
      • Insert/Update Vouchers
    • Missed Opportunity
      • Get Lost Opportunities
      • Insert/Update missed opportunities
      • Delete missed opportunity
    • Documents (deprecated)
      • Insert documents
      • Get document
    • Catalogs
      • Get Catalog
      • Insert/update catalog
      • Insert/Update hierarchies item catalog
      • Insert/Update entity clusters
    • Suppliers (deprecated)
      • Insert/Update tailor
      • Insert/Update supplier
    • Export (deprecated)
      • Get Items Export
      • Get Barcodes Export
      • Get Prices Export
      • Get Customers Export
      • Get Suppliers Export
      • Get Sales Export
      • Get Movements Export
      • Get Vouchers Export
    • Configuration Mobile Shop (deprecated)
      • Insert/Update Entities
      • Insert Seller
    • Mappings
      • Insert Mappings
      • Get Mappings
  1. Use cases

E-commerce & Gift Card

E-commerce & Gift Card#

Use Case Description#

This use case describes the process of a customer purchasing a digital gift card from an external system, gifting it to a friend, and the friend subsequently using the gift card to make purchases on an e-commerce site.

Actors#

Customer: Purchases and gifts the digital gift card.
E-commerce System: Handles the sale and validation of the gift card.
External System: Generates and manages the gift card details.
Preconditions#
The external system must have the necessary permissions and access to the document creation service, please refer to Authentication.

APIs Used#

1.
Generate Giftcards: Generates digital gift cards.
2.
Get Giftcard: Validates and retrieves gift card details.
3.
Update Giftcard: Updates the gift card balance after a purchase.

Main Success Scenario#

1.
Purchase and Gift Generation:
The customer sends a request to the external system to generate a digital gift card using the Generate Giftcards API.
The external system processes the request and sends the generated gift card details back to the customer via a callback URL.
2.
Gift Card Usage:
The recipient visits the e-commerce site and adds items to their cart.
At checkout, the recipient enters the barcode of the gift card.
The e-commerce site uses the Get Giftcard API to validate the gift card and check the available balance.
If the gift card is valid and has sufficient balance, the e-commerce site completes the order and uses the Update Giftcard API to deduct the purchase amount from the gift card balance.

Alternate Flows#

1.
Gift Card Generation Failure:
If the Generate Giftcards API fails (e.g., invalid itemCode), an error message is sent to the callback URL.
2.
Invalid or Expired Gift Card:
If the Get Giftcard API indicates the gift card is invalid or expired, the e-commerce site informs the recipient, and the transaction cannot proceed.
3.
Insufficient Balance:
If the gift card balance is insufficient to cover the purchase, the e-commerce site prompts the recipient to use an alternative payment method.

Example JSON Structure Generate Giftcards#

Request#
{
    "itemCode": "GIFTCARD_IVA_TAGLIO_100",
    "giftcards": 5,
    "callback": "https://webhook.site/..."
}
Successful Response#
{
    "success": true,
    "giftcards":
    [
        {
            "barcode": "4443334961511",
            "startValidity": "2022-06-10 00:00:00",
            "endValidity": "2023-06-10 00:00:00"
        },
        {
            "barcode": "4448332511072",
            "startValidity": "2022-06-10 00:00:00",
            "endValidity": "2023-06-10 00:00:00"
        }
    ]
}
Error Response#
{
    "success": false,
    "message": "itemCode not found"
}

Example JSON Structure Get Giftcard#

Request#
Successful Response#
{
    "success": true,
    "giftcard":
    {
        "id": "SVILU_500_440_2000000001814",
        "companyId": "XXXX",
        "siteId": 500,
        "branchCode": 1,
        "entityCode": 440,
        "cardBarcode": "2000000001814",
        "issueDate": "2021-10-04 00:00:00",
        "activationDate": "2021-10-04 00:00:00",
        "expirationDate": "2021-11-04 00:00:00",
        "flgActive": "Y",
        "priceList": "1",
        "priceListType": "V",
        "decimalNumber": 2,
        "currencySymbol": "€",
        "currency": "EUR",
        "originalAmount": 390,
        "amount": 390,
        "itemType": "FINANCIAL",
        "itemSubtype": "GIFTCARD",
        "itemCode": "GF440VP15_400_3",
        "taxRate": 21,
        "vatCode": 3,
        "printerDepartmentCode": 1,
        "flgNetworkUsage": "Y",
        "flgPartiallyUsage": "Y",
        "paymentTermCode": 201,
        "flgAllowOfflineUsage": "N",
        "taxation": ""
    }
}
Error Response#
{
    "success": false,
    "message": "barcode not found"
}

Example JSON Structure Update Giftcard#

Request#
{
    "entityCode": 440,
    "barcode": "0098260111383",
    "amount": -50.0
}
Successful callback Response#
{
    "success": true,
    "id": "7571b744-8e2d-4dde-99d8-b60c0dff1aca"
}
Error callback Response#
{
    "success": false,
    "message": "barcode not found"
}

Sequence Diagram#

INFO
Please refer to Best Practices for Error Handling in External System for best practices on implementation.

Code Examples in Node.js#

Generating a Gift Card#
Validating a Gift Card#
Updating a Gift Card Balance#
Modified at 2024-11-13 13:56:59
Previous
E-commerce Order Handling and Internal Stock Transfer
Next
Creating a free entry
Built with