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 = leal.customers().create(storeId,
CreateCustomersRequest.builder()
.customer(CreateCustomersRequestCustomer.builder()
.firstName("Ada")
.email("ada@example.com")
.build())
.cardId(cardId)
.build()); Add a stamp
The call most integrations need. Leal records the stamp, updates the wallet pass and sends the notification.
var card = leal.customerCards().stamp(storeId, customerId, customerCardId,
StampCustomerCardsRequest.builder()
.stamps(1)
.build()); Redeem a reward
Spend the stamps a customer has earned. Leal checks the reward is available before recording the redemption.
leal.customerCards().redeem(storeId, customerId, customerCardId,
RedeemCustomerCardsRequest.builder()
.rewardId(rewardId)
.build()); Handle a failure
Every failure throws a typed exception, so you can tell a missing record from a rate limit without reading strings.
import com.getleal.api.core.LealApiException;
try {
leal.customerCards().stamp(storeId, customerId, customerCardId, request);
} catch (LealApiException error) {
// Wait for the seconds in the Retry-After header, then try again.
throw error;
}