Designing a Spring Boot Starter for Lantu Pay’s Personal‑Sign‑Up SDK
This article walks through the design and implementation of a Spring Boot Starter for the Lantu Pay SDK that supports personal sign‑up, covering project structure, configuration classes, HTTP layer abstraction using strategy and template patterns, and request/response model design with concrete code examples.
Spring Boot Starter Design
The SDK is built by first creating a Starter module, defining public interfaces, and then implementing core business classes. A Properties class holds merchant ID, secret key and other configuration values. An auto‑configuration class injects these properties into LantuWxConfigStorage (stores parameters) and LantuWxPayService (global entry point for business code). The repository URL is https://github.com/wuchubuzai2018/lantu-pay-sdk.
HTTP Framework Layer Design
The SDK abstracts HTTP requests using a combination of the Strategy pattern and the Template Method pattern. Three interfaces— RequestHttp, RequestExecutor, ResponseHandler —and two abstract classes define a generic request flow that can be implemented with different HTTP clients such as OkHttp, HttpClient or RestTemplate.
RequestExecutorrepresents the executor (GET, POST, etc.). ResponseHandler parses the raw response. An AbstractPostRequestExecutor routes POST requests to a concrete OkHttpSimplePostRequestExecutor, encapsulating the core OkHttp logic.
Request and Response Model Design
Request and response POJOs follow the Open API specification. A common abstract class AbstractWxPayRequest provides fields such as merchant ID, timestamp and signature, annotated with FastJSON @JSONField to map JSON names. It implements checkFields for required‑parameter validation and checkAndSign for unified signing.
Each API (order creation, query, refund) has a concrete request class extending this base. A generic response wrapper uses generics to deserialize different payloads.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Ubiquitous Tech
A ubiquitous public account for pirate enthusiasts, regularly sharing curated experiences, tech learning, and growth insights. Currently publishing articles on AI RAG customer service, AI MCP technology, and open-source design. Personal free Knowledge Planet: Awakening New World Programmer.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
