Customer Balance and Transaction History
Returns a customer's balance and transaction history for a particular campaign.
The data to be submitted to the API is composed of the following fields:
|
|
field |
|
Example |
|
Note |
|
|
|
user_id |
|
john1970 |
|
Required |
|
|
|
user_password |
|
1959caadac9b13dcb3 |
|
Required |
|
|
|
type |
|
customer_balance |
|
Required |
|
|
|
account_id |
|
greatwidgets |
|
Required |
|
|
|
campaign_id |
|
1111222233334444 |
|
Required |
|
|
|
code
or
card_number |
|
1234567890123456
or
234566 |
|
Required |
|
|
|
transactions_number |
|
0 for none
1 to 9999...
|
|
Optional |
|
|
|
across_campaigns |
|
Yes |
|
Optional |
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
|
|
Notes:
- When using this call with 'code', it must be the unique Customer ID that was either passed as 'code' by your program when the customer record was created previously, or the 16-digit number that was generated by us and returned to you in the API response.
- The transactions_number field lets you specify how many transactions to return along with the balance:
- A value of "0" means none will be returned.
- Anything above "0" will return the number of transactions specified.
- Not providing this field returns ALL transactions.
- For coalition accounts, the balance will be the coalition balance, not the individual campaign balance. Hence the totals of the transactions may not add up to the coalition balance, since the customer may have other transactions in other campaign(s). Only the transactions for this campaign will be listed.
- To have the customer history of the customer's transactions in a coalition account (only) include all the transactions in all the campaigns that resulted in the balance, include the parameter across_campaigns set to Yes.
Example PHP Request:
If you are using PHP, the $data array would look like this:
- $data['user_id'] = 'john1970';
- $data['user_password'] = '1959caadac9b13dcb3';
- $data['type'] = 'customer_balance';
- $data['account_id'] = 'greatwidgets';
- $data['campaign_id'] = 'Store Rewards';
- $data['code'] = '1234567890123456';
- or
- $data['card_number'] = '29374856';
Success XML Response (Points-Based Campaign):
- <response status="success">
- <campaign>
- <campaign_id>4857302875023023</campaign_id>
- <campaign_type>points</campaign_type>
- <campaign_name>Store_Rewards</campaign_name>
- <customer>
- <code>1234567890123456</code>
- <balance>1500</balance>
- <last_transaction>2011-12-15</last_transaction>
- <last_redemption>2011-12-31</last_redemption>
- <transactions>
- <transaction>
- <id>4056</id>
- <date>2011-12-15</date>
- <amount>20000</amount>
- <orig_amount>200</orig_amount>
- <redeemed>N</redeemed>
- <authorization>Purchased Item</authorization>
- <user_name>employee1</user_name>
- </transaction>
- <transaction>
- <id>4097</id>
- <date>2011-21-31</date>
- <amount>-15000</amount>
- <redeemed>Y</redeemed>
- <authorization>Redeemed Item</authorization>
- <user_name>employee2</user_name>
- </transaction>
- ...
- </transactions>
- </customer>
- </campaign>
- </response>
Success XML Response (Points-Based Campaign with Spend-to-Reward ratio set):
- <response status="success">
- <campaign>
- <campaign_id>4857302875023023</campaign_id>
- <campaign_type>points</campaign_type>
- <campaign_name>Store_Rewards</campaign_name>
- <reward_ratio>10</reward_ratio>
- <customer>
- <code>1234567890123456</code>
- <balance>1500</balance>
- <equivalent_cash_balance>1.50</equivalent_cash_balance>
- <equivalent_cash_currency>Euro</equivalent_cash_currency>
- <equivalent_cash_glyph>€</equivalent_cash_glyph>
- <last_transaction>2011-12-15</last_transaction>
- <last_redemption>2011-12-31</last_redemption>
- <transactions>
- <transaction>
- <id>4056</id>
- <date>2011-03-15</date>
- <amount>20000</amount>
- <orig_amount>200</orig_amount>
- <redeemed>N</redeemed>
- <authorization>Purchased Item</authorization>
- <user_name>employee1</user_name>
- </transaction>
- <transaction>
- <id>4097</id>
- <date>2011-12-31</date>
- <amount>-50-0</amount>
- <equivalent_cash_amount>-5.00</equivalent_cash_amount>
- <redeemed>Y</redeemed>
- <authorization>Redeemed Item</authorization>
- <user_name>employee2</user_name>
- </transaction>
- ...
- </transactions>
- </customer>
- </campaign>
- </response>
Success XML Response (Points-Based Campaign with Custom Fields):
- <response status="success">
- <campaign>
- <campaign_id>4857302875023023</campaign_id>
- <campaign_type>points</campaign_type>
- <campaign_name>Store_Rewards</campaign_name>
- <customer>
- <code>1234567890123456</code>
- <balance>1500</balance>
- <equivalent_cash_balance>1.50</equivalent_cash_balance>
- <equivalent_cash_currency>Euro</equivalent_cash_currency>
- <equivalent_cash_glyph>€</equivalent_cash_glyph>
- <last_transaction>2011-12-15</last_transaction>
- <last_redemption>2011-12-31</last_redemption>
- <transactions>
- <transaction>
- <id>4056</id>
- <date>2011-12-15</date>
- <amount>20000</amount>
- <orig_amount>200.00</orig_amount>
- <redeemed>N</redeemed>
- <authorization>Purchased Item</authorization>
- <user_name>employee1</user_name>
- <custom_field_2>
- <label>quantity</label>
- <data>2</data>
- </custom_field_2>
- </transaction>
- <transaction>
- <id>4097</id>
- <date>2011-12-31</date>
- <amount>-5000</amount>
- <redeemed>Y</redeemed>
- <authorization>Redeemed Item</authorization>
- <user_name>employee2</user_name>
- <custom_field_2>
- <label>quantity</label>
- <data>1</data>
- </custom_field_2>
- </transaction>
- ...
- </transactions>
- </customer>
- </campaign>
- </response>
Success XML Response (Gift Card Campaign):
- <response status="success">
- <campaign>
- <campaign_id>57203576293875493</campaign_id>
- <campaign_type>giftcard</campaign_type>
- <campaign_name>Gift Basket</campaign_name>
- <customer>
- <code>1234567890123456</code>
- <balance>36.75</balance>
- <last_transaction>2011-12-15</last_transaction>
- <last_redemption>2011-12-31</last_redemption>
- <transactions>
- <transaction>
- <id>4056</id>
- <date>2011-12-15</date>
- <amount>40</amount>
- <redeemed>N</redeemed>
- <authorization>Cash Added</authorization>
- <user_name>employee2</user_name>
- </transaction>
- <transaction>
- <id>4097</id>
- <date>2011-12-31</date>
- <amount>-3.25</amount>
- <redeemed>Y</redeemed>
- <authorization>Cash Redeemed</authorization>
- <user_name>employee2</user_name>
- </transaction>
- ...
- </transactions>
- </customer>
- </campaign>
- </response>
Success XML Response (Buy-X-Get_One-Free / Membership Campaign):
- <response status="success">
- <campaign>
- <campaign_id>53485702387562034</campaign_id>
- <campaign_type>buyx</campaign_type>
- <campaign_name>Club Fantastic</campaign_name>
- <customer>
- <code>1234567890123456</code>
- <balances>
- <item>
- <name>Coffees</name>
- <balance>14</balance>
- <earned>1</earned>
- </item>
- <item>
- <name>Cakes</name>
- <balance>7</balance>
- <earned>0</earned>
- </item>
- <item>
- <name>Books</name>
- <balance>2</balance>
- <earned>0</earned>
- </item>
- </balances>
- <last_transaction>2011-12-15</last_transaction>
- <last_redemption>2011-12-31</last_redemption>
- <transactions>
- <transaction>
- <id>4056</id>
- <date>2011-12-15</date>
- <service_product>Coffees</service_product>
- <amount>12</amount>
- <redeemed>N</redeemed>
- <authorization>Purchased Items</authorization>
- <user_name>employee1</user_name>
- </transaction>
- <transaction>
- <id>4097</id>
- <date>2011-12-31</date>
- <service_product>Cakes</service_product>
- <amount>1</amount>
- <redeemed>Y</redeemed>
- <authorization>Redeemed Items</authorization>
- <user_name>employee1</user_name>
- </transaction>
- ...
- </transactions>
- </customer>
- </campaign>
- </response>
NOTES:
- The <balance> is the amount of purchases that have accumulated
- The <earned> is the amount of items that the customer has earned based on the <balance> of items purchased.
- The <balance> is not a cumulative balance -- It is the current balance of purchases that count towards the calculation of <earned> items.
- When an <earned> item is redeemed, the amount of items that were needed to earn it are deducted from the <balance>
- For example: A customer purchases 14 coffees. They earn 1 free coffee per 10 purchased (this ratio is defined when a campaign is created or updated and is also reported in the Campaign - List BuyX Items API call). This this means that with a <balance> of 14 they have <earned> 1 free Coffee. They then redeem it (get a free one) and their <balance> is now 4 (14-10=4) and with only 4 they have now <earned> 0 (have not yet earned any.)
Success XML Response (Events (Visits) Based Campaign):
- <response status="success">
- <campaign>
- <campaign_id>683979284679238</campaign_id>
- <campaign_type>events</campaign_type>
- <campaign_name>Frequent Shopper</campaign_name>
- <customer>
- <code>1234567890123456</code>
- <balance>23</balance>
- <last_transaction>2011-12-15</last_transaction>
- <last_redemption>2011-12-31</last_redemption>
- <transactions>
- <transaction>
- <id>4056</id>
- <date>2011-12-15</date>
- <amount>1</amount>
- <redeemed>N</redeemed>
- <authorization>Visit Note</authorization>
- <user_name>employee1</user_name>
- <transaction>
- </transaction>
- <id>4097</id>
- <date>2011-12-31</date>
- <amount>-10</amount>
- <redeemed>Y</redeemed>
- <authorization>Redeemed Reward</authorization>
- <user_name>employee2</user_name>
- </transaction>
- ...
- </transactions>
- </customer>
- </campaign>
- </response>
Success XML Response (Earn-per-Event Based Campaign):
- <response status="success">
- <campaign>
- <campaign_id>325702938572039</campaign_id>
- <campaign_type>earned</campaign_type>
- <campaign_name>Referral Rewards</campaign_name>
- <customer>
- <code>1234567890123456</code>
- <balance>105.00</balance>
- <last_transaction>2011-12-15</last_transaction>
- <last_redemption>2011-12-31</last_redemption>
- <transactions>
- <transaction>
- <id>4056</id>
- <date>2011-12-15</date>
- <amount>4.50</amount>
- <redeemed>N</redeemed>
- <authorization>Event Earning</authorization>
- <user_name>employee1</user_name>
- </transaction>
- <transaction>
- <id>4097</id>
- <date>2011-12-31</date>
- <amount>-29.95</amount>
- <redeemed>Y</redeemed>
- <authorization>Redeemed reward</authorization>
- <user_name>employee1</user_name>
- </transaction>
- ...
- </transactions>
- </customer>
- </campaign>
- </response>
Error XML Response:
- <response status="error">
- <error>Error message</error>
- </response>
|