Code Examples

The imei OR deviceTag is a required parameter in all of the following examples.

Lookup Device Information

Required Parameters
key: Your apiKey provided by PayJoy
deviceTag OR imei: The deviceTag or imei of target device


Example: looking up a device by device tag
curl "https://api.payjoy.com/devicemanager/v1/device?deviceTag=DCXQTF&key=<apikey>
Example: looking up a device by IMEI
curl "https://api.payjoy.com/devicemanager/v1/device?imei=4579507240395872309457&key=<apikey>

PHP

<?php
$apiKey = '[ApiKey]';
$deviceTag = '[DeviceTag]';

$url = "https://api.payjoy.com/devicemanager/v1/device?key=" .
  $apiKey . "&deviceTag=" . $deviceTag;

$options = array(
  'http'  => array (
    'method' => 'GET',
    'ignore_errors' => true,
  ),
);

$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);

echo($response);

Returns

{
   "valid": true,
   "device":
   {
      "deviceTag": "DCXQTF",
      "phoneNumber": "+16502527923",
      "simNumber": "89011202002275950932",
      "simNumber2": "89011202002286061043",
      "simCountryIso": "us",
      "imei": "4579507240395872309457",
      "imei2": "4579507240395872410568",
      "serialNumber": "ad09160358d7b0ec0b",
      "createTime": 1496158088,
      "lastSeen": 1496166213,
      "family": "Galaxy S8",
      "manufacturer": "SAMSUNG",
      "makeModel": "SM-G935V",
      "description": "Samsung Galaxy S8 (Verizon)",
      "firmwareModified": false,
      "isRooted":false,
      "lock": {
         "state": "active",
         "expiration": 1496276213,
         "requiredPhoneNumber": "16502527923",
         "requiredSimNumber": "89011202002275950932"
      }
   }
}
valid boolean True indicates that results data follows
deviceTag string Unique identifier for a device
phoneNumber string phone number of device
simNumber string SIM number of the installed SIM on the device
simNumber2 string Second SIM number of the installed SIM on the device (dual SIM only)
imei string IMEI of the device
imei2 string Second IMEI of the device (duial SIM only)
serialNumber string Device serial number
createTime string Timestamp when this device registered with PayJoy
family string Device family name
manufacturer string Manufacturer
makeModel string Manufacturer’s model number
description string Name of this model (including carrier(s))
firmwareModified boolean Indicates that the firmware on device has been modified
isRooted boolean Indicates if the device has been rooted
state string State of the device lock
expiration int Datetime that device will remain unlocked through
requiredPhoneNumber string Phone number required for device to remain unlocked
requiredSimNumber string Sim number required for device to remain unlocked
lastSeen string Timestamp when device last checked in

Claim a Registered Device

Claiming a device requires a device tag or imei (from the device we want to activate) and the first expiration time.

Example: Activating a device by device tag
curl "https://api.payjoy.com/devicemanager/v1/device/lock?deviceTag=DCXQTF&key=<apikey>&state=active&expiration=1496276213
Required Parameters
key: Your apiKey provided by PayJoy
deviceTag OR imei: The deviceTag or imei of target device
state: active
expiration: timestamp


PHP

<?php
$apiKey = '[ApiKey]';
$deviceTag = '[DeviceTag]';
$expiration = time() + 86400; // unix timestamp. time now + one day

$url = "https://api.payjoy.com/devicemanager/v1/device/lock?key=" .
  $apiKey . "&deviceTag=" . $deviceTag . "&state=active&expiration=" . $expiration;

$options = array(
  'http'  => array (
    'method' => 'GET',
    'ignore_errors' => true,
  ),
);

$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);

echo($response);

Returns

{
  "valid":true,
  "state":"ready_to_activate"
}

At this point the device is claimed and the lock will activate when the device hits our server. The device will have credit until the expiration date.

Reactivate a Claimed Device

A device can also be reactivated after being set to inactive. This process requires sending the active state long with the device tag or imei.

Example: Reactivating an inactive device by device tag
curl "https://api.payjoy.com/devicemanager/v1/device/lock?deviceTag=DCXQTF&key=<apikey>&state=active
Required Parameters
key: Your apiKey provided by PayJoy
deviceTag OR imei: The deviceTag or imei of target device
state: active


