Enrol a customer
Create the customer and put them straight onto a card. The response carries the Apple Wallet and Google Wallet links, so you can send them yourself.
var customer = await leal.Customers.CreateAsync(
new CreateCustomersRequest
{
AccountId = storeId,
Customer = new CreateCustomersRequestCustomer
{
FirstName = "Ada",
Email = "ada@example.com",
},
CardId = cardId,
}); Add a stamp
The call most integrations need. Leal records the stamp, updates the wallet pass and sends the notification.
var card = await leal.CustomerCards.StampAsync(
new StampCustomerCardsRequest
{
AccountId = storeId,
CustomerId = customerId,
Id = customerCardId,
Stamps = 1,
}); Redeem a reward
Spend the stamps a customer has earned. Leal checks the reward is available before recording the redemption.
await leal.CustomerCards.RedeemAsync(
new RedeemCustomerCardsRequest
{
AccountId = storeId,
CustomerId = customerId,
Id = customerCardId,
RewardId = rewardId,
}); Handle a failure
Every failure throws a typed exception carrying the status code, so you can tell a missing record from a rate limit without reading strings.
try
{
await leal.CustomerCards.StampAsync(request);
}
catch (LealClientApiException error) when (error.StatusCode == 429)
{
// Wait for the seconds in the Retry-After header, then try again.
}