Adds POST /customer/wallet/payment-code (docs/prd-point-coin.md F9, K8, PC-304). The customer approves with their PIN on their own phone and gets a 6-digit code, as digits and as a QR payload (enakpoint:<code>) for the app to render, valid for two minutes. The PIN is never typed at the cashier. Codes are drawn from crypto/rand and stored in Redis with SET NX and a TTL, bound to the customer; a new code retires the previous one. Redeeming is a single Lua step that uses the code up only if it belongs to the order's customer, so it stays one-time under a race, and a cashier scanning it against the wrong order does not burn it for its owner, which a plain GETDEL would. Expired, used, unknown and other customers' codes are all refused alike. Tests run against miniredis, added as a test dependency. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
34 lines
1.0 KiB
Go
34 lines
1.0 KiB
Go
package contract
|
|
|
|
// Requests of /customer/pin and /marketing/customers/:id/pin (docs/prd-point-coin.md
|
|
// F11). PINs are strings so a leading zero is kept.
|
|
|
|
type RequestPinOtpRequest struct {
|
|
// pin_setup or pin_reset.
|
|
Purpose string `json:"purpose" binding:"required"`
|
|
}
|
|
|
|
type CreateCustomerPinRequest struct {
|
|
OtpToken string `json:"otp_token" binding:"required"`
|
|
OtpCode string `json:"otp_code" binding:"required"`
|
|
Pin string `json:"pin" binding:"required"`
|
|
ConfirmPin string `json:"confirm_pin" binding:"required"`
|
|
}
|
|
|
|
type ChangeCustomerPinRequest struct {
|
|
OldPin string `json:"old_pin" binding:"required"`
|
|
Pin string `json:"pin" binding:"required"`
|
|
ConfirmPin string `json:"confirm_pin" binding:"required"`
|
|
}
|
|
|
|
type ResetCustomerPinRequest = CreateCustomerPinRequest
|
|
|
|
type RemoveCustomerPinRequest struct {
|
|
Reason string `json:"reason" binding:"required"`
|
|
}
|
|
|
|
// IssuePaymentCodeRequest is POST /customer/wallet/payment-code.
|
|
type IssuePaymentCodeRequest struct {
|
|
Pin string `json:"pin" binding:"required"`
|
|
}
|