PHP

<?php
$apiKey = '[ApiKey]';
$deviceTag = '[DeviceTag]';

$url = "https://api.payjoy.com/devicemanager/v1/device/lock?key=" .
  $apiKey . "&deviceTag=" . $deviceTag . "&state=active;

$options = array(
  'http'  => array (
    'method' => 'GET',
    'ignore_errors' => true,
  ),
);

$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);

echo($response);

Returns

{
  "valid":true,
  "state":"active"
}

Because this call is made on an already-secured device in the inactive state, at this point the PayJoy lock is now active and secured.

Update Device Expiration Time

When a customer makes a payment on the device, the expiration time of the lock needs to be extended

Example: Extending the expiration date to 1532818706
curl "https://api.payjoy.com/devicemanager/v1/device/lock?deviceTag=DCXQTF&key=<apikey>&state=active&expiration=1532818706
Required Parameters
key: Your apiKey provided by PayJoy
deviceTag OR imei: The deviceTag or imei of target device
expiration: timestamp


Returns

{
  "valid":true,
  "state":"active"
}

Note

Expiration is a unix timestamp, use the Epoch & Unix Timestamp Conversion Tools

Update Required Phone Number and Sim Number

Changing the sim and/or phone number will lock the device, as a safety measure, and can be change using the following API call. Note that this call sets both the required sim and the required phone number, but a request can also be made with only one.

Example: Extending the expiration date to
curl "https://api.payjoy.com/devicemanager/v1/device/lock?deviceTag=DCXQTF&key=<apikey>&state=active&requiredPhoneNUmber=16502527923&requiredSimNumber=89011202002275950932
Parameters
key: Your apiKey provided by PayJoy
deviceTag OR imei: The deviceTag or imei of target device
requiredPhoneNumber: Phone number required for device to remain unlocked
requiredSimNumber: Sim number required for device to remain unlocked


Returns

{
  "valid":true,
  "state":"active"
}

Note

The required phone number or sim number constraints may be removed by setting the parameter equal to nothing in the request (requiredSimNumber=&requiredPhoneNumber=<phoneNumber>).

Set Lock to Removable

In order to set the app as removable the state needs to be changed to removable using the following API call

Example: Remove the lock from a device
curl "https://api.payjoy.com/devicemanager/v1/device/lock?deviceTag=DCXQTF&key=<apikey>&state=removable
Required Parameters
key: Your apiKey provided by PayJoy
deviceTag OR imei: The deviceTag or imei of target device
state: removable


Returns

{
  "valid":true,
  "state":"removable"
}

Set Lock to Inactive

In order to deactivate the lock, the state needs to be changed to inactive using the following API call

Example: Setting the lock to inactive on a device
curl "https://api.payjoy.com/devicemanager/v1/device/lock?deviceTag=DCXQTF&key=<apikey>&state=inactive
Required Parameters
key: Your apiKey provided by PayJoy
deviceTag OR imei: The deviceTag or imei of target device
state: inactive


Returns

{
  "valid":true,
  "state":"inactive"
}

Preclaim a Device

Claim a device before it has been registered in PayJoy’s system

Example: claim a device by imei
curl "https://api.payjoy.com/devicemanager/v1/device/claim?imei=123456789012345&key=<apikey>
Required Parameters
key: Your apiKey provided by PayJoy
imei: The imei of target device


Note

The preclaim endpoint takes only imei, not deviceTag. At this point, no deviceTag has been generated.

Returns

{
  "valid":true,
}

Update offline device

Update valid through status of a device using text messaging.

Example: Update validThrough status of a device using imei.
curl "https://api.payjoy.com/devicemanager/v1/device/offline-update?action=expiration&imei=<imei>&key=<apiKey>"
Example: Update validThrough status of a device using deviceTag.
curl "https://api.payjoy.com/devicemanager/v1/device/offline-update?action=expiration&deviceTag=<deviceTag>&key=<apiKey>"
Required Parameters
key: Your apiKey provided by PayJoy
action: This must be expiration to update validThrough status of a device.
imei or deviceTag: The imei or deviceTag of target device

Returns

{
  "valid":true,
  "expirationChangeUnlockCode": "<code to update valid through>"
}