API DOCUMENTATION Last Update: Apr 2022

Batch Transactions

Record a batch of transactions for a customer account, including redemptions.

 

The data to be submitted to the API is composed of the following fields:

 

Fields common to all campaign types:

field   Example   Note
user_id john1970 Required
user_password 1959caadac9b13dcb3 Required
type batch_transactions Required
account_id greatwidgets Required
delimiter pipe or comma or tab Required
apply_ratio yes Optional: 'yes' or don't include.
no-undo yes Optional: 'yes' or don't include.
send_transaction_email Y Optional: 'Y' or don't include.
Output Format:
output JSON or XML Optional. If not provided, defaults to XML
callback someFunctionName Optional: JSONP format
condensed yes Optional (No white space)
Applies only to JSON(P) output

 

Fields for Points-Based Campaigns:

  field   Example   Note
visits_header_1 campaign_id Required
visits_header_2 code Required
visits_header_3 redeemed Required: Y | N
visits_header_4 amount Required: if not used
set value to none
visits_header_5 date Required: if not used
set value to none
visits_header_6 authorization Required: if not used
set value to none
visits_header_7 none Required: if not used
set value to none
Visits_Data (see below)
Data to be imported in batch: single (text) field with <eol>s at the end of each line:

1111222233334444|12121|N|14,95|03/15/2010|API test import 1

1111222233334444|12121|N|50|03/15/2010|API test import 2

1111222233334444|12121|N|34.67|03/15/2010|API test import 3

1111222233334444|12121|N|0,50|03/15/2010|API test import 4

1111222233334444|12121|N|.75|03/15/2010|API test import 5

1111222233334444|12121|N|2.00|03/15/2010|API test import 6

1111222233334444|12121|Y|1500|03/15/2010|API test redeem 1

 

Fields for Gift-Card Campaigns:

  field   Example   Note
visits_header_1 campaign_id Required
visits_header_2 code Required
visits_header_3 redeemed Required: Y | N
visits_header_4 amount Required: if not used
set value to none
visits_header_5 date Required: if not used
set value to none
visits_header_6 authorization Required: if not used
set value to none
visits_header_7 none Required: if not used
set value to none
Visits_Data (see below)
Data to be imported in batch: single (text) field with <eol>s at the end of each line:

1111222233334444|12121|N|14,95|03/15/2010|API test import 1

1111222233334444|12121|N|34.67|03/15/2010|API test import 2

1111222233334444|12121|Y|49.62|03/15/2010|API test redeem 1

 

Fields for Buy-X-Get-One-Free / Membership Campaigns:

  field   Example   Note
visits_header_1 campaign_id Required
visits_header_2 code Required
visits_header_3 redeemed Required: Y | N
visits_header_4 service_product Required
visits_header_5 amount Required: if not used
set value to none
visits_header_6 date Required: if not used
set value to none
visits_header_7 authorization Required: if not used
set value to none
Visits_Data (see below)
Data to be imported in batch: single (text) field with <eol>s at the end of each line:

1111222233334444|12121|N|Coffees|3|03/15/2010|API test import 1

1111222233334444|12121|N|Cakes|1|03/15/2010|API test import 2

1111222233334444|12121|Y|Coffees|1|03/15/2010|API test redeem 1

Notes:

  • 'service_product' is not the "id" but the "description" returned by the BuyX Campaign Items List API call. This is because some clients import lists of transaction with items they did not pre-enter in the admin interface. Thus, the import does allows new (service_product) items to be used that have not been pre-defined.
  • The caveat is that each service_product name must be exactly spelled and capitalized the same, usually not an issue when that information is taken from another database or output from a POS or inventory management system.  

 

Fields for Events (Visits) Based Campaigns:

  field   Example   Note
visits_header_1 campaign_id Required
visits_header_2 code Required
visits_header_3 redeemed Required: Y | N
visits_header_4 date Required: if not used
set value to none
visits_header_5 authorization Required: if not used
set value to none
visits_header_6 amount If redeemed = Y then Required
else set array key to none
visits_header_7 none Required: if not used
set value to none
Visits_Data (see below)
Events to be imported in batch: single (text) field with <eol>s at the end of each line:

1111222233334444|12121|N|03/15/2010|API add event

1111222233334444|12121|N|03/15/2010|API add event

Redemptions to be imported in batch: Single (text) field with <eol>s at end of each line:
1111222233334444|12121|Y|03/15/2010|API redeem|2

 

Fields for Earn-per-Event (Visits) Campaigns:

  field   Example   Note
visits_header_1 campaign_id Required
visits_header_2 code Required
visits_header_3 redeemed Required: Y | N
visits_header_4 date Required: if not used
set value to none
visits_header_5 authorization Required: if not used
set value to none
visits_header_6 amount If redeemed = Y then Required
else set array key to none
visits_header_7 none Required: if not used
set value to none
Visits_Data (see below)
Events to be imported in batch: single (text) field with <eol>s at the end of each line:

1111222233334444|12121|N|03/15/2010|API add event

1111222233334444|12121|N|03/15/2010|API add event

Redemptions to be imported in batch: single (text) field with <eol>s at end of each line:
1111222233334444|12121|Y|03/15/2010|API redeem|46.95

 

Notes:

  • 'code' is either
    • the unique Customer ID recored in the 'code' field when the customer account was first created AND there was no 'card_number'), or
    • the 'card_number' of the customer.
  • If date is not given, today's date will be used.
  • Unless there's a good reason, include the 'no-undo' = 'yes' directive, otherwise every batch will be listed in the Manage Customer Records section.

 

Example PHP Request for Points-Based Campaign:

If you are using PHP, the $data array would look like this:

  1. $data['user_id'] = 'john1970';
  2. $data['user_password'] = '1959caadac9b13dcb3';
  3. $data['type'] = 'batch_transactions';
  4. $data['account_id'] = 'greatwidgets';
  5. $data['delimiter'] = 'pipe';
  6. $data['apply_ratio'] = 'yes';
  7. $data['no-undo'] = 'yes';
  8. $data['visits_header_1'] = 'campaign_id';
  9. $data['visits_header_2'] = 'code';
  10. $data['visits_header_3'] = 'redeemed';
  11. $data['visits_header_4'] = 'amount';
  12. $data['visits_header_5'] = 'date';
  13. $data['visits_header_6'] = 'authorization';
  14. $data['visits_header_7'] = 'none';
  15. $data['Visits_Data'] = '
  16. 4638472975924871|12121|N|14,95|03/15/2010|API test import 1
  17. 4638472975924871|12121|N|50|03/15/2010|API test import 2
  18. 4638472975924871|12121|N|34.67|03/15/2010|API test import 3
  19. 4638472975924871|12121|N|0,50|03/15/2010|API test import 4
  20. 4638472975924871|12121|N|.75|03/15/2010|API test import 5
  21. 4638472975924871|12121|N|2.00|03/15/2010|API test import 6
  22. 4638472975924871|12121|Y|1500|03/15/2010|API test redeem 1
  23. ';

 

Success XML Response:

  1. <response status="success">
  2. <batch status="imported">
  3. <transactions>7</transactions>
  4. </batch>
  5. </response>

 

Error XML Response:

  1. <response status="error">
  2. <error>Error message</error>
  3. </response>