Reporting Transactions
The SDK can report various types of transactions to the server. For any product sold, we can create a product, set transaction type, and provide additional attributes.
Report Product Purchases
let productPurchased = PJDSDKModel.Product()productPurchased.name = "White Jersey - Nike"productPurchased.productDescription = "White Jersey - Nike"productPurchased.price = 25.80productPurchased.quantity = 1productPurchased.vendor = "Nike"let productPurchased2 = PJDSDKModel.Product()productPurchased.productDescription = "White Sneakers - Nike"productPurchased.price = 100.00productPurchased.quantity = 1productPurchased.vendor = "Nike"let transaction = PJDSDKModel.Transaction(with: permissions)//see "Report User Attributes" section for how to create permissionstransaction.tax = 10.00transaction.total = 135.80transaction.orderID = "ORDID120039"transaction.products = [productPurchased, productPurchased2]PJDSDK.sharedInstance.reportEvent(eventType: PJDTransactionType.MERCHANDISE, withTransaction: transaction)
The entire list is available here.
Syntax | Description |
---|---|
PJDSDKModel.Product | - |
name | String |
productDescription | String |
sku | String |
quantity | Int |
total | Double (the total monetary amount of the transaction) |
tax | Double [REQUIRED](any tax assessed on the transaction) |
price | Double [REQUIRED] |
meta | key/value pairs |
vendor | String |
currencyCode | String (default is “USD”) |
PJDSDKModel.Transaction | - |
userID | String [REQUIRED](UserID in createUser Req) |
fingerprint | String [REQUIRED] (UDID) |
total | Double [REQUIRED](the total monetary amount of the transaction) |
tax | Double [REQUIRED] (any tax assessed on the transaction) |
type | String (ticketing, merch, food and bev, subscription, etc) for event types refer Appendix B |
orderID | String (Order ID from source system) |
products | Array of PJDSDKModel.Product [REQUIRED] |
meta | key/value pairs |
transactedAt | String (yyyy-mm-dd H:i:s) |
subtotal | Int [REQUIRED] |
Mandatory Properties
Syntax | Description |
---|---|
permissions | PJDSDKModel.BasicPermissions |
Note: From v1.7 The PJDSDKModel.Transaction class also requires PJDSDKModel.BasicPermissions as mandatory class property at the time of its init, in order to work, See section (#2-initialization) for how to create “permissions”