keel-module-alipay
v0.1.0
Published
支付宝支付 (Alipay payment) for Keel React Native apps.
Maintainers
Readme
keel-module-alipay
支付宝支付 (Alipay payment) for Keel apps. The second build-verified Keel vendor module — same SPM
.binaryTargetrecipe askeel-module-wechat.
pay() runs the Alipay cashier for a server-signed order string and
resolves with { resultStatus, result, memo } (resultStatus === "9000" =
success). Your server builds + signs orderInfo (alipay.trade.app.pay)
with the merchant private key — the key never ships in the bundle.
| Platform | Upstream SDK | Symbol |
|----------|--------------|--------|
| iOS | AlipaySDK.xcframework — SPM .binaryTarget in Package.swift (Alipay's official CDN zip, pinned by checksum) | AlipaySDK |
| Android | com.alipay.sdk:alipaysdk-android (maven) | PayTask.payV2 |
iOS delivery note: an SPM source target can't
importa CocoaPods module, so the SDK is consumed as an SPM.binaryTarget(notios.pods). The SDK's transitive system frameworks (WebKit/CoreTelephony/z/…) are declared aslinkerSettingsinPackage.swift. The zip also ships anAlipaySDK.bundle(payment-UI assets) that a production app must embed as an app resource — not needed to build/link/launch.
Install
keel install keel-module-alipayKeel autolinking wires both platforms on the next build (no manual Podfile/Gradle edits).
iOS one-time fetch: Alipay's xcframework lives behind an extension-less
CDN url (so SPM binaryTarget(url:) can't take it), and its framework slices
ship a broken Info.plist. So the SDK is vendored via binaryTarget(path:),
populated by a fetch script (runs automatically on npm install's
postinstall; run it manually if needed):
sh node_modules/keel-module-alipay/packaging/fetch-sdk.shUsage
import * as alipay from 'keel-module-alipay';
// orderString comes from YOUR server (signed with the merchant key).
const { resultStatus } = await alipay.pay({
orderString,
scheme: 'myapp', // iOS only — must match a CFBundleURLSchemes entry
});
if (resultStatus === '9000') { /* success — verify result on your server */ }pay() does not reject on user cancel — check resultStatus
("6001" = cancel). It rejects only if the native module isn't linked or
orderString is missing.
Host integration
iOS
SDK — already wired via the SPM
.binaryTargetinPackage.swift.URL scheme — add your
scheme(e.g.myapp) toCFBundleURLTypes, and pass it topay({ scheme }).Route the return — when Alipay switches back to your app, the host AppDelegate/SceneDelegate forwards the URL to the module:
import KeelModuleAlipay func scene(_ scene: UIScene, openURLContexts contexts: Set<UIOpenURLContext>) { if let url = contexts.first?.url, KeelModuleAlipay.handleOpen(url) { return } // … existing handling … }
Android
The SDK is pulled automatically (build.gradle.kts), and the trampoline
KeelAlipayActivity is declared in this module's manifest — no host code.
Server side
Build + sign the order on your backend (alipay.trade.app.pay), return the
orderInfo string, and verify the async/result signature there before
fulfilling. Keep the merchant private key on the server.
License
Apache-2.0 — see LICENSE in the parent monorepo.
