PHPackages                             magefine/unidays-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. magefine/unidays-php

ActiveLibrary[API Development](/categories/api)

magefine/unidays-php
====================

This is the PhP library for integrating with UNiDAYS

1.0.1(1y ago)02.5k↓91.7%MITPHPPHP &gt;=5.6

Since Apr 2Pushed 1y agoCompare

[ Source](https://github.com/Magefine/unidays-php)[ Packagist](https://packagist.org/packages/magefine/unidays-php)[ Docs](https://github.com/Magefine/unidays-php)[ RSS](/packages/magefine-unidays-php/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (3)Used By (0)

 [![](https://camo.githubusercontent.com/53ca7d8198a5a854582bfe3b9e07bd36b1c9bd314936ff5038793660e1220e95/68747470733a2f2f617373657473312e756e69646179732e776f726c642f76352f6d61696e2f6173736574732f696d616765732f6c6f676f5f763030332e737667)](https://camo.githubusercontent.com/53ca7d8198a5a854582bfe3b9e07bd36b1c9bd314936ff5038793660e1220e95/68747470733a2f2f617373657473312e756e69646179732e776f726c642f76352f6d61696e2f6173736574732f696d616765732f6c6f676f5f763030332e737667)

[![Build Status](https://camo.githubusercontent.com/144da96158aa848e70628f2875960c382be6a5bc7b7458bbc4dd1c5b5fc3683f/68747470733a2f2f7472617669732d63692e6f72672f4d79554e69444159532f756e69646179732d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/MyUNiDAYS/unidays-php)

UNiDAYS PHP Library
===================

[](#unidays-php-library)

This is the PHP library for integrating with UNiDAYS. This is to be used for coded and codeless integrations. The following documentation provides descriptions of the implementations and examples.

Contents
--------

[](#contents)

[**How to use this code?**](#how-to-use-this-code)

[**Direct Tracking**](#direct-tracking)

- [Parameters](#parameters)
    - [Example Basket](#example-basket)
- [Example Usage](#example-usage)
    - [Create Server URL *(returns url for server to server request)*](#create-server-url)
    - [Create Script URL *(returns url for client to server request)*](#create-script-url)
    - [Tracking Client *(sends server to server request)*](#tracking-client)
    - [Test endpoint](#test-endpoint)
    - [Direct Tracking Details Builder](#direct-tracking-details-builder)

[**Codeless Verification**](#codeless-verification)

- [Codeless API](#codeless-api)
    - [Codeless Url Verifier](#codeless-url-verifier)

[**Contributing**](#contributing)

How to use this code
--------------------

[](#how-to-use-this-code)

- Pull the package from [Packagist](https://packagist.org/packages/unidays/unidays-php). The commands for doing this are displayed on the Packagist page. Please use the most recent version.
- See the example usage section for the type of call you intend to use. Each of these contains an example.

Direct Tracking
---------------

[](#direct-tracking)

### Parameters

[](#parameters)

Here is a description of all the available parameters. Which of these you provide to us are dependent on the agreed contract.

### Mandatory Parameters

[](#mandatory-parameters)

ParameterDescriptionData TypeExamplePartnerIdYour PartnerId as provided by UNiDAYS. If you operate in multiple geographic regions you MAY have a different PartnerId for each regionBase64 Encoded GuidXaxptFh0sK8Co6pI==TransactionIdA unique ID for the transaction in your systemStringOrder123CurrencyThe ISO 4217 currency codeStringGBPHaving **either** Code or MemberID as a parameter is also mandatory:

ParameterDescriptionData TypeExampleCodeThe UNiDAYS discount code usedStringABC123MemberIdOnly to be provided if you are using a codeless integrationBase64 Encoded Guid0LTio6iVNaKj861RM9azJQ==### Additional Parameters

[](#additional-parameters)

Note any of the following properties to which the value is unknown should be omitted from calls. Which of the following values you provide to us will depend on your agreed contract.

ParameterDescriptionData TypeExampleOrderTotalTotal monetary amount paid, formatted to 2 decimal placesDecimal209.00ItemsUNiDAYSDiscountTotal monetary amount of UNiDAYS discount applied on gross item value `ItemsGross`, formatted to 2 decimal placesDecimal13.00ItemsTaxTotal monetary amount of tax applied to items, formatted to 2 decimal placesDecimal34.50ShippingGrossTotal monetary amount of shipping cost, before any shipping discount or tax applied, formatted to 2 decimal placesDecimal5.00ShippingDiscountTotal monetary amount of shipping discount (UNiDAYS or otherwise) applied to the order, formatted to 2 decimal placesDecimal3.00ItemsGrossTotal monetary amount of the items, including tax, before any discounts are applied, formatted to 2 decimal placesDecimal230.00ItemsOtherDiscountTotal monetary amount of all non UNiDAYS discounts applied to `ItemsGross`, formatted to 2 decimal placesDecimal10.00UNiDAYSDiscountPercentageThe UNiDAYS discount applied, as a percentage, formatted to 2 decimal placesDecimal10.00NewCustomerIs the user a new (vs returning) customer to you?Booleantrue or false### Example Basket

[](#example-basket)

Here is an example basket with the fields relating to UNiDAYS tracking parameters,

ItemGrossUNiDAYS DiscountOther DiscountTaxNet TotalLine TotalShoes100.000.000.0016.6783.33100.00Shirt50.005.000.007.5037.5045.00Jeans80.008.0010.0010.3351.6762.00**Totals**230.0013.0010.0034.50172.50207.00Shipping5.00Shipping Discount3.00**Order Total**209.00Example Usage
-------------

[](#example-usage)

Below are the three options for implementing your integration. These examples cover both coded and codeless integrations (see the live analytics PDF for details) and include all optional parameters. They are intended as a guideline for implementation.

- [Create Server URL *(returns url for server to server request)*](#create-server-url)
- [Create Script URL *(returns url for client to server request)*](#create-script-url)
- [Tracking Client *(sends server to server request)*](#tracking-client)
- [Test endpoint](#test-endpoint)

### Create Server URL

[](#create-server-url)

This method returns a URL which you can use to call the API.

It is a mandatory requirement that all server URLs are signed. This means you are required to pass the signing key UNiDAYS provide you with as one of the arguments. The signing key is a Base64 encoded GUID. This endpoint accepts both `GET` and `POST` requests.

#### Making the call

[](#making-the-call)

The method to get the URL to make a server-to-server request with is `create_server_url($key)`. To implement this method you first need to use the `DirectTrackingDetailsBuilder` to create a direct tracking object with the properties you want to send across to us. More details about this builder can be found [here](#direct-tracking-details-builder).

Once the object containing the details you need to send us is created, create a Tracking helper, providing those details as an argument `new TrackingHelper($directTrackingDetails)` and call `->create_server_url($key)` where `$key` is the key provided to you by UNiDAYS.

#### Return

[](#return)

A URL will be returned to you, which can then be used to call our API. If successful a response with a status code of 204 No Content will be returned. This will work for both `POST` and `GET` requests.

#### Example

[](#example)

```
