Skip to main content

Track Orders & Cashback Reward

Use the SDK methods for order-tracking and cashback updates when your platform registers paid orders.
import Gameball

let order = OrderRequest(
    orderId: "order-123",
    customerId: "customer-123",
    amount: 99.99,
    currency: "USD",
    status: "paid"
)

Gameball.shared.sendOrder(order) { result in
    switch result {
    case .success:
        print("Order tracked successfully")
    case .failure(let error):
        print("Error: \(error.localizedDescription)")
    }
}

Order Parameters

orderId
String
required
Unique identifier for the order.
customerId
String
required
The customer who placed the order.
amount
Double
required
Total order amount.
currency
String
required
Currency code (e.g., “USD”, “EUR”, “GBP”).
status
String
required
Order status: “paid”, “pending”, “cancelled”, “refunded”.
lineItems
[OrderLineItem]
List of products/items in the order.
Important: It’s recommended to call order/cashback APIs when the order is actually paid to avoid incorrect reward assignment. For COD (Cash on Delivery) orders, wait until payment is captured before tracking.

Order with Line Items

let lineItem1 = OrderLineItem(
    productId: "PROD-123",
    productName: "Wireless Headphones",
    quantity: 1,
    price: 79.99
)

let lineItem2 = OrderLineItem(
    productId: "PROD-456",
    productName: "Phone Case",
    quantity: 2,
    price: 19.99
)

let order = OrderRequest(
    orderId: "order-123",
    customerId: "customer-123",
    amount: 119.97,
    currency: "USD",
    status: "paid",
    lineItems: [lineItem1, lineItem2]
)

Gameball.shared.sendOrder(order) { result in
    // Handle result
}

Cashback Rewards

Cashback is automatically calculated based on your Gameball program configuration. Ensure your cashback rules are properly set up in the Gameball dashboard to reward customers for their purchases.
For more advanced order tracking scenarios, you can also use the server-side Order API for better control and security.

Next Steps