Skip to main content

WeChat Pay integration: from writing backends to filling in config

CloudBase TeamCloudBase Team
2 min read

Accepting a WeChat Pay transaction in a mini program used to take far more than "calling an API" — storing merchant keys, implementing request signing, applying for an HTTPS callback domain, writing signature verification and decryption, handling retries and risk control. A full stack of cryptography plus network-fallback logic often accounts for 30% of the entire project's code.

CloudBase now ships the Integration Center, which pushes this heavy lifting down to the platform layer. You write business logic; the platform does the rest.

What the Integration Center does

What you used to doWhat the platform does now
Store keys in env vars / your own databaseCredential custody: secure storage for API keys, certificates, and secrets
Write request signing / callback verification / decryptionSigning & verification: done by the platform — you receive plaintext
Apply for a callback domain + HTTPSCallback proxy: callbacks hit the Integration Center first, get verified, then forward to your function
Handle timeouts / retries / risk controlError handling: platform-side fallback; your side only needs idempotency
Bake credentials into code or env varsCredential injection: injected into the function runtime in a controlled way

Four steps to integrate

1. Create the integration: Integration Center → pick a type (e.g. "Mini Program WeChat Pay") → fill in credentials and config
2. Auto-deploy: the platform generates an HTTP cloud function and injects credentials as env vars
3. Call it: invoke the integration function from front end or back end via SDK or HTTP (orders, queries, refunds)
4. Handle callbacks: async callbacks are verified and decrypted by the Integration Center, then forwarded to your function route as plaintext

Once created, the integration function appears in your cloud function list with a name like <integration-name>-<random-string>. Call it straight from the SDK — no signature-verification code required.

Build your next app on CloudBase

An all-in-one backend covering database, cloud functions, static hosting, and AI capabilities.